o
    j                     @   s|  d Z ddlZz
ddlmZ dZW n ey   dZY nw ddlmZ ddlmZ ddl	m
Z
 d	d
lmZmZmZmZmZmZmZmZ d	dlmZmZ d	dlmZmZmZmZmZmZmZmZm Z m!Z!m"Z"m#Z#m$Z$m%Z% d	dl&m'Z' d	dl(m)Z)m*Z*m+Z+m,Z, d	dl-m.Z.m/Z/ d	dl0m1Z1m2Z2 d	dl3m4Z4m5Z5m6Z6m7Z7m8Z8m9Z9m:Z:m;Z; d	dl<m=Z=m>Z>m?Z?m@Z@mAZA d	dlBmCZCmDZD d	dlEmFZFmGZGmHZHmIZImJZJ d	dlKmLZL d	dlMmNZNmOZO d	dlPmQZQmRZR d	dlSmTZTmUZU d	dlVmWZW d	dlXmYZY d	dlZm[Z[ d	dl\m]Z] d	dl^m_Z_ d	dl`maZambZbmcZcmdZdmeZemfZfmgZgmhZh d	dlimjZjmkZkmlZlmmZm d	d lnmoZo d	d!lpmqZqmrZr d"Zsd#Ztd$ZuG d%d& d&evZwdS )'
    N)AF_UNIXTF)pack)system)choice   )SYNC	ANONYMOUSget_config_parameterBASEALL_ATTRIBUTESALL_OPERATIONAL_ATTRIBUTESNO_ATTRIBUTES
DIGEST_MD5)DO_NOT_RAISE_EXCEPTIONSRESULT_REFERRAL)LDAPOperationResultLDAPSASLBindInProgressErrorLDAPSocketOpenError"LDAPSessionTerminatedByServerErrorLDAPUnknownResponseErrorLDAPUnknownRequestErrorLDAPReferralErrorcommunication_exception_factoryLDAPStartTLSErrorLDAPSocketSendErrorLDAPExceptionErrorLDAPControlErrorLDAPResponseTimeoutErrorLDAPTransactionError)	parse_uri)LDAPMessage
ProtocolOp	MessageIDSearchResultEntry)add_response_to_dictadd_request_to_dict)modify_request_to_dictmodify_response_to_dict)(search_result_reference_response_to_dict#search_result_done_response_to_dict$search_result_entry_response_to_dictsearch_request_to_dict)search_result_entry_response_to_dict_fast-search_result_reference_response_to_dict_fastattributes_to_dictattributes_to_dict_fast)bind_response_to_dictbind_request_to_dictsicily_bind_response_to_dictbind_response_to_dict_fast!sicily_bind_response_to_dict_fast)compare_response_to_dictcompare_request_to_dict)extended_request_to_dictextended_response_to_dictintermediate_response_to_dictextended_response_to_dict_fast"intermediate_response_to_dict_fast)Server)modify_dn_request_to_dictmodify_dn_response_to_dict)delete_response_to_dictdelete_request_to_dict)prepare_changes_for_requestbuild_controls_list)abandon_request_to_dict)Tls)Oids)RealSearchControlValue)DirSyncControlResponseValue)loglog_enabledERRORBASICPROTOCOLNETWORKEXTENDEDformat_ldap_message)encodedecoderldap_result_to_dict_fastdecode_sequence)
to_unicode)md5_hmd5_hmacTERMINATED_BY_SERVERTRANSACTION_ERRORRESPONSE_FROM_SERVER_COMPLETEc                   @   s  e Zd ZdZdd Zdd Zd?ddZd	d
 Zd@ddZdd Z	dd Z
dAddZdBddZedd Zdd Zdd Zedd ZedCdd ZedAd!d"Zd#d$ Zd%d& Zd'd( Zd)d* Zd+d, Zd-d. Zd/d0 Zd1d2 Zd3d4 Zd5d6 Zd7d8 Zd9d: Zd;d< Z d=d> Z!dS )DBaseStrategyz,
    Base class for connection strategy
    c                 C   sX   || _ d | _g | _d | _d | _d | _d | _i | _d| _t	t
r*tt
d| jj|  d S d S )NFzinstantiated <%s>: <%s>)
connection_outstanding
_referralssyncno_real_dsapooled
can_streamreferral_cachethread_saferJ   rL   rI   	__class____name__)selfldap_connection ri   /root/aizidognhua/tmp/workspace/projects/ec89d86c-575f-41c9-af57-ac45cbdbf775/venv/lib/python3.10/site-packages/ldap3/strategy/base.py__init__N   s   zBaseStrategy.__init__c                 C   sP   | j rt| j nd| jrdnd| jrdnd| jrdnd| jr dnd	g}d
|S )NNoner_   asynczno real DSAzreal DSAra   z
not pooledzcan stream outputzcannot stream output - )r\   strr_   r`   ra   rb   join)rg   sri   ri   rj   __str__[   s   
zBaseStrategy.__str__Tc                 C   s  t trttd| j | jjr*| jjs*d| j_d| j_t tr(ttd| j dS dS | jjs6| jjs6|   t	 | _
| jjrK|sE| jjjsK| jj  | jjrn| jj| j}| jj|krn|| j_| jjrn| jj jd7  _g }| js+| jj D ]W}z,t trttd|dd  | j|| jjj| jjjd	 || jj_| jj|d W  n) ty } z| jj|d |t|t||d
 f W Y d}~qzd}~ww | jjjs|rt|dkrt t rtt dt|d d d t|d d  | j |d d t t rtt d| j t!d|| jjjs+t t r'tt d| j t!dd| j_| "  t trAttd| j dS dS )z^
        Open a socket to a server. Choose a server from the server pool if available
        zopening connection for <%s>TFz"deferring open connection for <%s>   z try to open candidate address %sN)unix_socket   <%s> for <%s>r    zunable to open socket for <%s>zunable to open socketzinvalid server address for <%s>zinvalid server addresszconnection open for <%s>)#rJ   rN   rI   r\   lazy_executing_deferred_deferred_openclosedclosedictr]   usage_usageinitial_connection_start_timestartserver_pool
get_serverserverservers_from_poolr`   candidate_addressesrL   _open_socketsslipccurrent_addressupdate_availability	Exceptionappendtypero   lenrK   r   _start_listen)rg   reset_usageread_server_info
new_serverexception_historycandidate_addresseri   ri   rj   opene   sh   
*0



zBaseStrategy.openc                 C   s   t trttd| j | jjr/| jjs/| jjs| jjr/d| j_d| j_	t tr.ttd| j n| jj	s>| 
  | js>|   t trIttd| j d| j_d| j_d| j_d| j_d| _g | _| jjjsid| jj_| jjru| jj  dS dS )z"
        Close connection
        zclosing connection for <%s>FTz#deferred connection closed for <%s>zconnection closed for <%s>N)rJ   rN   rI   r\   ry   rz   _deferred_bindr{   	listeningr|   _stop_listenr`   _close_socketboundrequestresponsetls_startedr]   r^   strategyr   r   r   r   stoprg   ri   ri   rj   r}      s2    

zBaseStrategy.closeFc           	      C   s  zt j |dd  | j_ W n1 ty> } z%dt| | j_ttr+ttd| jj| j tt	t
|t|| jjd}~ww d}tr| jj jt jkrd}| jjD ]4}z| jj | jj|f d}W  n" ty } z|}ttr{ttd| jj|| W Y d}~qQd}~ww |sdt| | j_ttrttd	| jj| jj| j| tt	t
|t||z| jjjr| jj | jjj | jj |d
  W n2 t jy } z%dt| | j_ttrttd| jj| j tt	t
|t|| jjd}~ww | jjdurnz6| jj | jj t  dkr'| jj t jt jtd| jj  n| jj t jt jtd| jjd W n4 t jym } z&dt| | j_ttrZttd| jj| j tt	t
|t|| jjd}~ww |rz| jjjj | jdd | jj!r| jj" j#d7  _#W n3 ty } z&dt| | j_ttrttd| jj| j tt	t
|t|| jjd}~ww | jj!r| jj" j$d7  _$d| j_%dS )z
        Tries to open and connect a socket to a Server
        raise LDAPExceptionError if unable to open or connect socket
        N   zsocket creation error: rw   FTzFUnable to bind to local address <%s> with source port <%s> due to <%s>z/socket connection error while locally binding: zmUnable to locally bind to local address <%s> with any of the source ports <%s> for connection <%s due to <%s>rv   z'socket connection error while opening: windowsi  LLr   z5unable to set receive timeout for socket connection: )do_handshakers   zsocket ssl wrapping error: )&socketr\   r   ro   
last_errorrJ   rK   rI   r   r   r   unix_socket_availablefamilyr   source_port_listbindsource_addressrN   r   connect_timeout
settimeoutconnecterrorreceive_timeoutr   lower
setsockopt
SOL_SOCKETSO_RCVTIMEOintr   tlswrap_socketr   r   wrapped_socketsopen_socketsr|   )	rg   addressuse_sslru   r   last_bind_excsocket_bind_succeededsource_portbind_exri   ri   rj   r      s   

$"



zBaseStrategy._open_socketc                 C   s~   z
| j jtj W n	 ty   Y nw z| j j  W n	 ty%   Y nw d| j _d| j _| j jr=| j j j	d7  _	dS dS )z
        Try to close a socket
        don't raise exception if unable to close socket, assume socket is already closed
        NTrs   )
r\   r   shutdown	SHUT_RDWRr   r}   r|   r   r   closed_socketsr   ri   ri   rj   r     s   zBaseStrategy._close_socketc                 C   s   d| j _d S NF)r\   r   r   ri   ri   rj   r   3  s   zBaseStrategy._stop_listenNc                 C   s   d| j _| j jrc| j jr(|dvr(d| j _ttr"ttd| j j| j  t| j j| j j	
 }t }t||d< t |||d< t|}|durL||d< t|||| j _| j j| j|< | | |S d| j _ttruttd| j j| j  t| j j)	zE
        Send an LDAP message
        Returns the message_id
        N)bindRequestz=cannot send operation requests while SASL bind is in progressrw   	messageID
protocolOpcontrolsz*unable to send message, socket is not open)r\   r   r   sasl_in_progressr   rJ   rK   rI   r   r   next_message_idr!   r#   r"   setComponentByNamerC   r[   decode_requestr]   sendingr   )rg   message_typer   r   
message_idldap_messagemessage_controlsri   ri   rj   send6  s,   
zBaseStrategy.sendc              	   C   s  |du rt d}d}d}| jr|| jv r| ||}|s-ttr)ttd| j td|tkr\z| 	  W n t
jtfyC   Y nw d| j_ttrVttd| jj| j t| jj|tkrxd| j_ttrrttd| jj| j t| jj|d d	 tkr| jjr| jj jd
7  _| jjr| | j| |d d \}}|dur||g }|t n|dur|tg}g | _|r|d }|dd }d| j_d| j_| jjr|r|d	 tvrttrttd|| j | j| |  | j_t!|d	 |d |d |d |d d| jj"r_t#| ds_t$dd |D r_|  | _%|dd }	| &| j| |r]|	D ]#}
|
d dkrVdd |
d D }|D ]}|
d |= |
d |= qHq4|	}| j%}| `%| jj'r|D ]}}|d dkr| j| d D ],}||d vr|t(t)t*fvrt+ |d |< t+ |d |< ttrttd||  qv| jj"sg }|d D ]}d|, v r|-d\}}}|| q|D ]}ttrttd||  |d |= |d |= qȐqf| j|}nttrttd| j td|r|||fS ||fS ) a  
        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
        NRESPONSE_WAITING_TIMEOUTz0socket timeout, no response from server for <%s>zno response from serverzsession terminated by serverrw   ztransaction errorrt   resultrs   	referralszoperation result <%s> for <%s>descriptiondnmessager   )r   r   r   r   response_type_auto_range_searchingc                 s   s2    | ]}d |v r|d  D ]	}d|v rdV  qqdS )raw_attributes;range=TNri   ).0respnameri   ri   rj   	<genexpr>  s   0 z,BaseStrategy.get_response.<locals>.<genexpr>searchResEntryc                 S   s   g | ]}d |v r|qS )r   ri   )r   keyri   ri   rj   
<listcomp>  s    z-BaseStrategy.get_response.<locals>.<listcomp>r   
attributesz>attribute set to empty list for missing attribute <%s> in <%s>z;range;ziattribute type <%s> removed in response because of same attribute returned as range by the server in <%s>z,message id not in outstanding queue for <%s>z#message id not in outstanding queue).r
   r]   _get_responserJ   rK   rI   r\   r   SESSION_TERMINATED_BY_SERVERr}   r   r   r   r   r   rY   r   r   r   r   referrals_receivedauto_referralsdo_operation_on_referralr   RESPONSE_COMPLETEr^   r   r   raise_exceptionsr   rM   popcopyr   
auto_rangehasattranyr   do_search_on_auto_rangeempty_attributesr   r   r   listr   	partition)rg   r   timeoutget_requestr   r   	responsesref_response
ref_resulttemp_responser   keysr   entryattribute_typeattrs_to_remove	orig_attr_r   ri   ri   rj   get_responseT  s   	
&*









zBaseStrategy.get_responsec                 C   s   t | tr	t| } d}t| dkrN| d dkr| d d }|S | d d }t| |d krNd}|}| dd|  D ]}|d8 }||d|  7 }q9|d | }|S )z
        Compute LDAP Message size according to BER definite length rules
        Returns -1 if too few data to compute message length
        r   rs         r      )
isinstancero   	bytearrayr   )data	ret_valuebytes_lengthvalue_lengthcontbyteri   ri   rj   compute_ldap_message_size  s    
z&BaseStrategy.compute_ldap_message_sizec                 C   s  | d }|d  }|d  r|d nd}|dkr0t|d ds+t|}nzt|}nu|dkrDt|| j	j
j| j	j
j| j	j}na|dkrMt|}nX|d	krVt|}nO|d
kr_t|}nF|dkrht|}n=|dkrqt|}n4|dkrzt|}n+|dkrt|}n"|dkrt|}n|dkrt|}nttrttd|| j	 td||d< |rt |d< |D ]}| |}|d |d |d < q|S )z8
        Convert received LDAPMessage to a dict
        r   r   NbindResponse	matchedDN   NTLMr   searchResDonesearchResRefmodifyResponseaddResponsedelResponsemodDNResponsecompareResponseextendedRespintermediateResponseunknown response <%s> for <%s>unknown responser   rs   r   )getComponentByNamegetNamegetComponenthasValuebytes
startswithr1   r3   r+   r\   r   schemacustom_formattercheck_namesr*   r)   r(   r%   r@   r?   r6   r9   r:   rJ   rK   rI   r   r~   decode_control)rg   r   r   	componentr   r   controldecoded_controlri   ri   rj   decode_response  sJ   

 










zBaseStrategy.decode_responsec                 C   s  |d dkr#|d d d  dst|d }nt|d }d|d< n|d dkr?t|d | jjj| jjj| jj}d	|d< n|d d
krPt	|d }d|d< n|d dkrat
|d }d|d< n|d dkrrt	|d }d|d< nx|d dkrt	|d }d|d< ng|d dkrt	|d }d|d< nV|d dkrt	|d }d|d< nE|d dkrt	|d }d|d< n4|d dkrt|d }d|d< n#|d dkrt|d }d|d< nttrttd|d | j td|d rt |d< |d D ]}| |d }|d |d |d < q|S ) zN
        Convert received LDAPMessage from fast ber decoder to a dict
        r   rs   payloadr   r  r  r   rv   r      r     r     r  	   r     r     r     r     r     r  r  r  r   r   )r%  r4   r5   r-   r\   r   r&  r'  r(  rS   r.   r;   r<   rJ   rK   rI   r   r~   decode_control_fast)rg   r   r   r+  r,  ri   ri   rj   decode_response_fast  sX   
"











z!BaseStrategy.decode_response_fastc                 C   s   t | d }t| d }t| d }d}|dkr6tj|t d\}}t }t|d |d< t|d |d< n?|d	krXtj|t d\}}t }t|d
 |d< t|d |d< n|dks`|dkrutj|t	 d\}}t }t
|d |d< |rttrttd td|t|d||dfS )
        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
        controlTypecriticalitycontrolValueN1.2.840.113556.1.4.319)asn1Specsizecookie1.2.840.113556.1.4.841MoreResultsmore_resultsCookieServer1.3.6.1.1.13.11.3.6.1.1.13.2r   r   z)unprocessed control response in substrate r   r<  value)ro   boolr$  rR   decoderG   r~   r   rH   r$   r/   rJ   rK   rI   r   rF   get)r+  control_typer<  control_valueunprocessedcontrol_respri   ri   rj   r)  >  s.   
zBaseStrategy.decode_controlc                 C   sf  t t| d d |d}d}d}| dd D ]}|d dkr#|d }q|d dkr+dnd	}q|d
krZt|dt|}t }t|d d d d |d< t|d d d d |d< nM|dkrt|dt|}t }|d d d d rud	nd|d< |d d d d |d< n!|dks|dkrt|dt|}t }t|d d d d |d< |t	|d||dfS )r:  r   r   )from_serverFNrs   r   rv   Tr>  r@  rA  rB  rD  rF  rG  r   rH  rI  )
ro   rU   rT   r   r~   r   r$  r0   rF   rM  )r+  rR  rN  r<  rO  rrQ  ri   ri   rj   r8  \  s,   
 z BaseStrategy.decode_control_fastc                 C   s   | dkr	t |}n^| dkrt }nV| dkrt|}nM| dkr#t|}nD| dkr,t|}n;| dkr5t|}n2| dkr>t|}n)| dkrGt|}n | d	krPt|}n| d
krYt	|}nt
trcttd|  td| |d< ||d< |S )Nr   unbindRequest
addRequestcompareRequest
delRequestextendedReqmodifyRequestmodDNRequestsearchRequestabandonRequestzunknown request <%s>zunknown requestr   r   )r2   r~   r&   r7   rA   r8   r'   r>   r,   rD   rJ   rK   rI   r   )r   r*  r   r   ri   ri   rj   r   z  s4   








zBaseStrategy.decode_requestc                 C   st   g }|D ]3}t |}|r7| jjjD ]%}|d |d ks!|d dkr6|d | jvr6|d  |d< ||  nqq|S )Nr   host*rs   anonymousBindOnly)r    r\   r   allowed_referral_hostsr^   r   )rg   r   referral_listreferralcandidate_referralref_hostri   ri   rj   valid_referral_list  s   
z BaseStrategy.valid_referral_listc              	   C   s  d}|}|s| d\}}}| d\}}}	|d |  |d | 7  < |d |  |d | 7  < |	dkrttrHttdtt|	d | j |d tt|	d  d	 }
| jj|d
 dt|d |d tt|	d  d	 gd}| jj	j
r~|\}}}}n
|}| jj}| jj}| jj	jr|r|d }nd}n| |\}}|d }|s|
|d v rt|d |
 dkr|d |
= |d |
= ttdd |d  d }qd}|rd S d S )NFr   -r   r   r^  z2performing next search on auto-range <%s> via <%s>rs   z-*r   z(objectclass=*)dereferenceAlias)search_basesearch_filtersearch_scopedereference_aliasesr   r   Tc                 S   s   d| v S )Nr   ri   )ari   ri   rj   <lambda>  s    z3BaseStrategy.do_next_range_search.<locals>.<lambda>)r   rJ   rM   rI   ro   r   r\   searchr   r   rd   r   r   r_   r  r   r   filterr   )rg   r   r   	attr_namedonecurrent_response	attr_typer  returned_range
high_rangerequested_ranger   status	_responseri   ri   rj   do_next_range_search  sH   


 

z!BaseStrategy.do_next_range_searchc                 C   s   dd |D D ]R}t |d  D ]G}d|v rX|d\}}}|dv r'  dS ||d vs5|d | d u r<t  |d |< ||d vsJ|d | d u rQt  |d |< | ||| qqdS )	Nc                 S   s   g | ]
}|d  dkr|qS )r   r   ri   )r   rS  ri   ri   rj   r     s    z8BaseStrategy.do_search_on_auto_range.<locals>.<listcomp>r   r   )z1-1z0-0Fr   T)r   r   r   ry  )rg   r   r   r   rp  rs  r  range_valuesri   ri   rj   r     s   
z$BaseStrategy.do_search_on_auto_rangec           
         sP  d }d }d }  |}|r# fdd|D }|rt|nt|}|d |d p, jjj|d f} jjr@| jv r@ j| }nt|d |d pL jjj|d  jjj jjj	 jjj
 jjj jjj|d rt jjjj jjjj jjjj jjjj jjjjdnd d	}dd	lm} |||d
 s jjnd |d
 s jjnd  jj|d
 s jjnttd jj jj jj jj jj jj  jj!d} jj"rՈ jj# j$d7  _$|%   j&|j'_& jj(r|j)s|* sd|j+rd|j+ nd }	t,t-rt.t-d|	   /  t0|	 jj1r|2   jj"r# jj# j3d7  _3|||fS )Nc                    s"   g | ]}|d   j jjkr|qS )r   )r\   r   r   )r   rb  r   ri   rj   r     s    z;BaseStrategy.create_referral_connection.<locals>.<listcomp>r]  portr   )local_private_key_filelocal_certificate_filevalidateversionca_certs_file)	r]  r{  r   get_info	formatterr   moder`  r   r   )
Connectionr_  T)r   userpasswordr  authenticationclient_strategyr   	read_onlyr(  r   fast_decoderr   sasl_mechanismsasl_credentialsrs   z$start_tls in referral not successfulrn   rH  z%s for <%s>)4re  r   r\   r   r{  use_referral_cacherc   r=   r  r'  r   r  r`  rE   r   private_key_filecertificate_filer~  r  r  core.connectionr  r  r  r  r	   r   r  r(  r   r  r   r  r  r   r   referrals_connectionsr   r^   r   r   r   	start_tlsr   rJ   rK   rI   unbindr   r   r   referrals_followed)
rg   r   referral_connectionselected_referralcachekeyre  preferred_referral_listreferral_serverr  r   ri   r   rj   create_referral_connection  sz   
 









z'BaseStrategy.create_referral_connectionc                 C   sJ  t trttd| j | |\}}}|r|d dkrM|j|d p%|d |d p,|d |d p3|d |d |d p=|d |d	 |d
 |d |d d	 n|d dkrg|j|d p\|d d |d |d d n|d dkr|j|d pv|d |d |d |d d n~|d dkr|j|d p|d |d d nh|d dkr|j	|d |d |d dd nR|d dkr|j
|d p|d t|d |d d n7|d dkr|j|d p|d |d |d |d |d d nd| j_t trttd| jj| j t| jj|j}|j}| jjr|| j|< ||fS |  ||fS d }d }||fS ) Nzfollowing referral for <%s>r   r[  basero  scoperg  r   	sizeLimit	timeLimit	typesOnlyr   )r   rU  r   rV  	attributerJ  rW  rX  r   T)r   	no_encoderY  changesrZ  newRdndeleteOldRdnnewSuperiorz referral operation not permittedrw   )rJ   rM   rI   r\   r  rn  addcomparedeleteextendedmodifyrB   	modify_dnr   rK   r   r   r   r  rc   r  )rg   r   r   r  r  r  r   r   ri   ri   rj   r   $  s~   	



z%BaseStrategy.do_operation_on_referralc              
   C   s  t trttd| j zt|}| jjtkrf| jjrf| jjsf| jj	}| jj}t
t|t|dd| dd }tt|d d d dd| | tddd t|dd }| j j	d7  _	| jj| t tr|ttd	| jt|d
 t trttdt|| j W n4 tjy } z'dt| | j_d }t trttd| jj| j ttt|t|| jjd }~ww | jjr| jj| jjt| d S d S )Nzsending 1 ldap message for <%s>rv   bigr      r   
   rs   zldap message sent via <%s>:%sz>>zsent %d bytes via <%s>zsocket sending errorrw   )rJ   rN   rI   r\   rQ   r  r   _digest_md5_kicr   _digest_md5_sec_numr$  fromhexrW   r   to_bytesr   r   sendallrO   rP   r   ro   r   rK   r   r   r   r   r   update_transmitted_messager   )rg   r   encoded_messagesec_numkic	signaturer   ri   ri   rj   r   b  s6   (HzBaseStrategy.sendingc                 C      t NNotImplementedErrorr   ri   ri   rj   r        zBaseStrategy._start_listenc                 C   r  r  r  )rg   r   r   ri   ri   rj   r     r  zBaseStrategy._get_responsec                 C   r  r  r  r   ri   ri   rj   	receiving  r  zBaseStrategy.receivingc                 C   r  r  r  rg   r   ri   ri   rj   post_send_single_response  r  z&BaseStrategy.post_send_single_responsec                 C   r  r  r  r  ri   ri   rj   post_send_search  r  zBaseStrategy.post_send_searchc                 C   r  r  r  r   ri   ri   rj   
get_stream     zBaseStrategy.get_streamc                 C   r  r  r  )rg   rJ  ri   ri   rj   
set_stream  r  zBaseStrategy.set_streamc                 C   s:   t | jdkr| j \}}|  t | jdksd S d S )Nr   )r   rc   popitemr  )rg   r  r  ri   ri   rj   unbind_referral_cache  s   z"BaseStrategy.unbind_referral_cache)TT)FFr  r   )T)"rf   
__module____qualname____doc__rk   rr   r   r}   r   r   r   r   r  staticmethodr  r-  r9  r)  r8  r   re  ry  r   r  r   r   r   r   r  r  r  r  r  r  ri   ri   ri   rj   r[   I   sF    

<
]

r
,3
 )D>r[   )xr  r   r   r   ImportErrorstructr   platformr   randomr   rH  r   r	   r
   r   r   r   r   r   core.resultsr   r   core.exceptionsr   r   r   r   r   r   r   r   r   r   r   r   r   r   	utils.urir    protocol.rfc4511r!   r"   r#   r$   operation.addr%   r&   operation.modifyr'   r(   operation.searchr)   r*   r+   r,   r-   r.   r/   r0   operation.bindr1   r2   r3   r4   r5   operation.comparer6   r7   operation.extendedr8   r9   r:   r;   r<   core.serverr=   operation.modifyDnr>   r?   operation.deleter@   rA   protocol.convertrB   rC   operation.abandonrD   core.tlsrE   protocol.oidrF   protocol.rfc2696rG   protocol.microsoftrH   	utils.logrI   rJ   rK   rL   rM   rN   rO   rP   
utils.asn1rQ   rR   rS   rT   
utils.convrU   protocol.sasl.digestMd5rV   rW   r   rY   r   objectr[   ri   ri   ri   rj   <module>   sN    (@((