Commit 5eeddfb2 authored by Wade Fitzpatrick's avatar Wade Fitzpatrick

fix: use int for ldap port and better debugging

parent e4f6219f
......@@ -43,7 +43,7 @@ class LdapLoader:
if self.encryption == 'ssl':
self.ssl = True
elif self.encryption == 'tls':
selt.tls = True
self.tls = True'LDAP host: %s','LDAP port: %s', self.port)'LDAP encryption: %s', self.encryption)
......@@ -54,17 +54,17 @@ class LdapLoader:'LDAP bindpw: %s', '*****' if self.bindpw else 'None')
self.server = Server(, port=self.port, use_ssl=self.ssl, get_info=ALL, tls=self.tls)
self.server = Server(, port=int(self.port), use_ssl=self.ssl, get_info=ALL, tls=self.tls)'LDAP Server = {0}'.format(str(self.server)))
self.ldap = Connection(self.server, user=self.binddn, password=self.bindpw, raise_exceptions=True)
binded = False
with self.ldap:
binded = True
if binded:
if self.ldap.bind():'LDAP Connection = {0}'.format(str(self.ldap)))'OK, connected to LDAP')
raise Exception('Not connected')
except:'Could not connect to LDAP')'LDAP Connection = {0}'.format(str(self.ldap)))
except Exception as e:'Could not connect to LDAP: {0}'.format(str(e)))
self.server = None
self.ldap = None
......@@ -95,6 +95,7 @@ class LdapLoader:'filter: %s | base: %s', query, self.base)
r = None
with self.ldap:'LDAP Connection = {0}'.format(str(self.ldap))), query, attributes=['cn', self.attr])
r = self.ldap.response
if not r:
......@@ -124,6 +125,7 @@ class LdapLoader:
with Connection(self.server, user='{0}'.format(dn), password=passwd, raise_exceptions=True) as l:'LDAP Connection = {0}'.format(str(l)))'Bound as user: {0}'.format(dn))
return True
except Exception as e:
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment