我正在尝试针对我们的 LDAP 构建用户身份验证:
设置.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)
视图.py:
@login_required
def project_list(request):
...
网址.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 应该有所不同?