fix authentification for AD backend

This commit is contained in:
kakwa 2015-07-29 00:22:25 +02:00
parent ff08e09598
commit 383c68f8b8
1 changed files with 15 additions and 0 deletions

View File

@ -177,3 +177,18 @@ class Backend(ldapcherry.backend.backendLdap.Backend):
for entry in groups:
ret.append(entry[1]['cn'][0])
return ret
def auth(self, username, password):
binddn = username + '@' + self.domain
if binddn is not None:
ldap_client = self._connect()
try:
ldap_client.simple_bind_s(binddn, password)
except ldap.INVALID_CREDENTIALS:
ldap_client.unbind_s()
return False
ldap_client.unbind_s()
return True
else:
return False