getUserData "from ldap" is now surrounded with try
This commit is contained in:
Tim Gröger 2019-12-31 13:06:40 +01:00
parent 7a95fb9d32
commit 9f40d2c93b
1 changed files with 12 additions and 9 deletions

View File

@ -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):