Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/305.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python Django LDAP身份验证失败:服务器\u关闭_Python_Django_Authentication_Active Directory_Django Auth Ldap - Fatal编程技术网

Python Django LDAP身份验证失败:服务器\u关闭

Python Django LDAP身份验证失败:服务器\u关闭,python,django,authentication,active-directory,django-auth-ldap,Python,Django,Authentication,Active Directory,Django Auth Ldap,我正在使用django auth ldap进行身份验证 我有以下错误: 在对xxx:SERVER\u进行身份验证时捕获到LDAPError({'info':'(未知错误代码)'desc':“无法联系LDAP服务器”},) 使用: AUTH_LDAP_CONNECTION_OPTIONS={LDAP.OPT_X_TLS_REQUIRE_CERT:LDAP.OPT_X_TLS_NEVER} 在setting.py中应该可以解决问题,但它不能 我到处玩过,看起来在创建连接之前必须设置此选项。djang

我正在使用
django auth ldap
进行身份验证

我有以下错误:

在对xxx:SERVER\u进行身份验证时捕获到LDAPError({'info':'(未知错误代码)'desc':“无法联系LDAP服务器”},)

使用:
AUTH_LDAP_CONNECTION_OPTIONS={LDAP.OPT_X_TLS_REQUIRE_CERT:LDAP.OPT_X_TLS_NEVER}

setting.py中
应该可以解决问题,但它不能

我到处玩过,看起来在创建连接之前必须设置此选项。
django\u auth\u ldap/backend.py
在设置连接后设置选项:

self._connection = self.ldap.initialize(self.settings.SERVER_URI)
for opt, value in self.settings.CONNECTION_OPTIONS.iteritems():
    self._connection.set_option(opt, value)
只有提前设置了ldap.OPT_X_TLS_REQUIRE_CERT时,使用django shell我才能成功:

from django_auth_ldap.backend import LDAPBackend
ldapobj = LDAPBackend()
user = ldapobj.populate_user(username)
# ERROR:
# [12/Jun/2015 14:15:19] WARNING [django_auth_ldap:396] Caught LDAPError while authenticating xxx: SERVER_DOWN({'info': '(unknown error code)', 'desc': "Can't contact LDAP server"},)
if user is None:
    print "1st try failed!"
    ldapobj.ldap.set_option(ldapobj.ldap.OPT_X_TLS_REQUIRE_CERT, ldapobj.ldap.OPT_X_TLS_NEVER)
    user = ldapobj.populate_user(username)
    print user.is_anonymous()
输出:

 # 1st try failed!
 # False

知道我要做什么吗(不修改
django auth ldap
代码)?

听起来像是你想要的。

链接只能用死链接回答。仅供将来参考,这是新链接。