settings_ldap.py
1 import os 2 import ldap 3 from django_auth_ldap.config import LDAPSearch, GroupOfNamesType 4 5 6 # Baseline configuration. 7 AUTH_LDAP_SERVER_URI = os.environ.get('AUTH_LDAP_SERVER_URI', 'ldap://ldap.example.com') 8 9 AUTH_LDAP_BIND_DN = os.environ.get('AUTH_LDAP_BIND_DN', 'cn=Manager,dc=example,dc=com') 10 AUTH_LDAP_BIND_PASSWORD = os.environ.get('AUTH_LDAP_BIND_PASSWORD', '') 11 AUTH_LDAP_USER_FILTER = os.environ.get('AUTH_LDAP_USER_FILTER', '(uid=%(user)s)') 12 AUTH_LDAP_USER_SEARCH = LDAPSearch(os.environ.get('AUTH_LDAP_USER_SEARCH', 'ou=user,dc=example,dc=com'), 13 ldap.SCOPE_SUBTREE, AUTH_LDAP_USER_FILTER) 14 15 # Populate the Django user from the LDAP directory. 16 AUTH_LDAP_USER_ATTR_MAP = { 17 'first_name': 'givenName', 18 'last_name': 'sn', 19 'email': 'mail', 20 }