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.


Version 2.8 of ldap3 introduced SafeSync, a new connection strategy that can be used in multithreaded programs. In previous version only the ASYNC strategy was thread safe. Each LDAP operation with the SafeSync strategy 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. The SafeSync import name is SAFE_SYNC:

from ldap3 import Server, Connection, SAFE_SYNC
server = Server('my_server')
conn = Connection(s, 'my_user', 'my_password', 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 return tuple)


Indices and tables