[checkmk-commits] LDAP sync: Better display of changed values

Mathias Kettner mk at mathias-kettner.de
Fri Nov 11 11:28:49 CET 2016


Module: check_mk
Branch: master
Commit: 4bb44ea5d7244ecb5b7d4569be2eeee3f0f487bf
URL:    http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=4bb44ea5d7244ecb5b7d4569be2eeee3f0f487bf

Author: Mathias Kettner <mk at mathias-kettner.de>
Date:   Fri Nov 11 11:28:46 2016 +0100

LDAP sync: Better display of changed values

---

 web/plugins/userdb/ldap.py | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/web/plugins/userdb/ldap.py b/web/plugins/userdb/ldap.py
index bfc014b..8eb70c2 100644
--- a/web/plugins/userdb/ldap.py
+++ b/web/plugins/userdb/ldap.py
@@ -997,10 +997,10 @@ class LDAPUserConnector(UserConnector):
                 intersect = set_new.intersection(set_old)
                 added = set_new - intersect
                 removed = set_old - intersect
-                changed = self.find_changed_user_keys(intersect, users[user_id], user)
 
-            users[user_id] = user # Update the user record
+                changed = self.find_changed_user_keys(intersect, users[user_id], user) # returns a dict
 
+            users[user_id] = user # Update the user record
             if mode_create:
                 if config.wato_enabled:
                     wato.add_change("edit-users",
@@ -1028,7 +1028,8 @@ class LDAPUserConnector(UserConnector):
                     synchronize_profile_to_sites(self, user_id, user)
 
                 if changed:
-                    details.append(('Changed: %s') % ', '.join(changed))
+		    for key, (old_value, new_value) in sorted(changed.items()):
+                        details.append(('Changed %s from %s to %s' % (key, old_value, new_value)))
 
                 if details and config.wato_enabled:
                     wato.add_change("edit-users",
@@ -1048,7 +1049,7 @@ class LDAPUserConnector(UserConnector):
 
 
     def find_changed_user_keys(self, keys, user, new_user):
-        changed = set([])
+        changed = {}
         for key in keys:
             value = user[key]
             new_value = new_user[key]
@@ -1057,7 +1058,7 @@ class LDAPUserConnector(UserConnector):
             else:
                 is_changed = value != new_value
             if is_changed:
-                changed.add(key)
+                changed[key] = (value, new_value)
         return changed
 
 



More information about the checkmk-commits mailing list