Python / Django LDAP身份验证失败,需求无效

时间:2017-07-29 11:06:58

标签: python django ldap

我在使用python / django编写的ralph3应用程序中实现ldap时遇到问题。我安装了所有的先决条件并成功连接到ldap服务器

ldapsearch -H ldap://10.202.206.30 -b dc=bod,dc=local -x

但是当我尝试按照this official tutorial中的步骤创建prod_ldap.txt(模板)时:

import ldap
from django_auth_ldap.config import LDAPSearch, GroupOfNamesType
AUTH_LDAP_SERVER_URI = "ldap://activedirectory.domain:389"
AUTH_LDAP_BIND_DN = "secret"
AUTH_LDAP_BIND_PASSWORD = "secret"
AUTH_LDAP_PROTOCOL_VERSION = 3
AUTH_LDAP_USER_USERNAME_ATTR = "sAMAccountName"
AUTH_LDAP_USER_SEARCH_BASE = "DC=allegrogroup,DC=internal"
AUTH_LDAP_USER_SEARCH_FILTER = '(&(objectClass=*)({0}=%(user)s))'.format(
AUTH_LDAP_USER_USERNAME_ATTR)
AUTH_LDAP_USER_SEARCH = LDAPSearch(AUTH_LDAP_USER_SEARCH_BASE,
ldap.SCOPE_SUBTREE, AUTH_LDAP_USER_SEARCH_FILTER)
AUTH_LDAP_USER_ATTR_MAP = {
"first_name": "givenName",
"last_name": "sn",
"email": "mail",
"company": "company",
"manager": "manager",
"department": "department",
"employee_id": "employeeID",
"location": "officeName",
"country": "ISO-country-code",
}

并尝试使用pip安装它:

root@ubuntur:/home/marcel/ralph3# pip install -r requirements/prod_ldap.txt:

我收到此错误:

Invalid requirement: 'import ldap'
Traceback (most recent call last):
File "/usr/local/lib/python2.7/dist-packages/pip/req/req_install.py", line 
82, in __init__
req = Requirement(req)
File "/usr/local/lib/python2.7/dist-
packages/pip/_vendor/packaging/requirements.py", line 96, in __init__
requirement_string[e.loc:e.loc + 8]))
InvalidRequirement: Invalid requirement, parse error at "u'ldap'"

我还试图删除prod_ldap.txt中除了这两行之外的所有行:

import ldap
from django_auth_ldap.config import LDAPSearch, GroupOfNamesType

并且错误是一样的,所以我认为问题在于导入ldap而不是设置。

OS是应用程序创建者要求的Ubuntu 14.04 64。

谢谢。

0 个答案:

没有答案