LDAP
- class nginx_ldap_auth.ldap.TimeLimitedAIOLDAPConnection(client: LDAPClient, expires: int = 20, loop=None)[source]
A time-limited LDAP connection. This allows us to have a connection pool that will close connections after a certain amount of time.
- Parameters:
client – The LDAP client.
- Keyword Arguments:
expires – The number of seconds after which the connection will expire.
loop – The asyncio event loop.
- abandon()
Abandon ongoing operation associated with the given message id.
- close()
Close connection with the LDAP Server.
- closed
Connection is closed
- async delete(dname, timeout=None, recursive=False)
Delete an LDAPEntry with the given distinguished name.
- fileno()
Get the socket descriptor that belongs to the connection.
- async get_result(msg_id, timeout=None)
Poll the status of the operation associated with the given message id from LDAP server.
- is_async
Asynchronous connection
- modify_password(user: str | LDAPDN | None = None, new_password: str | None = None, old_password: str | None = None, timeout: float | None = None) Any
Modify password for the user.
- open(timeout=None)
Open connection with the LDAP Server.
- paged_search(base: str | LDAPDN | None = None, scope: LDAPSearchScope | int | None = None, filter_exp: str | None = None, attrlist: List[str] | None = None, timeout: float | None = None, sizelimit: int = 0, attrsonly: bool = False, sort_order: List[str] | None = None, page_size: int = 1) Any
- search(base: str | LDAPDN | None = None, scope: LDAPSearchScope | int | None = None, filter_exp: str | None = None, attrlist: List[str] | None = None, timeout: float | None = None, sizelimit: int = 0, attrsonly: bool = False, sort_order: List[str] | None = None) Any
Search for LDAP entries.
- virtual_list_search(base: str | LDAPDN | None = None, scope: LDAPSearchScope | int | None = None, filter_exp: str | None = None, attrlist: List[str] | None = None, timeout: float | None = None, sizelimit: int = 0, attrsonly: bool = False, sort_order: List[str] | None = None, offset: int = 1, before_count: int = 0, after_count: int = 0, est_list_count: int = 0, attrvalue: str | None = None) Any
- class nginx_ldap_auth.ldap.TimeLimitedAIOConnectionPool(settings: Settings, client: LDAPClient, minconn: int = 1, maxconn: int = 10, loop=None, **kwargs: Any)[source]
A pool of time-limited LDAP connections. This allows us to have relatively fresh connections to our LDAP server while not having to create a new connection for every request.
- Parameters:
settings – The application settings.
client – The LDAP client.
- Keyword Arguments:
minconn – The minimum number of connections to keep in the pool.
maxconn – The maximum number of connections to keep in the pool.
loop – The asyncio event loop.
- async get() AIOLDAPConnection [source]
Get a connection from the pool. If a connection has expired, close it and create a new connection, then return the new connection.
- Raises:
ClosedPool – The pool has not been initialized.
EmptyPool – There are no connections in the pool.
- Returns:
A connection from the pool.
- property closed: bool
Read-only property that will be True when the connection pool has been closed.
- property empty: bool
Read-only property that will be True when the connection pool has no free connection to use.
- async put(conn: AIOLDAPConnection) None
Put back a connection to the connection pool. The caller is allowed to close the connection (if, for instance, it is in an error state), in which case it’s not returned to the pool and a subsequent get will grow the pool if needed.
- Parameters:
conn (LDAPConnection) – the connection managed by the pool.
- Raises:
ClosedPool – when the method is called on a closed pool.
PoolError – when tying to put back an object that’s not managed by this pool.
The number of shared connections.
- spawn(*args: Any, **kwargs: Any) AsyncGenerator[AIOLDAPConnection, None]
Context manager method that acquires a connection from the pool and returns it on exit. It also opens the pool if it hasn’t been opened before.
- Params *args:
the positional arguments passed to
bonsai.pool.ConnectionPool.get
.- Params **kwargs:
the keyword arguments passed to
bonsai.pool.ConnectionPool.get
.