Install: $ pip install django-auth-ldap Then in settings.py, add: import ldap from django_auth_ldap.config import LDAPSearch AUTHENTICATION_BACKENDS = ( 'django.contrib.auth.backends.ModelBackend', 'django_auth_ldap.backend.LDAPBackend', ) AUTH_LDAP_SERVER_URI = "ldap://my.appauth.com" # ip or host name of Open Directory server AUTH_LDAP_BIND_DN = "CN=Accounts,OU=US Security,DC=corp,DC=com" AUTH_LDAP_BIND_PASSWORD = "MySecurePassword" AUTH_LDAP_USER_SEARCH = LDAPSearch("OU=US Users,dc=corp,dc=com", ldap.SCOPE_SUBTREE, "(sAMAccountName=%(user)s)") AUTH_LDAP_CONNECTION_OPTIONS = { # make search fast ldap.OPT_REFERRALS: 0 } AUTH_LDAP_USER_ATTR_MAP = { "username": "sAMAccountName", "first_name": "givenName", "last_name": "sn", "email": "mail" }The mapping above would result into automatically saving the information to the users table.
10.25.2016
Django LDAP Integration
These posts helped me:
http://kacperdziubek.pl/python/django-ldap-open-directory-integration/
https://pythonhosted.org/django-auth-ldap/
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment