我在Windows服务器2008 R2上使用Active目录。我有一个运行Django和python 2.7的应用程序。现在我需要使用Active Directory身份验证来访问我的应用程序。
要做到这一点,我正在使用这个包:
sudo apt-get-update
sudo apt-get install python-dev libldap2-dev libsasl2-dev libssl-dev
sudo pip install django-auth-ldap
sudo pip install python-ldap
我使用全名来成功绑定。
import ldap
from django.conf import settings
username='my full name in AD'
password= 'my password'
l = ldap.initialize(settings.AUTH_LDAP_SERVER_URI)
l.simple_bind_s(username,password)
我的问题是当我尝试使用我的cn属性进行绑定时,我收到了这个错误:
Traceback (most recent call last):
File "<console>", line 1, in <module>
File "/usr/lib/python2.7/dist-packages/ldap/ldapobject.py", line 207, in
simple_bind_s
return self.result(msgid,all=1,timeout=self.timeout)
File "/usr/lib/python2.7/dist-packages/ldap/ldapobject.py", line 422, in
result res_type,res_data,res_msgid = self.result2(msgid,all,timeout)
File "/usr/lib/python2.7/dist-packages/ldap/ldapobject.py", line 426, in
result2 res_type, res_data, res_msgid, srv_ctrls =
self.result3(msgid,all,timeout)
File "/usr/lib/python2.7/dist-packages/ldap/ldapobject.py", line 432, in
result3 ldap_result = self._ldap_call(self._l.result3,msgid,all,timeout)
File "/usr/lib/python2.7/dist-packages/ldap/ldapobject.py", line 96, in
_ldap_call result = func(*args,**kwargs)
INVALID_CREDENTIALS: {'info': '80090308: LdapErr: DSID-0C0903A9, comment:
AcceptSecurityContext error, data 52e, v1db1', 'desc': 'Invalid
credentials'}
我可以使用我的cn(通用名称)属性对Active Directory进行身份验证吗?
感谢。
答案 0 :(得分:1)
您不能在simple_bind()中使用cn值。请改为使用备用用户主体名称sAMAccountName@FQDN
,或使用其他supported bind names之一。
答案 1 :(得分:0)