I'am trying to use django-auth-ldap, without success, to authenticate a user in Django through my Active Directory.
My active directory has the following tree:
- DC=test,DC=local
- CN=Users
- CN=Administrator
- CN=test
- CN=Users
I have (in settings.py) :
AUTH_LDAP_SERVER_URI = "ldap://something.test.local"
AUTH_LDAP_BIND_DN = "cn=Administrator,cn=Users,dc=test,dc=local"
AUTH_LDAP_BIND_PASSWORD = "password"
AUTH_LDAP_USER_SEARCH = LDAPSearch("cn=Users,dc=test,dc=local",
ldap.SCOPE_SUBTREE, "(uid=%(user)s)")
and I always got (debugging in Django shell):
>>> from django.contrib.auth import authenticate, login
>>> authenticate(username='test', password='password')
search_s('cn=Users,dc=test,dc=local', 2, '(uid=%(user)s)') returned 0 objects:
Authentication failed for test: failed to map the username to a DN.