skillfed

python-ldap

Python modules for implementing LDAP clients

python-ldap v3.4.7 4.4M downloads/30d#2,307 on PyPI441
Permissive license python-ldap Active released

What it is and what it does

python-ldap is a wrapper around OpenLDAP client libraries that exposes LDAP directory operations through Python objects. It lets you connect to LDAP servers, authenticate users, search directory entries, and process LDAP-related data formats like LDIF and schema definitions. The package is built on compiled C extensions, so it depends on system-level OpenLDAP libraries being present.

The library is used primarily for authentication and directory lookups in enterprise environments. It handles the low-level protocol details and connection management, letting you focus on directory queries and user management logic. Runtime dependencies are pyasn1 and pyasn1_modules for ASN.1 encoding, but the installation itself requires C compilation and OpenLDAP headers.

Use it for:

  • Authenticate users against an LDAP server in a web application or service.
  • Search and retrieve user or group information from a directory for provisioning workflows.
  • Process LDIF files for directory data import or export.
  • Validate LDAP schema and parse LDAPv3 controls and extended operations.
  • Build directory-aware applications that need to query organizational structure or user attributes.

Worth the install?

AI-flagged interpretation of the facts on this page — verify before relying

Provides an object-oriented Python API to connect to and query LDAP directory servers, wrapping OpenLDAP client libraries and offering utilities for LDIF processing, LDAP URLs, and schema handling.

Yes, if you need LDAP directory integration and can meet the system dependency requirements. The package is stable, actively maintained, has no known vulnerabilities, and is widely used in enterprise Python applications. The main barrier is high install friction—you must have OpenLDAP development libraries available on your system. If you're working with corporate LDAP servers, this is the standard choice; if you don't need LDAP, the system dependency overhead makes it not worth installing.

Install

python-ldap on PyPI

pip

pip install python-ldap

uv

uv add python-ldap

poetry

poetry add python-ldap

Installing python-ldap

Before you install

High install friction due to compiled C extension wrapping OpenLDAP libraries; requires system-level LDAP development headers. Maintenance is active with recent releases and no known vulnerabilities.

License in practice

Licensed under a permissive Python-style license; contributions since July 2021 are under MIT. License text preservation is required but imposes minimal restrictions on use or distribution.

Quickstart

import ldap
l = ldap.initialize("ldap://my_ldap_server.my_domain")
l.simple_bind_s("", "")
l.search_s("o=My Organisation, c=AU", ldap.SCOPE_SUBTREE, "objectclass=*")

Requires OpenLDAP client libraries and development headers installed on the system; not a pure-Python package.

Verify before relying

  • Whether the package's C extension compiles cleanly on all supported platforms.
  • Performance characteristics and scalability limits for large directory queries.
  • Current state of SASL support and any known limitations with modern LDAP servers.

Package facts

License python-ldap (permissive)
Python support supports the current Python release (>=3.6)
Install friction high — source build required
Runtime dependencies 2 — pyasn1, pyasn1_modules
Maintenance actively maintained — 86 days since the last release
Last repo commit
First released
Downloads 4,423,726/month — #2,307 on PyPI (30-day window, as of 2026-08-14)
Known vulnerabilities none known (OSV.dev, checked 2026-08-14)

Evidence: python_ldap-3.4.7.tar.gz

Keywords: ldap, directory, authentication

Development Status :: 5 - Production/StableIntended Audience :: DevelopersIntended Audience :: System AdministratorsLicense :: OSI Approved :: Python Software Foundation LicenseOperating System :: MacOS :: MacOS XOperating System :: Microsoft :: WindowsOperating System :: OS IndependentOperating System :: POSIXProgramming Language :: CProgramming Language :: PythonProgramming Language :: Python :: 3Programming Language :: Python :: 3.10Programming Language :: Python :: 3.11Programming Language :: Python :: 3.12Programming Language :: Python :: 3.13Programming Language :: Python :: 3.6Programming Language :: Python :: 3.7Programming Language :: Python :: 3.8Programming Language :: Python :: 3.9Topic :: DatabaseTopic :: InternetTopic :: Software Development :: Libraries :: Python ModulesTopic :: System :: Systems Administration :: Authentication/Directory :: LDAP

Tags

ldap client library pythondirectory server authenticationldap query and binduser lookup directoryldap schema processingdirectory services apildap data interchange format
ldap-clientdirectory-servicesauthentication

More Python Modules packages