A Pure-Python Twisted library for LDAP
Project description
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:
passlib for Samba passwords
six for simultaneous Python 2 and 3 compatability
zope.interface to register implementers of Twisted interfaces
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file ldaptor-20.1.1.tar.gz
.
File metadata
- Download URL: ldaptor-20.1.1.tar.gz
- Upload date:
- Size: 303.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/50.3.0 requests-toolbelt/0.9.1 tqdm/4.50.0 CPython/3.8.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 778f45d68a0b5d63a892c804c05e57b464413a41d8ae52f92ae569321473ab67 |
|
MD5 | fc29a2a5625233e7db913ee48168fc14 |
|
BLAKE2b-256 | 3bb61e44c9a8a0f7a61c88c546895a258b9e3ca00540766f7d1e557aacea0fdf |
File details
Details for the file ldaptor-20.1.1-py2.py3-none-any.whl
.
File metadata
- Download URL: ldaptor-20.1.1-py2.py3-none-any.whl
- Upload date:
- Size: 182.6 kB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/50.3.0 requests-toolbelt/0.9.1 tqdm/4.50.0 CPython/3.8.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | f7028b4acb8a1bc627f3a56874fe8cd33335d941d29e61fb8604d3c8e7fad5e6 |
|
MD5 | 3208084f00aae316a8f0a9595974689e |
|
BLAKE2b-256 | 70126a358f20c52bc0757e713b9ea51f22fdb436f59b52cd6ae6d3febd599806 |