Advertisement
Guest User

Untitled

a guest
Jun 5th, 2016
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.94 KB | None | 0 0
  1. # LDAP Configuration.
  2. import ldap
  3. from django_auth_ldap.config import LDAPSearch
  4.  
  5. AUTHENTICATION_BACKENDS = (
  6. 'django_auth_ldap.backend.LDAPBackend',
  7. 'django.contrib.auth.backends.ModelBackend',
  8. )
  9.  
  10. # Binding and connection options.
  11.  
  12. # Address (by IP or Hostname) of LDAP Server (Directory Active)
  13. AUTH_LDAP_SERVER_URI = "ldap://xxx.xxx.x.xxx"
  14. # DN of user through we bind to LDAP Server.
  15. AUTH_LDAP_BIND_DN = "CN=xxx, CN=xxx, DC=xxx, DC=xxx"
  16. # Password of user through we bind to LDAP Server.
  17. AUTH_LDAP_BIND_PASSWORD = "xxxxxx"
  18. # Node where we start to search users. Use to be DN (of random user) without the last one parameter.
  19. AUTH_LDAP_USER_SEARCH = LDAPSearch("CN=xxx, DC=xxx, DC=xxx", ldap.SCOPE_SUBTREE, "(samAccountName=%(user)s)")
  20.  
  21. con = ldap.initialize("ldap://ldapserver")
  22. con.simple_bind_s( userDN, passwordUser )
  23. filter = '(sAMAccountName=' + "loginName" + ')'
  24. user = con.search_s( base_dn, ldap.SCOPE_SUBTREE, filter, attrs )
  25. con.unbind()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement