aboutsummaryrefslogtreecommitdiffstats
path: root/RepSys
diff options
context:
space:
mode:
authorBogdano Arendartchuk <bogdano@mandriva.org>2007-05-03 20:50:01 +0000
committerBogdano Arendartchuk <bogdano@mandriva.org>2007-05-03 20:50:01 +0000
commit25406a36a7e418fdb8a3953671549582e26d5c45 (patch)
treee343318b833fcd9bfe9d3c2f9d42d6d8aa287aea /RepSys
parentadb75a7908bd19535ca6ba1d8cc6363a3a1530c8 (diff)
downloadmgarepo-25406a36a7e418fdb8a3953671549582e26d5c45.tar
mgarepo-25406a36a7e418fdb8a3953671549582e26d5c45.tar.gz
mgarepo-25406a36a7e418fdb8a3953671549582e26d5c45.tar.bz2
mgarepo-25406a36a7e418fdb8a3953671549582e26d5c45.tar.xz
mgarepo-25406a36a7e418fdb8a3953671549582e26d5c45.zip
As noted by Andreas, LDAP search results can have only the needed
attributes of ldap-resultformat. Fixed it.
Diffstat (limited to 'RepSys')
-rw-r--r--RepSys/plugins/ldapusers.py16
1 files changed, 15 insertions, 1 deletions
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: