我试图在我的windows系统中安装django-auth-ldap,它显示了以下错误
\pip-build-3x6rkxb4\pyldap\modules\errors.h(8):致命错误C1083:无法打开包含文件:'lber.h':没有这样的文件或目录错误:命令'C:\Program (x86)\Microsoft 14.0\VC\BIN\x86_amd64\cl.exe‘退出状态2失败
# LDAP auth settings.
LDAP_AUTH_URL = os.environ.get("LDAP_AUTH_URL", "ldap://xxx.xx.xx.xx:389")
LDAP_AUTH_USE_TLS = False
LDAP_AUTH_SEARCH_BASE = "dc=maxcrc,dc=com"
LDAP_AUTH_OBJECT_CLASS = "inetOrgPerson"
LDAP_AUTH_USER_FIELDS = {
"username": "uid",
"first_name": "givenName",
"last_name": "sn",
"email": "mail",
}
LDAP_AUTH_USER_LOOKUP_FIELDS = ("username",)
LDAP_AUTH_CLEAN_USER_DATA = "django_python3_ldap.utils.clean_user_data"
LDAP_AUTH_SYNC_USER_RELATIONS = "django_python3_ldap.utils.sync_user_relations"
LDAP_AUTH_FORMAT_SEARCH_FILTERS = "django_python3_ldap.utils.format_search_filters"
LDAP_AUTH_FORMAT_USERNAME = "django_python3_ldap.utils.format_username_openldap"
LDAP_AUTH_ACTIVE_DIRECTORY_DOMAIN = None
LDAP_AUTH_CONNECTION_USERNAME = "cn=Manager,dc=maxcrc,dc=com"
LDAP_AUTH_CONNECTION_PASSWORD = "*****"
LDAP_AUTH_CONNECT_TIMEOUT = None
LDAP_AUTH_RECEIVE_TIMEOUT = None
AUTHENTICATION_BACKENDS = (
"django_python3_ldap.auth.LDAPBackend",
)我的版本是Python-3.6.3(64位) Django - 1.11.6 (64位) Windows 10-64位
谢谢
发布于 2017-11-01 11:52:24
由于django-auth-ldap的依赖关系,需要编译它。特别是在Windows上,我建议尝试纯Python解决方案。我使用的一个非常好的方法是django-python3-ldap,您可以在这里找到:
https://github.com/etianen/django-python3-ldap
下面是我如何设置这些设置,以便我们也可以直接使用这些值与ldap3连接:
AUTHENTICATION_BACKENDS = [
'django.contrib.auth.backends.ModelBackend',
'django_python3_ldap.auth.LDAPBackend',
]
# LDAP Connection Settings
LDAP_AUTH_HOST = 'ldap.example.com'
LDAP_AUTH_PORT = 636
LDAP_AUTH_URL = 'ldaps://{host}:{port}'.format(
host=LDAP_AUTH_HOST,
port=LDAP_AUTH_PORT,
)
LDAP_AUTH_CONNECTION_USERNAME = 'ldapuser'
LDAP_AUTH_CONNECTION_PASSWORD = 'ldappassword'
# Initiate TLS on connection.
LDAP_AUTH_USE_TLS = True
# The LDAP search base for looking up users.
LDAP_AUTH_SEARCH_BASE = "ou=People,dc=example,dc=com"
# The LDAP class that represents a user.
LDAP_AUTH_OBJECT_CLASS = "shadowAccount"
# User model fields mapped to the LDAP
# attributes that represent them.
LDAP_AUTH_USER_FIELDS = {
"username": "uid",
}
# A tuple of fields used to uniquely identify a user.
LDAP_AUTH_USER_LOOKUP_FIELDS = ("username",)README还包括有关Active Directory的说明,如果这是您要连接的内容。祝好运!
发布于 2019-02-20 10:00:08
对于那些像我一样,由于任何原因不能离开django-auth-ldap的人:我解决了从这里下载和安装python的二进制轮子的问题。
https://www.lfd.uci.edu/~gohlke/pythonlibs/#python-ldap
我希望这能帮到你
https://stackoverflow.com/questions/47048542
复制相似问题