From 25406a36a7e418fdb8a3953671549582e26d5c45 Mon Sep 17 00:00:00 2001 From: Bogdano Arendartchuk Date: Thu, 3 May 2007 20:50:01 +0000 Subject: As noted by Andreas, LDAP search results can have only the needed attributes of ldap-resultformat. Fixed it. --- RepSys/plugins/ldapusers.py | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/RepSys/plugins/ldapusers.py b/RepSys/plugins/ldapusers.py index 7eb6a09..371a2a8 100644 --- a/RepSys/plugins/ldapusers.py +++ b/RepSys/plugins/ldapusers.py @@ -82,6 +82,18 @@ def interpolate(optname, format, data): raise Error, "LDAP response formatting error: %s. Check " \ "your %s configuration" % (e, optname) +def used_attributes(format): + class DummyDict: + def __init__(self): + self.found = [] + def __getitem__(self, key): + self.found.append(key) + return key + dd = DummyDict() + t = string.Template(format) + t.safe_substitute(dd) + return dd.found + def make_handler(): server = config.get("global", "ldap-server") port = config.get("global", "ldap-port", 389) @@ -123,8 +135,10 @@ def make_handler(): data = {"username": option} filter = interpolate("ldap-filterformat", filterformat, data) + attrs = used_attributes(format) try: - found = l.search_s(basedn, ldap.SCOPE_SUBTREE, filter) + found = l.search_s(basedn, ldap.SCOPE_SUBTREE, filter, + attrlist=attrs) except ldap.LDAPError, e: raise LDAPError(e) if found: -- cgit v1.2.1