From 9f40d2c93b44f63cf169c212be3ddadc5012fabe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tim=20Gr=C3=B6ger?= Date: Tue, 31 Dec 2019 13:06:40 +0100 Subject: [PATCH] fixed #107 getUserData "from ldap" is now surrounded with try --- geruecht/controller/ldapController.py | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/geruecht/controller/ldapController.py b/geruecht/controller/ldapController.py index b543e64..67ba4c0 100644 --- a/geruecht/controller/ldapController.py +++ b/geruecht/controller/ldapController.py @@ -30,15 +30,18 @@ class LDAPController(metaclass=Singleton): raise PermissionDenied("Invalid Password or Username") def getUserData(self, username): - self.connect() - search_data = self.client.search_s('ou=user,{}'.format(self.dn), ldap.SCOPE_SUBTREE, 'uid={}'.format(username), ['uid', 'givenName', 'sn']) - retVal = search_data[0][1] - for k,v in retVal.items(): - retVal[k] = v[0].decode('utf-8') - retVal['dn'] = self.dn - retVal['firstname'] = retVal['givenName'] - retVal['lastname'] = retVal['sn'] - return retVal + try: + self.connect() + search_data = self.client.search_s('ou=user,{}'.format(self.dn), ldap.SCOPE_SUBTREE, 'uid={}'.format(username), ['uid', 'givenName', 'sn']) + retVal = search_data[0][1] + for k,v in retVal.items(): + retVal[k] = v[0].decode('utf-8') + retVal['dn'] = self.dn + retVal['firstname'] = retVal['givenName'] + retVal['lastname'] = retVal['sn'] + return retVal + except: + raise PermissionDenied("No User exists with this uid.") def getGroup(self, username):