From 7d19c130713f04c3dca330716a5b1669afe09b37 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tim=20Gr=C3=B6ger?= Date: Fri, 5 Jun 2020 23:26:15 +0200 Subject: [PATCH] synchronisations mit Ldap MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit wenn userlänge des ldap nicht mit der der datenbank übereinstimmt wird die datenbank mit dem ldap synchronisiert. --- .../databaseController/dbCreditListController.py | 2 ++ geruecht/controller/mainController/mainUserController.py | 8 ++++++++ 2 files changed, 10 insertions(+) diff --git a/geruecht/controller/databaseController/dbCreditListController.py b/geruecht/controller/databaseController/dbCreditListController.py index ddbc262..6e75cb7 100644 --- a/geruecht/controller/databaseController/dbCreditListController.py +++ b/geruecht/controller/databaseController/dbCreditListController.py @@ -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']) diff --git a/geruecht/controller/mainController/mainUserController.py b/geruecht/controller/mainController/mainUserController.py index 03371b8..5e6550f 100644 --- a/geruecht/controller/mainController/mainUserController.py +++ b/geruecht/controller/mainController/mainUserController.py @@ -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: