LDAP configuration

Library Dependencies

LDAP support requires LDAP development libraries

Centos/RHEL

$sudo yum install -y openldap-devel

Ubuntu

$sudo apt-get install -y libldap2-dev

Install

$pip install python-ldap django-auth-ldap

Configure

Add the following to your local_settings.py

Note: Example only - more details can be found here

import ldap
from django_auth_ldap.config import LDAPSearch

AUTHENTICATION_BACKENDS = (
    'django_auth_ldap.backend.LDAPBackend',
    'django.contrib.auth.backends.ModelBackend',
    'guardian.backends.ObjectPermissionBackend',
)
AUTH_LDAP_SERVER_URI = 'ldap://ldap.example.com'
LDAP_SEARCH_DN = 'ou=users,dc=example,dc=com'
AUTH_LDAP_USER = '(uid=%(user)s)'
AUTH_LDAP_BIND_DN = '{ADD_BIND_DN_IF_REQUIRED}'
AUTH_LDAP_BIND_PASSWORD = '{ADD_BIND_PASSWORD_IF_REQUIRED}'
AUTH_LDAP_USER_ATTR_MAP = {
    'first_name': 'givenName', 'last_name': 'sn', 'email': 'mail',
}
AUTH_LDAP_USER_SEARCH = LDAPSearch(LDAP_SEARCH_DN,
                                   ldap.SCOPE_SUBTREE, AUTH_LDAP_USER)