From 5bab4a7cdeefd312d039bd5ad6a08b22a6fe45f6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tim=20Gr=C3=B6ger?= Date: Tue, 9 May 2023 21:59:00 +0200 Subject: [PATCH] fix update ldap, no none types pushed, add more debugging --- flaschengeist/plugins/auth_ldap/__init__.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/flaschengeist/plugins/auth_ldap/__init__.py b/flaschengeist/plugins/auth_ldap/__init__.py index 8a99284..db2823a 100644 --- a/flaschengeist/plugins/auth_ldap/__init__.py +++ b/flaschengeist/plugins/auth_ldap/__init__.py @@ -126,9 +126,12 @@ class AuthLDAP(AuthPlugin): def modify_user(self, user: User, password=None, new_password=None): try: dn = user.get_attribute("DN") + logger.debug(f"LDAP: modify_user for user {user.userid} with dn {dn}") if password: + logger.debug(f"LDAP: modify_user for user {user.userid} with password") ldap_conn = self.ldap.connect(dn, password) else: + logger.debug(f"LDAP: modify_user for user {user.userid} with root_dn") if self.root_dn is None: logger.error("root_dn missing in ldap config!") raise InternalServerError @@ -141,9 +144,15 @@ class AuthLDAP(AuthPlugin): ("display_name", "displayName"), ]: if hasattr(user, name): - modifier[ldap_name] = [(MODIFY_REPLACE, [getattr(user, name)])] + attribute = getattr(user, name) + if attribute: + modifier[ldap_name] = [(MODIFY_REPLACE, [getattr(user, name)])] if new_password: modifier["userPassword"] = [(MODIFY_REPLACE, [self.__hash(new_password)])] + if "userPassword" in modifier: + logger.debug(f"LDAP: modify_user for user {user.userid} with password change (can't show >modifier<)") + else: + logger.debug(f"LDAP: modify_user for user {user.userid} with modifier {modifier}") ldap_conn.modify(dn, modifier) self._set_roles(user) except (LDAPPasswordIsMandatoryError, LDAPBindError):