Welcome to ldap3’s documentation¶
ldap3 is a pure Python LDAP 3 client library strictly conforming to RFC4510 and is released under the LGPL v3 open source license. RFC4510 is the current LDAP specification (June 2006) from IETF and obsoletes the previous LDAP RFCs 2251, 2830, 3771 (December 1997).
ldap3 can be used with any Python version starting from 2.6, including all Python 3 versions. It also works with PyPy and PyPy3.
ldap3 versioning follows SemVer. In version 2 the public API has slightly changed from version 1: some default values have been changed and the ldap3 namespace has been decluttered, removing redundant constants (look at the changelog for details). Also, the result code constants were moved to ldap3.core.results and the ldap3 custom exceptions were stored in ldap3.core.exceptions. If you experience errors in older code you should rearrange the import statements or explicitly set the defaults to their former values.
Thread safe strategies
In multithreaded programs you must use on of SAFE_SYNC (synchronous connection strategy), SAFE_RESTARTABLE (restartable syncronous connection strategy) or ASYNC (asynchronous connection strategy). Each LDAP operation with SAFE_SYNC or SAFE_RESTARTABLE strategies returns a tuple of four elements: status, result, response and request.
- status: states if the operation was successful
- result: the LDAP result of the operation
- response: the response of a LDAP Search Operation
- request: the original request of the operation
The SafeSync strategy can be used with the Abstract Layer, but the Abstract Layer currently is NOT thread safe. For example, to use SAFE_SYNC:
from ldap3 import Server, Connection, SAFE_SYNC server = Server('my_server') conn = Connection(server, 'my_user', 'my_password', client_strategy=SAFE_SYNC, auto_bind=True) status, result, response, _ = conn.search('o=test', '(objectclass=*)') # usually you don't need the original request (4th element of the returned tuple)
With ASYNC you must request the response with the get_response() method.
- The ldap3 project
- ldap3 Features
- ldap3 Tutorial
- Tutorial: Introduction to ldap3
- Tutorial: searching LDAP entries
- Tutorial: Database operations
- Tutorial: ldap3 Abstraction Layer - Introduction
- Tutorial: ldap3 Abstraction Layer - Reading data
- Tutorial: ldap3 Abstraction Layer - Writing data
- Installation and configuration
- SSL and TLS
- Connection metrics
- LDAP Operations
- The BIND operation
- The UNBIND operation
- The ADD operation
- The DELETE operation
- The MODIFY operation
- The MODIFY-DN operation
- The SEARCH operation
- The COMPARE operation
- The ABANDON operation
- The EXTENDED operation
- Extend namespace
- Abstraction Layer
- LDIF (LDAP Data Interchange Format)
- LDAP3 Utils