LDAP Pool
raw JSON → 3.0.0 verified Sat May 09 auth: no python maintenance
A simple connector pool for python-ldap. Current version 3.0.0 (released 2021). Provides a pool of LDAP connections to reuse, reducing overhead of creating new connections. Stable release cadence, maintenance mode.
pip install ldappool Common errors
error ModuleNotFoundError: No module named 'ldappool.pool' ↓
cause The pool module was removed in version 3.0.0.
fix
Use 'from ldappool import ConnectionManager' directly.
error ldappool.errors.ConnectorError: 'No server available' ↓
cause LDAP server unreachable or incorrect URI.
fix
Verify ldap:// URI and network connectivity. Check if server allows anonymous binds if binddn/password not provided.
error ldappool.errors.ConnectorError: 'Pool exhausted' ↓
cause All connections in pool are in use and pool is not set to unbounded (max_size=0).
fix
Increase pool size, ensure connections are reset properly, or set max_size=0 for unlimited pool.
Warnings
gotcha Connections obtained from pool MUST be returned via .reset() or they will be leaked and eventually exhausted. ↓
fix Always call conn.reset() or use context manager (with manager.connection() as conn:).
breaking In version 3.0.0, the 'pool' module was removed; imports from ldappool.pool will fail. ↓
fix Use 'from ldappool import ConnectionManager' instead.
deprecated The 'ldappool.ConnectionManager' constructor argument 'round_robin' is deprecated. Use 'strategy' instead. ↓
fix Set strategy='round_robin' instead of round_robin=True.
Imports
- ConnectionManager
from ldappool import ConnectionManager
Quickstart
from ldappool import ConnectionManager
manager = ConnectionManager(
uri='ldap://ldap.example.com',
binddn='cn=admin,dc=example,dc=com',
password='secret',
size=10
)
conn = manager.get_connection()
# use conn (python-ldap connection)
print(conn.search_s('dc=example,dc=com', 2, '(objectClass=*)', ['dn']))
conn.reset() # return to pool