安装python-ldap django-auth-ldap
xxxxxxxxxxpip install python-ldap django-auth-ldap
错误
xxxxxxxxxx #include "lber.h" ^ compilation terminated. error: command 'gcc' failed with exit status 1
缺少那个组件安装哪个组件
xxxxxxxxxxyum install openldap-devel修改django settings
x
import ldapfrom django_auth_ldap.config import LDAPSearch
AUTHENTICATION_BACKENDS = ( 'django_auth_ldap.backend.LDAPBackend', #配置为先使用LDAP认证,如通过认证则不再使用后面的认证方式 'django.contrib.auth.backends.ModelBackend',)AUTH_LDAP_SERVER_URI = "ldap://10.10.10.10" # ldap服务器地址AUTH_LDAP_BIND_DN = 'cn=root,dc=abc,dc=com' AUTH_LDAP_BIND_PASSWORD = '*****'AUTH_LDAP_USER_SEARCH = LDAPSearch("ou=Group,dc=abc,dc=me", ldap.SCOPE_SUBTREE, "(cn=%(user)s)")AUTH_LDAP_USER_ATTR_MAP = {"first_name": "givenName", "last_name": "sn", "username": "uid","email": "mail"}AUTH_LDAP_ALWAYS_UPDATE_USER = True
#AUTH_LDAP_MIRROR_GROUPS = True #导入用户的组信息
```
评论
发表评论