MSLDAPClientConnection – low level LDAP connection¶
- class msldap.connection.MSLDAPClientConnection(target: MSLDAPTarget, credential: UniCredential, auth=None)¶
- async add(entry: str, attributes: Dict[str, object])¶
Performs the add operation.
- Parameters
entry (str) – The DN of the object to be added
attributes (dict) – Attributes to be used in the operation
- Returns
A tuple of (True, None) on success or (False, Exception) on error.
- Return type
(
bool
,Exception
)
- async connect()¶
Connects to the remote server. Establishes the session, but doesn’t perform binding. This function MUST be called first before the bind operation.
- Returns
A tuple of (True, None) on success or (False, Exception) on error.
- Return type
(
bool
,Exception
)
- async delete(entry: str)¶
Performs the delete operation.
- Parameters
entry (str) – The DN of the object to be deleted
- Returns
A tuple of (True, None) on success or (False, Exception) on error.
- Return type
(
bool
,Exception
)
- async disconnect()¶
Tears down the connection.
- Returns
Nothing
- Return type
None
- async modify(entry: str, changes: Dict[str, object], controls: Optional[List[Control]] = None)¶
Performs the modify operation.
- Parameters
entry (str) – The DN of the object whose attributes are to be modified
changes (dict) – Describes the changes to be made on the object. Must be a dictionary of the following format: {‘attribute’: [(‘change_type’, [value])]}
controls (List[class:Control]) – additional controls to be passed in the query
- Returns
A tuple of (True, None) on success or (False, Exception) on error.
- Return type
(
bool
,Exception
)
- async pagedsearch(base: str, query: str, attributes: List[str], search_scope: int = 2, size_limit: int = 1000, typesOnly: bool = False, derefAliases: bool = 0, timeLimit: Optional[int] = None, controls: Optional[List[Control]] = None, rate_limit: int = 0)¶
Paged search is the same as the search operation and uses it under the hood. Adds automatic control to read all results in a paged manner.
- Parameters
base (str) – base tree on which the search should be performed
query (str) – filter query that defines what should be searched for
attributes (List[str]) – a list of attributes to be included in the response
search_scope (int) – Specifies the search operation’s scope. Default: 2 (Subtree)
types_only (bool) – indicates whether the entries returned should include attribute types only or both types and values. Default: False (both)
size_limit (int) – Size limit of result elements per query. Default: 1000
derefAliases (int) – Specifies the behavior on how aliases are dereferenced. Default: 0 (never)
timeLimit (int) – Maximum time the search should take. If time limit reached the server SHOULD return an error
controls (dict) – additional controls to be passed in the query
rate_limit (float) – time to sleep bwetween each query
- Returns
Async generator which yields (dict, None) tuple on success or (None, Exception) on error
- Return type
Iterator[(
dict
,Exception
)]
- async search(base: str, query: str, attributes: List[str], search_scope: int = 2, size_limit: int = 1000, types_only: bool = False, derefAliases: int = 0, timeLimit: Optional[int] = None, controls: Optional[List[Control]] = None, return_done: bool = False)¶
Performs the search operation.
- Parameters
base (str) – base tree on which the search should be performed
query (str) – filter query that defines what should be searched for
attributes (List[str]) – a list of attributes to be included in the response
search_scope (int) – Specifies the search operation’s scope. Default: 2 (Subtree)
types_only (bool) – indicates whether the entries returned should include attribute types only or both types and values. Default: False (both)
size_limit (int) – Size limit of result elements per query. Default: 1000
derefAliases (int) – Specifies the behavior on how aliases are dereferenced. Default: 0 (never)
timeLimit (int) – Maximum time the search should take. If time limit reached the server SHOULD return an error
controls (List[class:Control]) – additional controls to be passed in the query
return_done (bool) – Controls wether the final ‘done’ LDAP message should be returned, or just the actual results
- Returns
Async generator which yields (LDAPMessage, None) tuple on success or (None, Exception) on error
- Return type
Iterator[(
LDAPMessage
,Exception
)]