synchronisations mit Ldap

wenn userlänge des ldap nicht mit der der datenbank übereinstimmt wird die datenbank mit dem ldap synchronisiert.
This commit is contained in:
Tim Gröger 2020-06-05 23:26:15 +02:00
parent 93fcbe72ae
commit 7d19c13071
2 changed files with 10 additions and 0 deletions

View File

@ -9,6 +9,8 @@ from geruecht.model.user import User
class Base:
def getCreditListFromUser(self, user, **kwargs):
try:
if user.uid == 'extern':
return []
cursor = self.db.connection.cursor()
if 'year' in kwargs:
sql = "select * from creditList where user_id={} and year_date={}".format(user.id if type(user) is User else user, kwargs['year'])

View File

@ -78,8 +78,16 @@ class Base:
debug.debug("updated config of user is {{ {} }}".format(retVal))
return retVal
def syncLdap(self):
debug.info('sync Users from Ldap')
ldap_users = ldap.getAllUser()
for user in ldap_users:
self.getUser(user['username'])
def getAllUsersfromDB(self, extern=True):
debug.info("get all users from database")
if (len(ldap.getAllUser()) != len(db.getAllUser())):
self.syncLdap()
users = db.getAllUser()
debug.debug("users are {{ {} }}".format(users))
for user in users: