From 7c6801158dda7c987f3b75ad5673bfb2d74dcc0b Mon Sep 17 00:00:00 2001 From: Chuyen Vo Date: Thu, 17 Mar 2016 10:35:53 +0700 Subject: [PATCH 1/5] Update models.py Update AD search filter --- app/models.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/app/models.py b/app/models.py index 2c18969..e9a78f8 100644 --- a/app/models.py +++ b/app/models.py @@ -18,6 +18,7 @@ LDAP_URI = app.config['LDAP_URI'] LDAP_USERNAME = app.config['LDAP_USERNAME'] LDAP_PASSWORD = app.config['LDAP_PASSWORD'] LDAP_SEARCH_BASE = app.config['LDAP_SEARCH_BASE'] +LDAP_TYPE = app.config['LDAP_TYPE'] PDNS_STATS_URL = app.config['PDNS_STATS_URL'] PDNS_API_KEY = app.config['PDNS_API_KEY'] @@ -146,7 +147,10 @@ class User(db.Model): return False elif method == 'LDAP': - searchFilter = "cn=%s" % self.username + if LDAP_TYPE == 'ldap': + searchFilter = "cn=%s" % self.username + else: + searchFilter = "sammaaccount=%s" % self.username try: result = self.ldap_search(searchFilter, LDAP_SEARCH_BASE) except Exception, e: From d231335382ec499448b765c79b916a0a50c9fa2a Mon Sep 17 00:00:00 2001 From: Chuyen Vo Date: Thu, 17 Mar 2016 10:36:29 +0700 Subject: [PATCH 2/5] Update config_template.py --- config_template.py | 1 + 1 file changed, 1 insertion(+) diff --git a/config_template.py b/config_template.py index 22043f8..69bbac1 100644 --- a/config_template.py +++ b/config_template.py @@ -23,6 +23,7 @@ LDAP_URI = 'ldaps://your-ldap-server:636' LDAP_USERNAME = 'cn=dnsuser,ou=users,ou=services,dc=duykhanh,dc=me' LDAP_PASSWORD = 'dnsuser' LDAP_SEARCH_BASE = 'ou=System Admins,ou=People,dc=duykhanh,dc=me' +LDAP_TYPE = 'ldap' // or 'ad' # POWERDNS CONFIG PDNS_STATS_URL = 'http://172.16.214.131:8081/' From 5e1898c47a6a8f0449b4439602243e68cfc81574 Mon Sep 17 00:00:00 2001 From: Chuyen Vo Date: Thu, 17 Mar 2016 11:59:33 +0700 Subject: [PATCH 3/5] Update config_template.py add timeout requests --- config_template.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/config_template.py b/config_template.py index 69bbac1..12a3ca7 100644 --- a/config_template.py +++ b/config_template.py @@ -6,6 +6,9 @@ WTF_CSRF_ENABLED = True SECRET_KEY = 'We are the world' PORT = 9393 +# TIMEOUT - for large zones +TIMEOUT = 10 + # LOG CONFIG LOG_LEVEL = 'DEBUG' LOG_FILE = 'logfile.log' From 1ccd98a3643889c2bb87f84cacdcd3e69bfd6261 Mon Sep 17 00:00:00 2001 From: Chuyen Vo Date: Thu, 17 Mar 2016 12:00:33 +0700 Subject: [PATCH 4/5] Update utils.py add timeout requests.request for large zones --- app/lib/utils.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/app/lib/utils.py b/app/lib/utils.py index 1b838a8..888b4d1 100644 --- a/app/lib/utils.py +++ b/app/lib/utils.py @@ -3,6 +3,9 @@ import sys import json import requests import urlparse +from app import app + +TIMEOUT = app.config['TIMEOUT'] def auth_from_url(url): auth = None @@ -18,7 +21,7 @@ def fetch_remote(remote_url, method='GET', data=None, accept=None, params=None, data = json.dumps(data) if timeout is None: - timeout = 1.5 + timeout = TIMEOUT verify = False @@ -125,4 +128,4 @@ def display_time(amount, units='s', remove_seconds=True): final_string = final_string[:final_string.rfind(' ')] return final_string[:final_string.rfind(' ')] - return final_string \ No newline at end of file + return final_string From 02323d2fada0a9353d1060cf41e8d7fb2e60cd14 Mon Sep 17 00:00:00 2001 From: Chuyen Vo Date: Thu, 17 Mar 2016 17:45:50 +0700 Subject: [PATCH 5/5] Fix AD searchfilter --- app/models.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/models.py b/app/models.py index e9a78f8..b56487b 100644 --- a/app/models.py +++ b/app/models.py @@ -150,7 +150,7 @@ class User(db.Model): if LDAP_TYPE == 'ldap': searchFilter = "cn=%s" % self.username else: - searchFilter = "sammaaccount=%s" % self.username + searchFilter = "(&(objectcategory=person)(samaccountname=%s))" % self.username try: result = self.ldap_search(searchFilter, LDAP_SEARCH_BASE) except Exception, e: