【发布时间】:2016-05-04 16:19:04
【问题描述】:
我正在尝试使用 django-auth-ldap 通过我的 Active Directory 对 Django 中的用户进行身份验证,但没有成功。
我的活动目录有以下树:
- DC=测试,DC=本地
- CN=用户
- CN=管理员
- CN=测试
- CN=用户
我有(在 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)")
我总是得到(在 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.
【问题讨论】:
标签: python django active-directory ldap