首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >django_auth_ldap募集OPERATIONS_ERROR

django_auth_ldap募集OPERATIONS_ERROR
EN

Stack Overflow用户
提问于 2012-02-13 22:03:53
回答 4查看 4.1K关注 0票数 1

我正在尝试根据我们的LDAP构建用户身份验证:

settings.py:

代码语言:javascript
复制
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:

代码语言:javascript
复制
@login_required
def project_list(request):
...

urls.py:

代码语言:javascript
复制
(r'^accounts/login/$', 'django.contrib.auth.views.login',{'template_name':'login.html'}),

模板是from this example

它将把我带到auth表单,并得到以下调试输出:

代码语言:javascript
复制
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应该有所不同?

EN

回答 4

Stack Overflow用户

回答已采纳

发布于 2012-02-17 03:31:43

尽管ldap_simple_bind_s()会返回一个成功的绑定,但我必须禁用引用选项才能使其正常工作:

代码语言:javascript
复制
ldap.set_option(ldap.OPT_REFERRALS, 0)
票数 3
EN

Stack Overflow用户

发布于 2012-02-14 08:54:29

您需要绑定到服务器,即使是匿名绑定。

因此,您必须具有

代码语言:javascript
复制
AUTH_LDAP_BIND_DN = ""
AUTH_LDAP_BIND_PASSWORD = ""
票数 1
EN

Stack Overflow用户

发布于 2015-04-21 18:04:43

我不知道我是否可以在这篇文章中问另一个问题。在views.py中,我有类似这样的东西:

默认登录(请求):

C= {} c.update(csrf(request)) return render_to_response('login.html',c)

def auth_view(请求):

username = request.POST.get('username','') password = request.POST.get('password','') user = auth.authenticate(username=username,password=password)

如果user不是None: auth.login(request,user) return HttpResponseRedirect('/loggedin') else: return HttpResponseRedirect('/invalid')

我的问题是如何将其与ldap服务器绑定?在django文档中有用于日志记录的模板:

导入日志记录

logger = logging.getLogger('django_auth_ldap') logger.addHandler(logging.StreamHandler()) logger.setLevel(logging.DEBUG)

但我不知道如何在rhis代码中实现它

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/9261848

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档