LDAP server, client and utilities, using Twisted Python
Python
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
bin fixes #526522 ldaptor-ldap2passwd --help throws exception. Jul 4, 2014
docs document the return type for startTLS Jul 19, 2018
ldaptor document the return type for startTLS Jul 19, 2018
.coveragerc Fix coverage reporting for local dev environment. Reduce CI builds. B… Jan 12, 2018
.gitignore Fix coverage reporting for local dev environment. Reduce CI builds. B… Jan 12, 2018
.travis.yml Fix non str vs bytes tests for Python3 porting. (#96) May 22, 2018
CONTRIBUTING.rst Fix module imports for py3 and use replacements for methods removed i… Jan 15, 2018
LICENSE doc -> docs rename, updated gitignore, fixed LICENSE and added AUTHORS Oct 14, 2014
MANIFEST.in Fix coverage reporting for local dev environment. Reduce CI builds. B… Jan 12, 2018
README.rst add parentheses around print() in README Jun 26, 2018
codecov.yml Allow for some space in project coverage changes May 28, 2018
ldaptor.schema Add our own LDAP schema file. To use in slapd, add line "include /etc… Jan 20, 2005
requirements-dev.txt adding check-manifest for devs Oct 31, 2014
requirements.txt using pngs, readying for release, go Oct 30, 2014
setup.cfg adding wheel support and renaming to ldaptor Nov 4, 2014
setup.py Use absolute imports and fix all python2 -3 warnings when running tes… Jan 14, 2018
test-ldapserver.tac Move the test LDAP server used in web tests from port 10389 to port 3… Feb 13, 2006
tox.ini Fix non str vs bytes tests for Python3 porting. (#96) May 22, 2018

README.rst

Ldaptor

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():
   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 (bind port 38942) from a repo checkout with the project installed:

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

Dependencies: