Module: check_mk
Branch: master
Commit: 272730df76b5951169d89414179a70e7482b33b9
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=272730df76b595…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Tue Nov 5 10:10:55 2013 +0100
FIX LDAP: Improved error reporting during synchronisation
Providing more details in case of errors during sync
---
.werks/43 | 8 ++++++++
ChangeLog | 3 +++
web/htdocs/userdb.py | 12 ++++++++++--
web/plugins/userdb/ldap.py | 16 ++++++++++++----
4 files changed, 33 insertions(+), 6 deletions(-)
diff --git a/.werks/43 b/.werks/43
new file mode 100644
index 0000000..cd717b6
--- /dev/null
+++ b/.werks/43
@@ -0,0 +1,8 @@
+Title: LDAP: Improved error reporting during synchronisation
+Level: 1
+Component: multisite
+Version: 1.2.3i7
+Date: 1383642604
+Class: fix
+
+Providing more details in case of errors during sync
diff --git a/ChangeLog b/ChangeLog
index 5554448..5fe2918 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,4 +1,7 @@
1.2.3i7:
+ Multisite:
+ * 0043 FIX : LDAP: Improved error reporting during synchronisation...
+
1.2.3i6:
Core & Setup:
diff --git a/web/htdocs/userdb.py b/web/htdocs/userdb.py
index 51814ee..dab736f 100644
--- a/web/htdocs/userdb.py
+++ b/web/htdocs/userdb.py
@@ -161,6 +161,7 @@ def on_failed_login(username):
root_dir = defaults.check_mk_configdir + "/wato/"
multisite_dir = defaults.default_config_dir + "/multisite.d/wato/"
+#.
# .--Users---------------------------------------------------------------.
# | _ _ |
# | | | | |___ ___ _ __ ___ |
@@ -460,6 +461,7 @@ def save_users(profiles):
# Call the users_saved hook
hooks.call("users-saved", users)
+#.
# .-Roles----------------------------------------------------------------.
# | ____ _ |
# | | _ \ ___ | | ___ ___ |
@@ -513,6 +515,7 @@ def load_roles():
'Initializing structure...' % (filename, e))
return roles
+#.
# .-Groups---------------------------------------------------------------.
# | ____ |
# | / ___|_ __ ___ _ _ _ __ ___ |
@@ -548,6 +551,7 @@ def load_group_information():
'Initializing structure...' % (filename, e))
return {}
+#.
# .--Custom-Attrs.-------------------------------------------------------.
# | ____ _ _ _ _ |
# | / ___| _ ___| |_ ___ _ __ ___ / \ | |_| |_ _ __ ___ |
@@ -595,6 +599,7 @@ def declare_custom_user_attrs():
topic = attr.get('topic', 'personal'),
)
+#.
# .----------------------------------------------------------------------.
# | _ _ _ |
# | | | | | ___ ___ | | _____ |
@@ -743,6 +748,9 @@ def hook_page():
def ajax_sync():
try:
hook_sync(add_to_changelog = False, raise_exc = True)
- html.write('OK')
+ html.write('OK\n')
except Exception, e:
- html.write('ERROR %s' % e)
+ if config.debug:
+ raise
+ else:
+ html.write('ERROR %s\n' % e)
diff --git a/web/plugins/userdb/ldap.py b/web/plugins/userdb/ldap.py
index c6719e1..645878c 100644
--- a/web/plugins/userdb/ldap.py
+++ b/web/plugins/userdb/ldap.py
@@ -195,8 +195,8 @@ def ldap_connect(enforce_new = False, enforce_server = None):
# Got no connection to any server
if ldap_connection is None:
- raise MKLDAPException(_('The LDAP connector is unable to connect to the
LDAP server.\n%s') %
- ('<br />\n'.join(errors)))
+ raise MKLDAPException(_('LDAP connection failed:\n%s') %
+ ('\n'.join(errors)))
# on success, store the connection options the connection has been made with
ldap_connection_options = config.ldap_connection
@@ -316,6 +316,7 @@ def ldap_search(base, filt = '(objectclass=*)', columns = [],
scope = None):
# be as stable as it is needed. So we try to repeat the query for three times.
tries_left = 2
success = False
+ last_exc = None
while not success:
tries_left -= 1
try:
@@ -345,6 +346,7 @@ def ldap_search(base, filt = '(objectclass=*)', columns = [],
scope = None):
'incomplete results. You should change the
scope of operation '
'within the ldap or adapt the limit settings
of the LDAP server.'))
except (ldap.SERVER_DOWN, ldap.TIMEOUT, MKLDAPException), e:
+ last_exc = e
if tries_left:
ldap_log(' Received %r. Retrying with clean connection...' % e)
ldap_disconnect()
@@ -357,8 +359,14 @@ def ldap_search(base, filt = '(objectclass=*)', columns = [],
scope = None):
if not success:
ldap_log(' FAILED')
- raise MKLDAPException(_('Unable to successfully perform the LDAP search.
'
- 'Maybe there is a connection problem with the LDAP
server.'))
+ if config.debug:
+ raise MKLDAPException(_('Unable to successfully perform the LDAP search
'
+ '(Base: %s, Scope: %s, Filter: %s, Columns: %s):
%s') %
+ (html.attrencode(base), html.attrencode(scope),
+ html.attrencode(filt),
html.attrencode(','.join(columns))),
+ last_exc)
+ else:
+ raise MKLDAPException(_('Unable to successfully perform the LDAP search
(%s)') % last_exc)
ldap_log(' RESULT length: %d, duration: %0.3f' % (len(result), duration))
return result