Skip to main content

A Pure-Python Twisted library for LDAP

Project description

https://travis-ci.org/twisted/ldaptor.svg?branch=master

Ldaptor is a pure-Python library that implements:

  • LDAP client logic

  • 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.

Verbose documentation can be found on ReadTheDocs.

Quick Usage Example

from twisted.internet import reactor, defer
from ldaptor.protocols.ldap import ldapclient, ldapsyntax, ldapconnector

@defer.inlineCallbacks
def example():
    # The following arguments may be also specified as unicode strings
    # but it is recommended to use byte strings for ldaptor objects
    serverip = b'192.168.128.21'
    basedn = b'dc=example,dc=com'
    binddn = b'bjensen@example.com'
    bindpw = b'secret'
    query = b'(cn=Babs*)'
    c = ldapconnector.LDAPClientCreator(reactor, ldapclient.LDAPClient)
    overrides = {basedn: (serverip, 389)}
    client = yield c.connect(basedn, overrides=overrides)
    yield client.bind(binddn, bindpw)
    o = ldapsyntax.LDAPEntry(client, basedn)
    results = yield o.search(filterText=query)
    for entry in results:
        print(entry.getLDIF())

if __name__ == '__main__':
    df = example()
    df.addErrback(lambda err: err.printTraceback())
    df.addCallback(lambda _: reactor.stop())
    reactor.run()

Installation

Ldaptor can be installed using the standard command line method:

python setup.py install

or using pip from PyPI:

pip install ldaptor

Linux distributions may also have ready packaged versions of Ldaptor and Twisted. Debian and Ubuntu have quality Ldaptor packages that can be installed e.g., by:

apt-get install python-ldaptor

To run the LDAP server (bind port 38942) from a repo checkout with the project installed:

twistd -n --pidfile=ldapserver.pid --logfile=ldapserver.log \
    -y test-ldapserver.tac

Dependencies:

Project details


Download files

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

Source Distribution

ldaptor-19.1.0.tar.gz (299.0 kB view details)

Uploaded Source

Built Distribution

ldaptor-19.1.0-py2.py3-none-any.whl (181.5 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file ldaptor-19.1.0.tar.gz.

File metadata

  • Download URL: ldaptor-19.1.0.tar.gz
  • Upload date:
  • Size: 299.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.4.2 requests/2.21.0 setuptools/40.8.0 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/3.7.3

File hashes

Hashes for ldaptor-19.1.0.tar.gz
Algorithm Hash digest
SHA256 64c7b870c77e34e4f5f9cfdf330b9702e89b4dd0f64275704f86c1468312c755
MD5 bee1e75daa206f9a4ed556af98b2f2c4
BLAKE2b-256 35b9e35227fdfaac5b0c5d0d94b3b2d1855dbaa97e057f21fc20e1cf4d6831bd

See more details on using hashes here.

File details

Details for the file ldaptor-19.1.0-py2.py3-none-any.whl.

File metadata

  • Download URL: ldaptor-19.1.0-py2.py3-none-any.whl
  • Upload date:
  • Size: 181.5 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.4.2 requests/2.21.0 setuptools/40.8.0 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/3.7.3

File hashes

Hashes for ldaptor-19.1.0-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 85f7a91b9ea68392bb3594f30ad6a8140fa7c307f2b35ebf005ae50d7a789124
MD5 86de851b2e0fc76d6bc00dac6619a638
BLAKE2b-256 93078a8f88a80fcd5c5af50c3cd8e2370168ffa183831b2a697240ab93d2bb46

See more details on using hashes here.

Supported by

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