From f821aab9f406e6d90a7381243d7f283aa6ffd96c Mon Sep 17 00:00:00 2001 From: kakwa Date: Thu, 18 Jun 2015 20:38:10 +0200 Subject: [PATCH] adding logs when adding a user to a group --- ldapcherry/backend/backendLdap.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/ldapcherry/backend/backendLdap.py b/ldapcherry/backend/backendLdap.py index a978019..3585a3c 100644 --- a/ldapcherry/backend/backendLdap.py +++ b/ldapcherry/backend/backendLdap.py @@ -258,11 +258,20 @@ class Backend(ldapcherry.backend.Backend): group = self._str(group) for attr in self.group_attrs: content = self._str(self.group_attrs[attr] % attrs) + self._logger( + severity = logging.DEBUG, + msg = "%(backend)s: adding user '%(user)s' with dn '%(dn)s' to group '%(group)s' by setting '%(attr)s' to '%(content)s'" % \ + { 'user': username, 'dn': dn, 'group': group, 'attr': attr, 'content': content, 'backend': self.backend_name } + ) ldif = modlist.modifyModlist({}, { attr : content }) try: ldap_client.modify_s(group, ldif) except ldap.TYPE_OR_VALUE_EXISTS as e: - pass + self._logger( + severity = logging.INFO, + msg = "%(backend)s: user '%(user)s' already member of group '%(group)s' (attribute '%(attr)s')" % \ + { 'user': username, 'group': group, 'attr': attr, 'backend': self.backend_name} + ) ldap_client.unbind_s() def del_from_groups(self, username, groups):