From bd030af75529f0f6344252983a9a1f434baedf6b Mon Sep 17 00:00:00 2001 From: Bogdano Arendartchuk Date: Fri, 4 May 2007 15:49:18 +0000 Subject: Unbind the ldapobject after searching. --- RepSys/plugins/ldapusers.py | 36 +++++++++++++++++++----------------- 1 file 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 -- cgit v1.2.1