Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # LDAP Configuration.
- import ldap
- from django_auth_ldap.config import LDAPSearch
- AUTHENTICATION_BACKENDS = (
- 'django_auth_ldap.backend.LDAPBackend',
- 'django.contrib.auth.backends.ModelBackend',
- )
- # Binding and connection options.
- # Address (by IP or Hostname) of LDAP Server (Directory Active)
- AUTH_LDAP_SERVER_URI = "ldap://xxx.xxx.x.xxx"
- # DN of user through we bind to LDAP Server.
- AUTH_LDAP_BIND_DN = "CN=xxx, CN=xxx, DC=xxx, DC=xxx"
- # Password of user through we bind to LDAP Server.
- AUTH_LDAP_BIND_PASSWORD = "xxxxxx"
- # Node where we start to search users. Use to be DN (of random user) without the last one parameter.
- AUTH_LDAP_USER_SEARCH = LDAPSearch("CN=xxx, DC=xxx, DC=xxx", ldap.SCOPE_SUBTREE, "(samAccountName=%(user)s)")
- con = ldap.initialize("ldap://ldapserver")
- con.simple_bind_s( userDN, passwordUser )
- filter = '(sAMAccountName=' + "loginName" + ')'
- user = con.search_s( base_dn, ldap.SCOPE_SUBTREE, filter, attrs )
- con.unbind()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement