我已经使用python应用程序成功地configuration了LDAP,使用db/model.py这些语句:
from gluon.contrib.login_methods.ldap_auth import ldap_auth auth.settings.login_methods = [ldap_auth(mode='ad', server='ldap.example.com', base_dn='dc=example,dc=com')]
我正在尝试与Django相同,但是我在网上看到的所有说明都相当复杂。
什么Django相当于我的web2py LDAP设置?
有没有简单的方法来debugging到Django服务器控制台的LDAP连接过程?
这是我所尝试的:
import ldap from django_auth_ldap.config import LDAPSearch, GroupOfNamesType # LDAP Configuration AUTH_LDAP_SERVER_URI = "ldap://ldap.example.com" AUTH_LDAP_BIND_DN = "" AUTH_LDAP_BIND_PASSWORD = "" AUTH_LDAP_USER_DN_TEMPLATE = "uid=%(user)s,ou=users,dc=example,dc=com" # group names: #AUTH_LDAP_GROUP_SEARCH = LDAPSearch("ou=groups,dc=example,dc=com", # ldap.SCOPE_SUBTREE, "(objectClass=groupOfNames)" # ) #AUTH_LDAP_GROUP_TYPE = GroupOfNamesType() #AUTH_LDAP_FIND_GROUP_PERMS = True #AUTH_LDAP_CACHE_GROUPS = True #AUTH_LDAP_GROUP_CACHE_TIMEOUT = 300 AUTH_LDAP_USER_ATTR_MAP = {"first_name": "givenName", "last_name": "sn", "email": "mail"} AUTH_LDAP_PROFILE_ATTR_MAP = {"home_directory": "homeDirectory"} AUTH_LDAP_USER_FLAGS_BY_GROUP = { "is_active": "cn=active,ou=groups,dc=example,dc=com", "is_staff": "cn=staff,ou=groups,dc=example,dc=com", "is_superuser": "cn=superuser,ou=groups,dc=example,dc=com", } AUTHENTICATION_BACKENDS = ( 'django_auth_ldap.backend.LDAPBackend', 'django.contrib.auth.backends.ModelBackend', )
这是我目前看到的,当我尝试validation:
前一阵子在debugging石墨ldap安装
ldap.set_option(ldap.OPT_DEBUG_LEVEL,65535)
我从石墨文档中获得( http://graphite.readthedocs.io/en/latest/config-local-settings.html )。
它可能会告诉你更多关于你的应用程序正在发生的事情。