Skip to content
Snippets Groups Projects
Commit 21be06b9 authored by Julian Rother's avatar Julian Rother
Browse files

Fix more corner-cases of LDAP auth errors

parent cdc798a9
No related branches found
No related tags found
No related merge requests found
......@@ -121,11 +121,12 @@ if 'LDAP_HOST' in config:
user = LDAP_USERRE.sub(r'', user.lower())
try:
conn = ldap3.Connection(config['LDAP_HOST'], 'uid=%s,ou=users,dc=fsmpi,dc=rwth-aachen,dc=de'%user, password, auto_bind=True)
groups = []
if conn.search("ou=groups,dc=fsmpi,dc=rwth-aachen,dc=de", "(&(cn=*)(memberUid=%s))"%user, attributes=['cn']):
groups = [e['attributes']['cn'][0] for e in conn.response]
conn.unbind()
return user, groups
except ldap3.core.exceptions.LDAPBindError:
except ldap3.core.exceptions.LDAPExceptionError:
return None, []
def ldapget(user):
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment