Skip to main content
Codecov Read the Docs GitHub Actions PyPI Black

anyldap is a pure-Python, AnyIO-based library for Python 3.10 and newer that implements:

  • LDAP client and server logic

  • a client with python-ldap’s API, awaited rather than blocking

  • separately-accessible LDAP and BER protocol message generation/parsing

  • ASCII-format LDAP filter generation and parsing

  • LDIF format data generation

  • Samba password changing logic

Also included is a set of LDAP utilities for use from the command line.

The full documentation is available on Read the Docs.

Quick Usage Example

import anyio

from anyldap.protocols.ldap import ldapclient, ldapconnector, ldapsyntax


async def example():
    serverip = "192.168.128.21"
    basedn = b"dc=example,dc=com"
    binddn = b"bjensen@example.com"
    bindpw = b"secret"
    query = b"(cn=Babs*)"
    overrides = {basedn: (serverip, 389)}
    connection = await ldapconnector.connectToLDAPDNAsync(
        basedn,
        ldapclient.LDAPClient,
        overrides=overrides,
    )
    async with connection as client:
        await client.bind_async(binddn, bindpw)
        entry = ldapsyntax.LDAPEntry(client, basedn)
        results = await entry.search_async(filterText=query)
        for result in results:
            print(result.getLDIF())


if __name__ == "__main__":
    anyio.run(example)

python-ldap’s API but async

anyldap.ldap is python-ldap’s ldap module made async: the names, the arguments they take and the values they hand back are python-ldap’s, with every operation a coroutine, so code written against it ports by adding await. It runs on asyncio and on trio, since it is written against AnyIO, and none of it is a binding to OpenLDAP’s C library – the protocol, the SASL mechanisms and the TLS handshake are anyldap’s own, which is also why the handful of things only libldap can answer are not here:

import anyio

from anyldap import ldap


async def example():
    async with ldap.initialize("ldap://ldap.example.com") as connection:
        await connection.simple_bind_s("bjensen@example.com", b"secret")
        results = await connection.search_s(
            "dc=example,dc=com", ldap.SCOPE_SUBTREE, "(cn=Babs*)"
        )
        for dn, attributes in results:
            print(dn, attributes)


if __name__ == "__main__":
    anyio.run(example)

ldap.controls, ldap.schema, ldap.sasl, ldap.dn, ldap.filter, ldap.modlist, ldap.cidict, ldap.ldapurl, ldap.ldif, ldap.asyncsearch, ldap.syncrepl and ReconnectLDAPObject are here too. What it does and does not cover is in the documentation. Most of python-ldap’s own test suite is ported under interop/, next to tests that run the same operations through both libraries against one OpenLDAP server and compare the answers; tox -e interop runs them.

Installation

Install anyldap from PyPI:

python -m pip install anyldap

To install a repository checkout in editable mode:

python -m pip install -e .

For a server example from a repo checkout, see docs/source/examples/quickstart_server.py.

Dependencies:

Release files for anyldap 0.2.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for anyldap 0.2.0
File Size Uploaded
anyldap-0.2.0.tar.gz 473.6 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for anyldap 0.2.0
File Interpreter ABI Platform
anyldap-0.2.0-py3-none-any.whl Python 3 none any Details

Total release size: 687.5 kB

Release files / anyldap-0.2.0.tar.gz

Download URL anyldap-0.2.0.tar.gz
Size 473.6 kB
Tags Source
SHA-256 checksum
How to use checksums
9ea561dd5384ce552fa4d41d54975e5565d6a3419a090bac7b4ad3474f9db7e9
BLAKE2b-256 checksum
How to use checksums
9da168f9f04c3b76c528738224d3449eb5be29a01720a407782cca615ded012b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Aug 5, 2026.

Transparency log

Release files / anyldap-0.2.0-py3-none-any.whl

Download URL anyldap-0.2.0-py3-none-any.whl
Size 213.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
c8fc93e1796fb3d7eb009201ce1a0ac306d26b9231ee3d05230a44f0748eee68
BLAKE2b-256 checksum
How to use checksums
9e62d3354b310f9e20f963a27134f63e56f119b5fa6aacfcfe78dee1aef7c1f7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Aug 5, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

0.2.0 This release

2 release files

0.1.0

2 release files

0.0.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page