【发布时间】:2012-02-13 14:03:52
【问题描述】:
我正在尝试针对我们的 LDAP 构建用户身份验证:
settings.py:
AUTHENTICATION_BACKENDS = (
'django_auth_ldap.backend.LDAPBackend',
'django.contrib.auth.backends.ModelBackend',
)
AUTH_LDAP_SERVER_URI = "ldap://********-dc01.*******.ru"
import ldap
from django_auth_ldap.config import LDAPSearch
AUTH_LDAP_BIND_DN = ""
AUTH_LDAP_BIND_PASSWORD = ""
AUTH_LDAP_USER_SEARCH = LDAPSearch("cn=users,dc=*********,dc=ru",ldap.SCOPE_SUBTREE,"(uid=%(user)s)")
AUTH_LDAP_USER_ATTR_MAP = {
"first_name": "givenName",
"last_name": "sn",
"email": "mail"
}
import logging
logger = logging.getLogger('django_auth_ldap')
logger.addHandler(logging.StreamHandler())
logger.setLevel(logging.DEBUG)
views.py:
@login_required
def project_list(request):
...
urls.py:
(r'^accounts/login/$', 'django.contrib.auth.views.login',{'template_name':'login.html'}),
它会带我去验证表单,我会得到以下调试输出:
search_s('cn=users,dc=********,dc=ru', 2, '(uid=bolotnov)') raised OPERATIONS_ERROR({'info': '000004DC: LdapErr: DSID-0C0906DC, comment: In order to perform this operation a successful bind must be completed on the connection., data 0, v1db0', 'desc': 'Operations error'},)
search_s('cn=users,dc=**********,dc=ru', 2, '(uid=bolotnov)') raised OPERATIONS_ERROR({'info': '000004DC: LdapErr: DSID-0C0906DC, comment: In order to perform this operation a successful bind must be completed on the connection., data 0, v1db0', 'desc': 'Operations error'},)
Authentication failed for bolotnov
Authentication failed for bolotnov
我尝试使用谷歌搜索,但没有找到任何可以帮助我进一步提高的东西,也许是来自社区的提示 - 也许我缺少一些简单的东西或者需要检查一下?我似乎可以通过 Softerra LDAP 浏览器匿名绑定到我们的 ldap,也许 ldap_auth_user_search 应该有些不同?
【问题讨论】:
-
我想我知道问题出在哪里,但还无法验证。它将尝试使用用户在登录/密码字段中提供的相同凭据绑定到 LDAP 服务器以获得用户的首选项。发生的情况是 - 用户很高兴地找到/验证了登录/密码令牌但绑定到 LDAP,服务器也期望提供域名 - 这就是导致问题的原因。
标签: django ldap django-authentication python-ldap