try to update userdata in database from ldap when getAllUsersFromDB is executed

This commit is contained in:
Tim Gröger 2020-02-26 22:49:23 +01:00
parent 80fbe2b759
commit 358826e8c4
2 changed files with 15 additions and 1 deletions

View File

@ -38,8 +38,10 @@ class LDAPController(metaclass=Singleton):
'dn': self.ldap.connection.response[0]['dn'],
'firstname': user['givenName'][0],
'lastname': user['sn'][0],
'uid': username
'uid': username,
}
if user['mail']:
retVal['mail'] = user['mail'][0]
return retVal
except:
raise PermissionDenied("No User exists with this uid.")

View File

@ -110,6 +110,14 @@ class UserController(metaclass=Singleton):
db.updateUser(user)
return self.getUser(username)
def __updateDataFromLDAP(self, user):
groups = ldap.getGroup(user.uid)
user_data = ldap.getUserData(user.uid)
user_data['gruppe'] = groups
user_data['group'] = groups
user.updateData(user_data)
db.updateUser(user)
def autoLock(self, user):
if user.autoLock:
if user.getGeruecht(year=datetime.now().year).getSchulden() <= (-1*user.limit):
@ -141,6 +149,10 @@ class UserController(metaclass=Singleton):
def getAllUsersfromDB(self):
users = db.getAllUser()
for user in users:
try:
self.__updateDataFromLDAP(user)
except:
pass
self.__updateGeruechte(user)
return db.getAllUser()