diff options
author | Bogdano Arendartchuk <bogdano@mandriva.org> | 2007-05-04 15:49:18 +0000 |
---|---|---|
committer | Bogdano Arendartchuk <bogdano@mandriva.org> | 2007-05-04 15:49:18 +0000 |
commit | bd030af75529f0f6344252983a9a1f434baedf6b (patch) | |
tree | 7f99ad843bf9b125cd7aee5accb76b05dd92b42f /RepSys/plugins | |
parent | e04d72f060b1a8257bab955f6c0931989d546f99 (diff) | |
download | mgarepo-bd030af75529f0f6344252983a9a1f434baedf6b.tar mgarepo-bd030af75529f0f6344252983a9a1f434baedf6b.tar.gz mgarepo-bd030af75529f0f6344252983a9a1f434baedf6b.tar.bz2 mgarepo-bd030af75529f0f6344252983a9a1f434baedf6b.tar.xz mgarepo-bd030af75529f0f6344252983a9a1f434baedf6b.zip |
Unbind the ldapobject after searching.
Diffstat (limited to 'RepSys/plugins')
-rw-r--r-- | RepSys/plugins/ldapusers.py | 36 |
1 files changed, 19 insertions, 17 deletions
diff --git a/RepSys/plugins/ldapusers.py b/RepSys/plugins/ldapusers.py index b43862b..6471f58 100644 --- a/RepSys/plugins/ldapusers.py +++ b/RepSys/plugins/ldapusers.py @@ -136,24 +136,26 @@ def make_handler(): l.bind(binddn, bindpw) except ldap.LDAPError, e: raise LDAPError(e) - - data = {"username": option} - filter = interpolate("ldap-filterformat", filterformat, data) - attrs = used_attributes(format) try: - found = l.search_s(basedn, ldap.SCOPE_SUBTREE, filter, - attrlist=attrs) - except ldap.LDAPError, e: - raise LDAPError(e) - if found: - dn, entry = found[0] - entry = strip_entry(entry) - value = interpolate("ldap-resultformat", format, entry) - else: - # issue a warning? - value = config.get(section, option, default, wrap=False) - users_cache[option] = value - return value + data = {"username": option} + filter = interpolate("ldap-filterformat", filterformat, data) + attrs = used_attributes(format) + try: + found = l.search_s(basedn, ldap.SCOPE_SUBTREE, filter, + attrlist=attrs) + except ldap.LDAPError, e: + raise LDAPError(e) + if found: + dn, entry = found[0] + entry = strip_entry(entry) + value = interpolate("ldap-resultformat", format, entry) + else: + # issue a warning? + value = config.get(section, option, default, wrap=False) + users_cache[option] = value + return value + finally: + l.unbind_s() return users_wrapper |