mirror of
https://github.com/kakwa/ldapcherry
synced 2024-11-22 09:24:21 +01:00
factoring binding to the ldap
This commit is contained in:
parent
4d29706eaf
commit
16c757bdd4
@ -66,7 +66,7 @@ class Backend(ldapcherry.backend.Backend):
|
|||||||
def del_user(self, username):
|
def del_user(self, username):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def _search(self, searchfilter, attrs):
|
def _bind(self):
|
||||||
ldap_client = self._connect()
|
ldap_client = self._connect()
|
||||||
try:
|
try:
|
||||||
ldap_client.simple_bind_s(self.binddn, self.bindpassword)
|
ldap_client.simple_bind_s(self.binddn, self.bindpassword)
|
||||||
@ -84,7 +84,11 @@ class Backend(ldapcherry.backend.Backend):
|
|||||||
)
|
)
|
||||||
ldap_client.unbind_s()
|
ldap_client.unbind_s()
|
||||||
raise e
|
raise e
|
||||||
|
return ldap_client
|
||||||
|
|
||||||
|
|
||||||
|
def _search(self, searchfilter, attrs):
|
||||||
|
ldap_client = self._bind()
|
||||||
try:
|
try:
|
||||||
r = ldap_client.search_s(self.userdn,
|
r = ldap_client.search_s(self.userdn,
|
||||||
ldap.SCOPE_SUBTREE,
|
ldap.SCOPE_SUBTREE,
|
||||||
|
Loading…
Reference in New Issue
Block a user