Metadata-Version: 2.4
Name: ldaptor
Version: 21.2.0
Summary: A Pure-Python Twisted library for LDAP
Home-page: https://github.com/twisted/ldaptor
Author: Tommi Virtanen
Author-email: tv@eagain.net
Maintainer: Bret Curtis
Maintainer-email: psi29a@gmail.com
License: MIT
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Classifier: Development Status :: 5 - Production/Stable
Classifier: Framework :: Twisted
Classifier: Programming Language :: Python
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.5
Classifier: Programming Language :: Python :: 3.6
Classifier: Programming Language :: Python :: 3.7
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Classifier: Topic :: System :: Systems Administration :: Authentication/Directory :: LDAP
Requires-Python: ~=3.5
License-File: LICENSE
Requires-Dist: passlib
Requires-Dist: Twisted[tls]>=15.5.0
Requires-Dist: pyparsing
Requires-Dist: six>=1.7
Requires-Dist: zope.interface
Provides-Extra: docs
Requires-Dist: alabaster~=0.7.12; extra == "docs"
Requires-Dist: commonmark~=0.9.1; extra == "docs"
Requires-Dist: docutils~=0.16.0; extra == "docs"
Requires-Dist: mock~=4.0; extra == "docs"
Requires-Dist: pillow~=7.2; extra == "docs"
Requires-Dist: readthedocs-sphinx-ext~=2.1; extra == "docs"
Requires-Dist: recommonmark~=0.6.0; extra == "docs"
Requires-Dist: sphinx~=3.2; extra == "docs"
Requires-Dist: sphinx-rtd-theme~=0.5.0; extra == "docs"
Dynamic: license-file

Ldaptor
=======

.. image:: https://img.shields.io/codecov/c/github/twisted/ldaptor?label=codecov&logo=codecov
    :alt: Codecov
    :target: https://codecov.io/gh/twisted/ldaptor
.. image:: https://img.shields.io/readthedocs/ldaptor?logo=read-the-docs
    :alt: Read the Docs
    :target: https://ldaptor.readthedocs.io/en/latest/
.. image:: https://img.shields.io/github/workflow/status/twisted/ldaptor/CI?label=GitHub%20Actions&logo=github
    :alt: GitHub Actions
    :target: https://github.com/twisted/ldaptor
.. image:: https://img.shields.io/pypi/v/ldaptor?logo=pypi
    :alt: PyPI
    :target: https://pypi.org/project/ldaptor/
.. image:: https://img.shields.io/badge/code%20style-black-black
    :alt: Black
    :target: https://github.com/psf/black

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 <https://ldaptor.readthedocs.org>`_.


Quick Usage Example
-------------------

.. code-block:: python

    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:

- `Twisted[tls] <https://pypi.python.org/pypi/Twisted/>`_
- `pyparsing <https://pypi.python.org/pypi/pyparsing/>`_
- `passlib <https://pypi.python.org/pypi/passlib/>`_ for Samba passwords
- `six <https://pypi.python.org/pypi/six/>`_ for simultaneous Python 2 and 3 compatability
- `zope.interface <https://pypi.python.org/pypi/zope.interface/>`_ to register implementers of Twisted interfaces
