ldapsearch, django-ldap-auth and "data 52e, v1db1"



>我正在尝试让 django-auth-ldap 工作,但我不断收到无效凭据 (49) 错误,尽管有正确的凭据:

additional info: 80090308: LdapErr: DSID-0C0903A9, comment: AcceptSecurityContext error, data 52e, v1db1

在 Ubuntu 12.04.3 上使用 python-ldap (2.4.13) 和 django-auth-ldap (1.1.4) 对抗 Windows Server 2008 R2。我按照这里的安装说明进行操作:http://pythonhosted.org/django-auth-ldap/install.html 和这里:http://www.djm.org.uk/using-django-auth-ldap-active-directory-ldaps

第二个链接建议使用以下方法测试连接:

ldapsearch -H ldaps://ldap-x.companygroup.local:636 -D "CN=Something LDAP,OU=Random Group,DC=companygroup,DC=local" -w "p4ssw0rd" -v -d 1

在本地,这将是:

ldapsearch -H ldap://192.168.0.3 -D "cn=testadmin,dc=fds,dc=local" -w "password" -v -d 1

这对我不起作用,但以下内容确实

ldapsearch -H ldap://192.168.0.3 -D "dc=fds,dc=local" -U "testadmin" -w "password" -v -d 1

所以我很高兴。在将用户移动到 -U 标志之前,我也尝试了以下方法,但没有成功:

ldapsearch -H ldap://192.168.0.3 -D "cn=testadmin,ou=Users,dc=fds,dc=local" -w "password" -v -d 1
ldapsearch -H ldap://192.168.0.3 -D "uid=testadmin,dc=fds,dc=local" -w "password" -v -d 1
ldapsearch -H ldap://192.168.0.3 -D "uid=testadmin,ou=Users,dc=fds,dc=local" -w "password" -v -d 1

我的 django-auth-ldap 设置是:

import ldap
from django_auth_ldap.config import LDAPSearch
AUTHENTICATION_BACKENDS = (
    'django_auth_ldap.backend.LDAPBackend',
    'django.contrib.auth.backends.ModelBackend',
)
AUTH_LDAP_SERVER_URI = 'ldap://192.168.0.3'
AUTH_LDAP_BIND_DN = 'uid=testadmin,ou=Users,dc=fds,dc=local'
AUTH_LDAP_BIND_PASSWORD = 'password'
AUTH_LDAP_USER_SEARCH = LDAPSearch("ou=Users,dc=fds,dc=local",
    ldap.SCOPE_SUBTREE, "(uid=%(user))")
AUTH_LDAP_CONNECTION_OPTIONS = {
        ldap.OPT_DEBUG_LEVEL: 0,
        ldap.OPT_REFERRALS: 0,
}

这不起作用,错误与上述相同。如您所见,我尝试使用三种形式登录:testadmin,[domain]\testadmin和testadmin@[domain].local,每种形式都有相同的错误。

Development server is running at http://0.0.0.0:8000/
Quit the server with CONTROL-C.
Caught LDAPError while authenticating testadmin: INVALID_CREDENTIALS({'info': '80090308: LdapErr: DSID-0C0903A9, comment: AcceptSecurityContext error, data 52e, v1db1', 'desc': 'Invalid credentials'},)
[06/Sep/2013 08:51:38] "POST /admin/ HTTP/1.1" 200 2027
Caught LDAPError while authenticating testadmin@fds.local: INVALID_CREDENTIALS({'info': '80090308: LdapErr: DSID-0C0903A9, comment: AcceptSecurityContext error, data 52e, v1db1', 'desc': 'Invalid credentials'},)
[06/Sep/2013 08:53:40] "POST /admin/ HTTP/1.1" 200 2037
Caught LDAPError while authenticating fdstestadmin: INVALID_CREDENTIALS({'info': '80090308: LdapErr: DSID-0C0903A9, comment: AcceptSecurityContext error, data 52e, v1db1', 'desc': 'Invalid credentials'},)
[06/Sep/2013 08:53:50] "POST /admin/ HTTP/1.1" 200 2031

我已经尝试对各种组合中的设置进行一些更改,包括:

AUTH_LDAP_BIND_DN = 'uid=testadmin,ou=Domain Users,ou=Users,dc=fds,dc=local'
AUTH_LDAP_BIND_DN = 'cn=testadmin,ou=Users,dc=fds,dc=local'
AUTH_LDAP_BIND_DN = 'cn=testadmin,ou=Users,dc=fds,dc=local'
AUTH_LDAP_BIND_DN = 'uid=testadmin,dc=fds,dc=local'
AUTH_LDAP_BIND_DN = 'cn=testadmin,dc=fds,dc=local'
AUTH_LDAP_USER_SEARCH = LDAPSearch("ou=Domain Users,ou=Users,dc=fds,dc=local",
    ldap.SCOPE_SUBTREE, "(uid=%(user))")
AUTH_LDAP_USER_SEARCH = LDAPSearch("ou=FDS Users,dc=fds,dc=local",
    ldap.SCOPE_SUBTREE, "(uid=%(user))")
AUTH_LDAP_USER_SEARCH = LDAPSearch("ou=IT Users,ou=FDS Users,dc=fds,dc=local",
    ldap.SCOPE_SUBTREE, "(uid=%(user))")

我不完全了解 AD 或 LDAP,但我正在从我在网上找到的示例中工作 - 这些 ou 中的每一个都是我域中包含用户的现有 ou 或其他包含用户的 ou。

在我看来,问题与设置有关

AUTH_LDAP_BIND_DN = 'uid=testadmin,ou=Users,dc=fds,dc=local'
AUTH_LDAP_BIND_PASSWORD = 'password'

AUTH_LDAP_USER_SEARCH = LDAPSearch("ou=Users,dc=fds,dc=local",
    ldap.SCOPE_SUBTREE, "(uid=%(user))")

但我不确定 - 并且不知道下一步该怎么做来解决这个问题。有什么想法吗?

原来我在错误的地方寻找错误。这是一个绑定错误,而不是用户身份验证错误。 请注意,错误是AUTH_LDAP_BIND_DN还是AUTH_LDAP_USER_SEARCH存在混淆。

解决方案是

AUTH_LDAP_BIND_DN = 'cn=testadmin,ou=FDS Users,dc=fds,dc=local'

AUTH_LDAP_BIND_DN需要引用可分辨名称,即,它需要指向用户所在的确切位置 - 与其说是"搜索组或OU",不如说是"这是链接"。

以上有效。

最新更新