Module: check_mk
Branch: master
Commit: e7a2987e1f430fd1ca9dd387b64f373b1e568db4
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=e7a2987e1f430f…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Wed Jul 8 15:43:46 2015 +0200
The Check_MK LDAP integration can now deal with LDAP directories which use special
characters
like german umlauts e.g. in OU (Organisational Unit) names in the LDAP directory.
Previous
version simply did not allow to configure such DNs (Distinguished Names) as user or group
DNs.
Conflicts:
ChangeLog
web/plugins/userdb/ldap.py
---
.werks/2396 | 12 ++++++++++++
ChangeLog | 1 +
web/htdocs/valuespec.py | 2 +-
web/htdocs/wato.py | 2 +-
web/plugins/userdb/ldap.py | 13 +++++++++++--
5 files changed, 26 insertions(+), 4 deletions(-)
diff --git a/.werks/2396 b/.werks/2396
new file mode 100644
index 0000000..3e14d8c
--- /dev/null
+++ b/.werks/2396
@@ -0,0 +1,12 @@
+Title: LDAP: Fixed handling of LDAP trees having special chars in the path (e.g. in OU
names)
+Level: 1
+Component: multisite
+Class: fix
+Compatible: compat
+State: unknown
+Version: 1.2.7i3
+Date: 1436362239
+
+The Check_MK LDAP integration can now deal with LDAP directories which use special
characters
+like german umlauts e.g. in OU (Organisational Unit) names in the LDAP directory.
Previous
+version simply did not allow to configure such DNs (Distinguished Names) as user or group
DNs.
diff --git a/ChangeLog b/ChangeLog
index 6a248a5..62aa62e 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -55,6 +55,7 @@
* 2380 FIX: Custom Host Notes painter was showing service notes when used in service
based views
* 2393 FIX: Fixed exception "user_confdir" not set in case of exceptions
during login
* 1263 FIX: Fixed handling of urls in views...
+ * 2396 FIX: LDAP: Fixed handling of LDAP trees having special chars in the path (e.g.
in OU names)...
WATO:
* 2365 Removed old deprecated notification global options for plain emails...
diff --git a/web/htdocs/valuespec.py b/web/htdocs/valuespec.py
index 1373c81..ef6e5fe 100644
--- a/web/htdocs/valuespec.py
+++ b/web/htdocs/valuespec.py
@@ -3148,7 +3148,7 @@ class Transform(ValueSpec):
self._valuespec.validate_value(self.forth(value), varprefix)
ValueSpec.custom_validate(self, value, varprefix)
-class LDAPDistinguishedName(TextAscii):
+class LDAPDistinguishedName(TextUnicode):
def __init__(self, **kwargs):
TextAscii.__init__(self, **kwargs)
self.enforce_suffix = kwargs.get('enforce_suffix')
diff --git a/web/htdocs/wato.py b/web/htdocs/wato.py
index 4cd28c7..0d1aff2 100644
--- a/web/htdocs/wato.py
+++ b/web/htdocs/wato.py
@@ -7722,7 +7722,7 @@ def mode_edit_ldap_connection(phase):
msg = _('Found no user object for synchronization. Please check your
filter settings.')
except Exception, e:
ldap_users = 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.'))
diff --git a/web/plugins/userdb/ldap.py b/web/plugins/userdb/ldap.py
index 97e3249..bd6318d 100644
--- a/web/plugins/userdb/ldap.py
+++ b/web/plugins/userdb/ldap.py
@@ -115,9 +115,11 @@ ldap_umlaut_translation = {
ord(u'æ'): u'ae',
}
+
class MKLDAPException(MKGeneralException):
pass
+
def ldap_test_module():
try:
ldap
@@ -125,6 +127,13 @@ def ldap_test_module():
raise MKLDAPException(_("The python module python-ldap seems to be missing.
You need to "
"install this extension to make the LDAP user
connector work."))
+
+def make_utf8(x):
+ if type(x) == unicode:
+ return x.encode('utf-8')
+ else:
+ return x
+
#.
# .--UserConnector-------------------------------------------------------.
# | _ _ ____ _ |
@@ -430,7 +439,7 @@ class LDAPUserConnector(UserConnector):
try:
search_func = self._config.get('page_size') \
and self.ldap_paged_async_search or
self.ldap_async_search
- for dn, obj in search_func(base, self.ldap_get_scope(scope), filt,
columns):
+ for dn, obj in search_func(make_utf8(base),
self.ldap_get_scope(scope), make_utf8(filt), columns):
if dn is None:
continue # skip unwanted answers
new_obj = {}
@@ -454,7 +463,7 @@ class LDAPUserConnector(UserConnector):
last_exc = e
if tries_left:
self.log(' Received %r. Retrying with clean connection...' %
e)
- ldap_disconnect()
+ self.disconnect()
time.sleep(0.5)
else:
self.log(' Giving up.')