Module: check_mk
Branch: master
Commit: 112c770a7cc6a1f5c70b11c4dce0f29a11fbe5e6
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=112c770a7cc6a1…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Wed Jan 9 11:11:56 2013 +0100
ldap: Detecting and handling size limit errors for better understanding
---
web/plugins/userdb/ldap.py | 17 ++++++++++++-----
1 files changed, 12 insertions(+), 5 deletions(-)
diff --git a/web/plugins/userdb/ldap.py b/web/plugins/userdb/ldap.py
index fb441f2..1f9775f 100644
--- a/web/plugins/userdb/ldap.py
+++ b/web/plugins/userdb/ldap.py
@@ -192,11 +192,18 @@ def ldap_search(base, filt = '(objectclass=*)', columns =
[], scope = None):
# Convert all keys to lower case!
result = []
- for dn, obj in ldap_connection.search_s(base, scope, filt, columns):
- new_obj = {}
- for key, val in obj.iteritems():
- new_obj[key.lower().decode('utf-8')] = [ i.decode('utf-8')
for i in val ]
- result.append((dn, new_obj))
+ try:
+ for dn, obj in ldap_connection.search_s(base, scope, filt, columns):
+ new_obj = {}
+ for key, val in obj.iteritems():
+ new_obj[key.lower().decode('utf-8')] = [
i.decode('utf-8') for i in val ]
+ result.append((dn, new_obj))
+ except ldap.SIZELIMIT_EXCEEDED:
+ raise MKLDAPException(_('The response reached a size limit. This could be due
to '
+ 'a sizelimit configuration on the LDAP server.<br
/>Throwing away the '
+ 'incomplete results. You should change the scope of
operation '
+ 'within the ldap or adapt the limit settings of the
LDAP server.'))
+
return result
#return ldap_connection.search_s(base, scope, filter, columns)
#for dn, obj in ldap_connection.search_s(base, scope, filter, columns):