Module: check_mk
Branch: master
Commit: 2fa8ec98c1e3dbdff253cd22ba0b3f2b05be3d8e
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=2fa8ec98c1e3db…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Tue Sep 26 12:11:46 2017 +0200
5210 FIX LDAP: Fixed equal default value for custom variable sync plugins
The LDAP sync plugins that are dynamically created for each configured
custom user attribute all had the same default value for the LDAP field
to use during syncing.
Change-Id: Ia1213721b94d1746d81d68880e711318170e2be7
---
.werks/5210 | 13 +++++++++++++
web/plugins/userdb/ldap.py | 10 ++++++++--
2 files changed, 21 insertions(+), 2 deletions(-)
diff --git a/.werks/5210 b/.werks/5210
new file mode 100644
index 0000000..a31b9d2
--- /dev/null
+++ b/.werks/5210
@@ -0,0 +1,13 @@
+Title: LDAP: Fixed equal default value for custom variable sync plugins
+Level: 1
+Component: multisite
+Class: fix
+Compatible: compat
+Edition: cre
+State: unknown
+Version: 1.5.0i1
+Date: 1506420627
+
+The LDAP sync plugins that are dynamically created for each configured
+custom user attribute all had the same default value for the LDAP field
+to use during syncing.
diff --git a/web/plugins/userdb/ldap.py b/web/plugins/userdb/ldap.py
index 919dc5e..ea8cee3 100644
--- a/web/plugins/userdb/ldap.py
+++ b/web/plugins/userdb/ldap.py
@@ -1303,11 +1303,17 @@ def register_user_attribute_sync_plugins():
if attr_name not in ldap_builtin_attribute_plugin_names:
del ldap_attribute_plugins[attr_name]
+ def default_attr_value(attr):
+ return lambda: ldap_attr_of_connection(g_editing_connection_id, attr)
+
+ def needed_attributes(attr):
+ return lambda connection, params: [ params.get('attr',
connection.ldap_attr(attr)).lower() ]
+
for attr, val in get_user_attributes():
ldap_attribute_plugins[attr] = {
'title': val['valuespec'].title(),
'help': val['valuespec'].help(),
- 'needed_attributes': lambda connection, params: [
params.get('attr', connection.ldap_attr(attr)).lower() ],
+ 'needed_attributes': needed_attributes(attr),
'sync_func': lambda connection, plugin, params, user_id,
ldap_user, user: \
ldap_sync_simple(user_id, ldap_user, user,
plugin,
params.get('attr',
connection.ldap_attr(plugin)).lower()),
@@ -1316,7 +1322,7 @@ def register_user_attribute_sync_plugins():
('attr', TextAscii(
title = _("LDAP attribute to sync"),
help = _("The LDAP attribute whose contents shall be synced
into this custom attribute."),
- default_value = lambda:
ldap_attr_of_connection(g_editing_connection_id, attr),
+ default_value = default_attr_value(attr),
)),
],
}