django-auth-ldap
Django LDAP authentication backend
What it is and what it does
django-auth-ldap is a Django authentication backend that delegates user authentication to an LDAP directory service such as Active Directory or OpenLDAP. Instead of storing passwords in Django's database, it validates credentials against your organization's directory, allowing centralized identity management. The package handles user lookup via LDAP search or distinguished name templates, maps LDAP attributes to Django user fields, and can derive group membership and permissions directly from LDAP groups.
The backend integrates into Django's authentication system by registering as a custom backend in AUTHENTICATION_BACKENDS. It supports rich configuration for user discovery, group restrictions, attribute mapping, and permission calculation. You can use it alongside Django's built-in ModelBackend to combine LDAP authentication with local permissions, or run it exclusively with LDAP-sourced groups. The package caches LDAP queries to reduce directory traffic and works with custom user models.
Use it for:
- Authenticate Django users against an Active Directory or OpenLDAP directory in an enterprise environment.
- Map LDAP group membership to Django user flags (is_staff, is_superuser) and permissions without local database management.
- Populate Django user profiles (name, email) automatically from LDAP attributes on first login.
- Restrict Django application access to specific LDAP groups while allowing others to be denied.
- Migrate from local password storage to centralized directory authentication in an existing Django project.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Provides a Django authentication backend that validates user credentials against an LDAP directory service, supporting user search, group membership, and permission mapping.
Yes, if you need LDAP authentication in Django. The package is actively maintained, has no known vulnerabilities, low install friction (aside from system OpenLDAP libraries), and is widely used in enterprise environments. The BSD license is permissive. Install only if your deployment uses LDAP or Active Directory; it adds no value for applications with local-only authentication.
Install
django-auth-ldap on PyPI
pip
pip install django-auth-ldapuv
uv add django-auth-ldappoetry
poetry add django-auth-ldapInstalling django-auth-ldap
Before you install
Low friction installation with a pure-Python wheel. Actively maintained with recent commits and no known vulnerabilities. Requires OpenLDAP libraries and headers on the system, and python-ldap >= 3.1 as a runtime dependency.
License in practice
BSD 2-Clause license is permissive and imposes minimal restrictions on use, modification, and distribution in both open-source and proprietary projects.
Quickstart
pip install django-auth-ldap
# In Django settings.py:
from django_auth_ldap.config import LDAPSearch
import ldap
AUTH_LDAP_SERVER_URI = 'ldap://ldap.example.com'
AUTH_LDAP_USER_SEARCH = LDAPSearch(
'ou=users,dc=example,dc=com',
ldap.SCOPE_SUBTREE,
'(uid=%(user)s)',
)
AUTHENTICATION_BACKENDS = [
'django_auth_ldap.backend.LDAPBackend',
]
Requires OpenLDAP libraries and headers available on your system; python-ldap >= 3.1 must be installed.
Verify before relying
- Whether the package supports LDAP over SSL/TLS by default or requires additional configuration.
- Performance characteristics when syncing large numbers of users or groups from LDAP.
- Whether custom user model support includes all edge cases or has known limitations.
Package facts
| License | BSD (permissive) |
| Python support | supports the current Python release (>=3.10) |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | 2 — Django, python-ldap |
| Maintenance | actively maintained — 231 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 693,255/month — #5,316 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: django_auth_ldap-5.3.0-py3-none-any.whl
Tags
More Python Modules packages
Converts domain names between Unicode and…
permissive · top 100 on PyPI
setuptoolsSetuptools is a Python build backend and…
permissive · top 100 on PyPI
PyYAMLPyYAML parses and emits YAML 1.1 data format,…
permissive · top 100 on PyPI
pydanticPydantic validates Python data structures…
permissive · top 100 on PyPI
annotated-typesProvides reusable metadata objects for use with…
permissive · top 100 on PyPI
typing-inspectionProvides runtime tools to inspect and…
permissive · top 100 on PyPI
python-ldapProvides an object-oriented Python API to…
permissive · top 5,000 on PyPI
ldaptorLdaptor is a pure-Python LDAP client library…
permissive · top 5,000 on PyPI
django-authlibProvides passwordless authentication for Django…
permissive · top 15,000 on PyPI
bloodhoundBloodHound.py is a Python ingestor that…
permissive · top 15,000 on PyPI
python3-ldapThis package is a redirect to ldap3—a pure…
copyleft · top 15,000 on PyPI
ldapdomaindumpCollects and exports Active Directory…
permissive · top 15,000 on PyPI
django-sesamedjango-sesame provides token-based…
permissive · top 15,000 on PyPI
python-active-directoryAn Active Directory client library for Python…
permissive · top 15,000 on PyPI
msldapmsldap is a Python library for querying and…
permissive · top 15,000 on PyPI
authAn HTTP authorization service that answers…
permissive · top 15,000 on PyPI