Module: check_mk
Branch: master
Commit: 8a3f8171c60903a159cb0442648c1e92ff8af473
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=8a3f8171c60903…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Wed Jul 8 16:02:26 2015 +0200
LDAP: additional encoding fixes; fixed group to role sync test
---
web/htdocs/wato.py | 24 ++++++++++++++----------
web/plugins/userdb/ldap.py | 6 +++---
2 files changed, 17 insertions(+), 13 deletions(-)
diff --git a/web/htdocs/wato.py b/web/htdocs/wato.py
index 0d1aff2..c08c906 100644
--- a/web/htdocs/wato.py
+++ b/web/htdocs/wato.py
@@ -7753,7 +7753,7 @@ def mode_edit_ldap_connection(phase):
msg = _('Found no group object for synchronization. Please check your
filter settings.')
except Exception, e:
ldap_groups = None
- msg = str(e)
+ msg = "%s" % e
if 'successful bind must be completed' in msg:
if not connection.has_bind_credentials_configured():
return (False, _('Please configure proper bind
credentials.'))
@@ -7772,15 +7772,19 @@ def mode_edit_ldap_connection(phase):
connection.connect(enforce_new = True, enforce_server = address)
num = 0
- for role_id, dn in active_plugins['groups_to_roles'].items():
- if isinstance(dn, str):
- num += 1
- try:
- ldap_groups = connection.get_groups(dn)
- if not ldap_groups:
- return False, _('Could not find the group specified for
role %s') % role_id
- except Exception, e:
- return False, _('Error while fetching group for role %s:
%s') % (role_id, str(e))
+ for role_id, group_distinguished_names in
active_plugins['groups_to_roles'].items():
+ if type(group_distinguished_names) != list:
+ group_distinguished_names = [group_distinguished_names]
+
+ for dn in group_distinguished_names:
+ if type(dn) in [ str, unicode ]:
+ num += 1
+ try:
+ ldap_groups = connection.get_groups(dn)
+ if not ldap_groups:
+ return False, _('Could not find the group specified
for role %s') % role_id
+ except Exception, e:
+ return False, _('Error while fetching group for role %s:
%s') % (role_id, e)
return True, _('Found all %d groups.') % num
tests = [
diff --git a/web/plugins/userdb/ldap.py b/web/plugins/userdb/ldap.py
index bd6318d..b56abb5 100644
--- a/web/plugins/userdb/ldap.py
+++ b/web/plugins/userdb/ldap.py
@@ -1335,7 +1335,7 @@ def ldap_convert_groups_to_roles(connection, plugin, params,
user_id, ldap_user,
for role_id, distinguished_names in params.items():
if type(distinguished_names) == list:
groups_to_fetch += [ dn.lower() for dn in distinguished_names ]
- elif type(distinguished_names) == str:
+ elif type(distinguished_names) in [ str, unicode ]:
groups_to_fetch.append(distinguished_names.lower())
ldap_groups = dict(connection.group_members(groups_to_fetch,
@@ -1355,7 +1355,7 @@ def ldap_convert_groups_to_roles(connection, plugin, params,
user_id, ldap_user,
distinguished_names = [distinguished_names]
for dn in distinguished_names:
- if not isinstance(dn, str):
+ if type(dn) not in [ str, unicode ]:
continue # skip non configured ones (old valuespecs allowed None)
dn = dn.lower() # lower case matching for DNs!
@@ -1469,7 +1469,7 @@ def synchronize_profile_to_sites(user_id, profile):
try:
result = wato.push_user_profile_to_site(site, user_id, profile)
except Exception, e:
- result = str(e)
+ result = "%s" % e
if result == True:
num_succeeded += 1