From 21be06b93e0aaecab7edc9e4faeebf1dd3f140ca Mon Sep 17 00:00:00 2001
From: Julian Rother <julianr@fsmpi.rwth-aachen.de>
Date: Sat, 18 Feb 2017 02:13:48 +0100
Subject: [PATCH] Fix more corner-cases of LDAP auth errors

---
 db.py | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/db.py b/db.py
index 7b5fef1..b062972 100644
--- a/db.py
+++ b/db.py
@@ -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):
-- 
GitLab