From 16c757bdd46ba20c5b86899e668426c7d385ce0d Mon Sep 17 00:00:00 2001 From: kakwa Date: Mon, 25 May 2015 22:17:17 +0200 Subject: [PATCH] factoring binding to the ldap --- ldapcherry/backend/backendLdap.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/ldapcherry/backend/backendLdap.py b/ldapcherry/backend/backendLdap.py index b9a8579..5c17f92 100644 --- a/ldapcherry/backend/backendLdap.py +++ b/ldapcherry/backend/backendLdap.py @@ -66,7 +66,7 @@ class Backend(ldapcherry.backend.Backend): def del_user(self, username): pass - def _search(self, searchfilter, attrs): + def _bind(self): ldap_client = self._connect() try: ldap_client.simple_bind_s(self.binddn, self.bindpassword) @@ -84,7 +84,11 @@ class Backend(ldapcherry.backend.Backend): ) ldap_client.unbind_s() raise e + return ldap_client + + def _search(self, searchfilter, attrs): + ldap_client = self._bind() try: r = ldap_client.search_s(self.userdn, ldap.SCOPE_SUBTREE,