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:

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

anyldap-0.2.0.tar.gz (473.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

anyldap-0.2.0-py3-none-any.whl (213.9 kB view details)

Uploaded Python 3

File details

Details for the file anyldap-0.2.0.tar.gz.

File metadata

  • Download URL: anyldap-0.2.0.tar.gz
  • Upload date:
  • Size: 473.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for anyldap-0.2.0.tar.gz
Algorithm Hash digest
SHA256 9ea561dd5384ce552fa4d41d54975e5565d6a3419a090bac7b4ad3474f9db7e9
MD5 e8c8a8a67d282760e887eabeba4b2543
BLAKE2b-256 9da168f9f04c3b76c528738224d3449eb5be29a01720a407782cca615ded012b

See more details on using hashes here.

Provenance

The following attestation bundles were made for anyldap-0.2.0.tar.gz:

Publisher: main.yml on graingert/anyldap

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file anyldap-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: anyldap-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 213.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for anyldap-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 c8fc93e1796fb3d7eb009201ce1a0ac306d26b9231ee3d05230a44f0748eee68
MD5 aa0cd20265414275c72b46ebbf2ad79e
BLAKE2b-256 9e62d3354b310f9e20f963a27134f63e56f119b5fa6aacfcfe78dee1aef7c1f7

See more details on using hashes here.

Provenance

The following attestation bundles were made for anyldap-0.2.0-py3-none-any.whl:

Publisher: main.yml on graingert/anyldap

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page