fix: ldap3 changes for #64

parent 1f53210c
......@@ -90,15 +90,17 @@ class LdapLoader:
query = '{0}={1}'.format(self.attr, searchval)'filter: %s | base: %s', query, self.base)
r =, query, attributes=['cn', self.attr]), query, attributes=['cn', self.attr])
r = self.ldap.response
except Exception as e:'Ooops, LDAP lookup failed: {0}'.format(str(e)))
return None
for record in r:
if searchval in record[self.attr]:'Found DN: {0}'.format(record.dn))
return {'dn': record.dn, 'cn': record['cn'][0]}
attrs = record['attributes']
if self.attr in attrs and searchval in attrs[self.attr]:'Found DN: {0}'.format(record['dn']))
return {'dn': record['dn'], 'cn': attrs['cn'][0]}
def check(self, dn=None, passwd=None):
......@@ -115,14 +117,16 @@ class LdapLoader:
l = Connection(self.server, user='{0}'.format(dn), password=passwd, raise_exceptions=True)
b ='Bound as user: {0}'.format(dn))
b = l.bind()
except Exception as e:'Failed to authenticate user: {0}, {1}'.format(dn, str(e)))
return False
if b:'Bound as user: {0}'.format(dn))
else:'Failed to authenticate user: {0}, {1}'.format(dn, str(e)))
return b
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