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 diff --git a/app/models.py b/app/models.py index 2c18969..b56487b 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 = "(&(objectcategory=person)(samaccountname=%s))" % self.username try: result = self.ldap_search(searchFilter, LDAP_SEARCH_BASE) except Exception, e: diff --git a/config_template.py b/config_template.py index 22043f8..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' @@ -23,6 +26,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/'