Module: check_mk
Branch: master
Commit: 4da4115e3dfc65b34f4f4c9f52221ae2f98c8f75
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=4da4115e3dfc65…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Fri Mar 11 10:12:44 2016 +0100
LDAP: Fixed default values of user/group attributes/filters
---
web/htdocs/wato.py | 8 ++++----
web/plugins/userdb/ldap.py | 9 +++++++++
2 files changed, 13 insertions(+), 4 deletions(-)
diff --git a/web/htdocs/wato.py b/web/htdocs/wato.py
index 2813d0d..14bb805 100644
--- a/web/htdocs/wato.py
+++ b/web/htdocs/wato.py
@@ -5801,7 +5801,7 @@ def vs_ldap_connection(new, connection_id):
"Members of a group:<br> "
"<tt>(&(objectclass=user)(objectcategory=person)(memberof=CN=cmk-users,OU=groups,DC=example,DC=com))</tt><br>"),
size = 80,
- default_value = lambda: userdb.ldap_filter('users', False),
+ default_value = lambda: userdb.ldap_filter_of_connection(connection_id,
'users', False),
attrencode = True,
)),
("user_filter_group", LDAPDistinguishedName(
@@ -5825,7 +5825,7 @@ def vs_ldap_connection(new, connection_id):
help = _("The attribute used to identify the individual users. It must
have "
"unique values to make an user identifyable by the value of
this "
"attribute."),
- default_value = lambda: userdb.ldap_attr('user_id'),
+ default_value = lambda: userdb.ldap_attr_of_connection(connection_id,
'user_id'),
attrencode = True,
)),
("lower_user_ids", FixedValue(
@@ -5879,13 +5879,13 @@ def vs_ldap_connection(new, connection_id):
"subset of the groups below the given base
DN.<br><br>"
"e.g. <tt>(objectclass=group)</tt>"),
size = 80,
- default_value = lambda: userdb.ldap_filter('groups', False),
+ default_value = lambda: userdb.ldap_filter_of_connection(connection_id,
'groups', False),
attrencode = True,
)),
("group_member", TextAscii(
title = _("Member Attribute"),
help = _("The attribute used to identify users group
memberships."),
- default_value = lambda: userdb.ldap_attr('member'),
+ default_value = lambda: userdb.ldap_attr_of_connection(connection_id,
'member'),
attrencode = True,
)),
]
diff --git a/web/plugins/userdb/ldap.py b/web/plugins/userdb/ldap.py
index db86eba..54921ee 100644
--- a/web/plugins/userdb/ldap.py
+++ b/web/plugins/userdb/ldap.py
@@ -1214,6 +1214,15 @@ def ldap_attr_of_connection(connection_id, attr):
return connection.ldap_attr(attr)
+# Helper function for gathering the default LDAP filters of a connection.
+def ldap_filter_of_connection(connection_id, *args, **kwargs):
+ connection = get_connection(connection_id)
+ if not connection:
+ return None
+
+ return connection.ldap_filter(*args, **kwargs)
+
+
def ldap_sync_simple(user_id, ldap_user, user, user_attr, attr):
if attr in ldap_user:
return {user_attr: ldap_user[attr][0]}