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():
serverip = '192.168.128.21'
basedn = 'dc=example,dc=com'
binddn = 'bjensen@example.com'
bindpw = 'secret'
query = '(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
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 (runs on port 38942):
twistd -ny --pidfile=ldapserver.pid --logfile=ldapserver.log \ test-ldapserver.tac
Dependencies:
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-14.0.tar.gz
.
File metadata
- Download URL: ldaptor-14.0.tar.gz
- Upload date:
- Size: 259.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 88b0e15fe0e706bf275d0b2e7bfffe36490a782e745292808ad99eb9cf686479 |
|
MD5 | 7c76ef8a499bc5909f881a3edc276488 |
|
BLAKE2b-256 | 50484cec8e40212f15c1375a6d01fe1e9889236c14b70d3d4d36a49d98cb35a5 |
File details
Details for the file ldaptor-14.0-py2.py3-none-any.whl
.
File metadata
- Download URL: ldaptor-14.0-py2.py3-none-any.whl
- Upload date:
- Size: 153.9 kB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6f91311333d200fa13ee8db37f30afec4f06788d54e996da826fcbb9561cab74 |
|
MD5 | b1adf72327b962059280cf5d109668b1 |
|
BLAKE2b-256 | 42e7c4a5ee98a845ba78772eaaee64b0cfcea3ad5f0763b9776f84c6cda6b062 |