NBa*_*nca 1 python django ldap active-directory
我正在尝试使用django-auth-ldap来通过我的 Active Directory 对 Django 中的用户进行身份验证,但没有成功。
我的活动目录有以下树:
我有(在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)")
Run Code Online (Sandbox Code Playgroud)
我总是得到(在 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.
Run Code Online (Sandbox Code Playgroud)
哪里有:
AUTH_LDAP_USER_SEARCH = LDAPSearch("cn=Users,dc=test,dc=local",
ldap.SCOPE_SUBTREE, "(uid=%(user)s)")
Run Code Online (Sandbox Code Playgroud)
它应该是:
AUTH_LDAP_USER_SEARCH = LDAPSearch("cn=Users,dc=test,dc=local",
ldap.SCOPE_SUBTREE, "(sAMAccountName=%(user)s)")
Run Code Online (Sandbox Code Playgroud)
因为 uid 在 Active Directory 中通常为空,所以搜索不会返回假装的用户。
不,我得到:
search_s('cn=Users,dc=test,dc=local', 2, '(uid=%(user)s)') returned 1 objects: cn=test,cn=users,dc=test,dc=local
Created Django user test
Populating Django user test
<User: test>
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
4483 次 |
| 最近记录: |