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

Disbale check_names on LDAP connection

ldap3 behavior differs severely between different versions with check_names enabled.
parent 043e3023
No related branches found
No related tags found
1 merge request!11Resolve "LDAP-Authentifizierung an Active Directory"
......@@ -152,13 +152,12 @@ if 'LDAP_HOST' in config:
def ldapauth(user, password):
user = LDAP_USERRE.sub(r'', user.lower())
try:
conn = ldap3.Connection(ldap3.Server(config['LDAP_HOST'], port=config['LDAP_PORT'], use_ssl=True), 'fsmpi\\%s'%user, password, auto_bind=True)
conn = ldap3.Connection(ldap3.Server(config['LDAP_HOST'], port=config['LDAP_PORT'], use_ssl=True), 'fsmpi\\%s'%user, password, auto_bind=True, check_names=False)
except ldap3.core.exceptions.LDAPBindError:
return {}, []
conn.search("cn=users,dc=fsmpi,dc=rwth-aachen,dc=de", "(cn=%s)"%user, attributes=['memberOf', 'givenName', 'sn'])
info = dict(conn.response[0]['attributes'])
info['uid'] = user
groups = [g.split(',')[0].split('=')[-1] for g in info['memberOf']]
info = {'uid': user, 'givenName': conn.response[0]['attributes']['givenName'][0], 'sn': conn.response[0]['attributes']['sn'][0]}
groups = [g.split(',')[0].split('=')[-1] for g in conn.response[0]['attributes']['memberOf']]
conn.unbind()
return info, groups
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment