ldap3.strategy package¶
Submodules¶
ldap3.strategy.asynchronous module¶
-
class
ldap3.strategy.asynchronous.
AsyncStrategy
(ldap_connection)[source]¶ Bases:
ldap3.strategy.base.BaseStrategy
This strategy is asynchronous. You send the request and get the messageId of the request sent Receiving data from socket is managed in a separated thread in a blocking mode Requests return an int value to indicate the messageId of the requested Operation You get the response with get_response, it has a timeout to wait for response to appear Connection.response will contain the whole LDAP response for the messageId requested in a dict form Connection.request will contain the result LDAP message in a dict form Response appear in strategy._responses dictionary
-
class
ReceiverSocketThread
(ldap_connection)[source]¶ Bases:
threading.Thread
The thread that actually manage the receiver socket
-
class
ldap3.strategy.asyncStream module¶
-
class
ldap3.strategy.asyncStream.
AsyncStreamStrategy
(ldap_connection)[source]¶ Bases:
ldap3.strategy.asynchronous.AsyncStrategy
This strategy is asynchronous. It streams responses in a generator as they appear in the self._responses container
ldap3.strategy.base module¶
-
class
ldap3.strategy.base.
BaseStrategy
(ldap_connection)[source]¶ Bases:
object
Base class for connection strategy
-
static
compute_ldap_message_size
(data)[source]¶ Compute LDAP Message size according to BER definite length rules Returns -1 if too few data to compute message length
-
static
decode_control
(control)[source]¶ decode control, return a 2-element tuple where the first element is the control oid and the second element is a dictionary with description (from Oids), criticality and decoded control value
-
static
decode_control_fast
(control)[source]¶ decode control, return a 2-element tuple where the first element is the control oid and the second element is a dictionary with description (from Oids), criticality and decoded control value
-
decode_response_fast
(ldap_message)[source]¶ Convert received LDAPMessage from fast ber decoder to a dict
-
get_response
(message_id, timeout=None, get_request=False)[source]¶ Get response LDAP messages Responses are returned by the underlying connection strategy Check if message_id LDAP message is still outstanding and wait for timeout to see if it appears in _get_response Result is stored in connection.result Responses without result is stored in connection.response A tuple (responses, result) is returned
-
static
ldap3.strategy.ldifProducer module¶
-
class
ldap3.strategy.ldifProducer.
LdifProducerStrategy
(ldap_connection)[source]¶ Bases:
ldap3.strategy.base.BaseStrategy
This strategy is used to create the LDIF stream for the Add, Delete, Modify, ModifyDn operations. You send the request and get the request in the ldif-change representation of the operation. NO OPERATION IS SENT TO THE LDAP SERVER! Connection.request will contain the result LDAP message in a dict form Connection.response will contain the ldif-change format of the requested operation if available You don’t need a real server to connect to for this strategy
ldap3.strategy.mockAsync module¶
-
class
ldap3.strategy.mockAsync.
MockAsyncStrategy
(ldap_connection)[source]¶ Bases:
ldap3.strategy.mockBase.MockBaseStrategy
,ldap3.strategy.asynchronous.AsyncStrategy
This strategy create a mock LDAP server, with asynchronous access It can be useful to test LDAP without accessing a real Server
ldap3.strategy.mockBase module¶
-
class
ldap3.strategy.mockBase.
MockBaseStrategy
[source]¶ Bases:
object
Base class for connection strategy
-
evaluate_filter_node
(node, candidates)[source]¶ After evaluation each 2 sets are added to each MATCH node, one for the matched object and one for unmatched object. The unmatched object set is needed if a superior node is a NOT that reverts the evaluation. The BOOLEAN nodes mix the sets returned by the MATCH nodes
-
ldap3.strategy.mockSync module¶
-
class
ldap3.strategy.mockSync.
MockSyncStrategy
(ldap_connection)[source]¶ Bases:
ldap3.strategy.mockBase.MockBaseStrategy
,ldap3.strategy.sync.SyncStrategy
This strategy create a mock LDAP server, with synchronous access It can be useful to test LDAP without accessing a real Server
ldap3.strategy.restartable module¶
ldap3.strategy.reusable module¶
-
class
ldap3.strategy.reusable.
ReusableStrategy
(ldap_connection)[source]¶ Bases:
ldap3.strategy.base.BaseStrategy
A pool of reusable SyncWaitRestartable connections with lazy behaviour and limited lifetime. The connection using this strategy presents itself as a normal connection, but internally the strategy has a pool of connections that can be used as needed. Each connection lives in its own thread and has a busy/available status. The strategy performs the requested operation on the first available connection. The pool of connections is instantiated at strategy initialization. Strategy has two customizable properties, the total number of connections in the pool and the lifetime of each connection. When lifetime is expired the connection is closed and will be open again when needed.
-
class
PooledConnectionThread
(worker, master_connection)[source]¶ Bases:
threading.Thread
The thread that holds the Reusable connection and receive operation request via the queue Result are sent back in the pool._incoming list when ready
-
class
PooledConnectionWorker
(connection, request_queue)[source]¶ Bases:
object
Container for the restartable connection. it includes a thread and a lock to execute the connection in the pool
-
pools
= {}¶
-
class
ldap3.strategy.sync module¶
-
class
ldap3.strategy.sync.
SyncStrategy
(ldap_connection)[source]¶ Bases:
ldap3.strategy.base.BaseStrategy
This strategy is synchronous. You send the request and get the response Requests return a boolean value to indicate the result of the requested Operation Connection.response will contain the whole LDAP response for the messageId requested in a dict form Connection.request will contain the result LDAP message in a dict form
-
post_send_search
(message_id)[source]¶ Executed after a search request Returns the result message and store in connection.response the objects found
-