diff options
author | Jan Cholasta <jcholast@redhat.com> | 2014-11-21 20:03:29 +0100 |
---|---|---|
committer | Jan Cholasta <jcholast@redhat.com> | 2015-04-16 06:58:31 +0000 |
commit | 8f263df2456c6c2ba4463c690bb69b3650356493 (patch) | |
tree | 04282782f429a480aa1bd740d659fc990495ffad | |
parent | 45d9b82f404128926102750e28503de2b768cf9d (diff) | |
download | freeipa-8f263df2456c6c2ba4463c690bb69b3650356493.tar.gz freeipa-8f263df2456c6c2ba4463c690bb69b3650356493.tar.xz freeipa-8f263df2456c6c2ba4463c690bb69b3650356493.zip |
ldap: Use LDAPClient connection management in ldap2
Reviewed-By: Petr Viktorin <pviktori@redhat.com>
-rw-r--r-- | ipaserver/plugins/ldap2.py | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/ipaserver/plugins/ldap2.py b/ipaserver/plugins/ldap2.py index 267157146..98b038ab9 100644 --- a/ipaserver/plugins/ldap2.py +++ b/ipaserver/plugins/ldap2.py @@ -145,10 +145,12 @@ class ldap2(LDAPClient, CrudBackend): if debug_level: _ldap.set_option(_ldap.OPT_DEBUG_LEVEL, debug_level) + object.__setattr__(self, '_force_schema_updates', + self.api.env.context in ('installer', 'updates')) + LDAPClient._connect(self) + conn = self._conn + with self.error_handler(): - force_updates = self.api.env.context in ('installer', 'updates') - conn = IPASimpleLDAPObject( - self.ldap_uri, force_schema_updates=force_updates) if self.ldap_uri.startswith('ldapi://') and ccache: conn.set_option(_ldap.OPT_HOST_NAME, self.api.env.host) minssf = conn.get_option(_ldap.OPT_X_SASL_SSF_MIN) @@ -200,6 +202,11 @@ class ldap2(LDAPClient, CrudBackend): # ignore when trying to unbind multiple times pass + try: + LDAPClient._disconnect(self) + except errors.PublicError: + # ignore when trying to unbind multiple times + pass def find_entries(self, filter=None, attrs_list=None, base_dn=None, scope=_ldap.SCOPE_SUBTREE, time_limit=None, |