skillfed

django-auth-ldap

Django LDAP authentication backend

django-auth-ldap v5.3.0 693.3K downloads/30d#5,316 on PyPI376
Permissive license BSD Active released

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-ldap

uv

uv add django-auth-ldap

poetry

poetry add django-auth-ldap

Installing 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

Development Status :: 5 - Production/StableEnvironment :: Web EnvironmentFramework :: DjangoFramework :: Django :: 4.2Framework :: Django :: 5.2Framework :: Django :: 6.0Intended Audience :: DevelopersIntended Audience :: System AdministratorsLicense :: OSI Approved :: BSD LicenseProgramming Language :: PythonProgramming Language :: Python :: 3Programming Language :: Python :: 3 :: OnlyProgramming Language :: Python :: 3.10Programming Language :: Python :: 3.11Programming Language :: Python :: 3.12Programming Language :: Python :: 3.13Programming Language :: Python :: 3.14Topic :: Internet :: WWW/HTTPTopic :: Software Development :: Libraries :: Python ModulesTopic :: System :: Systems Administration :: Authentication/Directory :: LDAP

Tags

django ldap authenticationldap backend djangoactive directory django authldap user authenticationdjango directory servicesldap group permissions djangoenterprise directory integration
ldap-authenticationenterprise-identitydirectory-services

More Python Modules packages