HEX
Server: LiteSpeed
System: Linux shams.tasjeel.ae 5.14.0-611.5.1.el9_7.x86_64 #1 SMP PREEMPT_DYNAMIC Tue Nov 11 08:09:09 EST 2025 x86_64
User: infowars (1469)
PHP: 8.2.29
Disabled: NONE
Upload Files
File: //proc/self/root/lib64/python3.9/site-packages/ldap/__pycache__/syncrepl.cpython-39.opt-1.pyc
a

�.d�H�@s�dZddlmZddlmZmZmZmZmZddl	m
Z
mZddlm
Z
mZmZddlmZmZmZdgZGdd	�d	ej�ZGd
d�dej�ZGdd
�d
ej�ZGdd�dej�ZGdd�de�ZGdd�dej�ZGdd�dej�ZGdd�de�Zeeej <Gdd�dej�Z!Gdd�de�Z"e"ee"j <Gdd�dej�Z#Gdd�dej�Z$Gd d!�d!ej%�Z&Gd"d#�d#ej�Z'Gd$d%�d%ej(�Z)Gd&d'�d'�Z*Gd(d�d�Z+d)S)*zz
ldap.syncrepl - for implementing syncrepl consumer (see RFC 4533)

See https://www.python-ldap.org/ for project details.
�)�UUID)�tag�	namedtype�namedval�univ�
constraint)�encoder�decoder)�__version__�
__author__�__license__)�RequestControl�ResponseControl�KNOWN_RESPONSE_CONTROLS�SyncreplConsumerc@seZdZdZe�dd�ZdS)�SyncUUIDz.
    syncUUID ::= OCTET STRING (SIZE(16))
    �N)�__name__�
__module__�__qualname__�__doc__rZValueSizeConstraint�subtypeSpec�rr�3/usr/lib64/python3.9/site-packages/ldap/syncrepl.pyrsrc@seZdZdZdS)�
SyncCookiez%
    syncCookie ::= OCTET STRING
    N)rrrrrrrrrsrc@s0eZdZdZe�dd�Zejj	e
�dd�Z	dS)�SyncRequestModez�
           mode ENUMERATED {
               -- 0 unused
               refreshOnly       (1),
               -- 2 reserved
               refreshAndPersist (3)
           },
    )�refreshOnly�)ZrefreshAndPersist�rrN�rrrrrZNamedValuesZnamedValuesr�
EnumeratedrrZSingleValueConstraintrrrrr"s�rc
@s@eZdZdZe�e�de��e�de	��e�
de�d���Z
dS)�SyncRequestValuea:
       syncRequestValue ::= SEQUENCE {
           mode ENUMERATED {
               -- 0 unused
               refreshOnly       (1),
               -- 2 reserved
               refreshAndPersist (3)
           },
           cookie     syncCookie OPTIONAL,
           reloadHint BOOLEAN DEFAULT FALSE
       }
    �mode�cookie�
reloadHintFN)rrrrr�
NamedTypes�	NamedTyper�OptionalNamedTyper�DefaultedNamedTyper�Boolean�
componentTyperrrrr!2s�r!c@s&eZdZdZdZddd�Zd	d
�ZdS)�SyncRequestControlan
    The Sync Request Control is an LDAP Control [RFC4511] where the
    controlType is the object identifier 1.3.6.1.4.1.4203.1.9.1.1 and the
    controlValue, an OCTET STRING, contains a BER-encoded
    syncRequestValue.  The criticality field is either TRUE or FALSE.
    [..]
    The Sync Request Control is only applicable to the SearchRequest
    Message.
    z1.3.6.1.4.1.4203.1.9.1.1rNrFcCs||_||_||_||_dS)N)�criticalityr#r"r$)�selfr,r#r"r$rrr�__init__RszSyncRequestControl.__init__cCsXt�}|�dt|j��|jdur4|�dt|j��|jrN|�dt�|j��t	�
|�S)Nr"r#r$)r!ZsetComponentByNamerr"r#rr$rr)r�encode)r-Zrcvrrr�encodeControlValueXs
z%SyncRequestControl.encodeControlValue)rNrF)rrrr�controlTyper.r0rrrrr+Fs	
r+c@s8eZdZdZe�dddd�Zejj	e
�dddd	�Z	d
S)�SyncStateOpz�
           state ENUMERATED {
               present (0),
               add (1),
               modify (2),
               delete (3)
           },
    )�presentr)�addr)�modify�)�deleterrrr6rNrrrrrr2bs�r2c@s<eZdZdZe�e�de��e�de��e�	de
���ZdS)�SyncStateValuea
       syncStateValue ::= SEQUENCE {
           state ENUMERATED {
               present (0),
               add (1),
               modify (2),
               delete (3)
           },
           entryUUID syncUUID,
           cookie    syncCookie OPTIONAL
       }
    �state�	entryUUIDr#N)rrrrrr%r&r2rr'rr*rrrrr8ts�r8c@s eZdZdZdZdZdd�ZdS)�SyncStateControlam
    The Sync State Control is an LDAP Control [RFC4511] where the
    controlType is the object identifier 1.3.6.1.4.1.4203.1.9.1.2 and the
    controlValue, an OCTET STRING, contains a BER-encoded SyncStateValue.
    The criticality is FALSE.
    [..]
    The Sync State Control is only applicable to SearchResultEntry and
    SearchResultReference Messages.
    z1.3.6.1.4.1.4203.1.9.1.2)r3r4r5r7cCs�tj|t�d�}|d�d�}tt|d�d��d�}|d�d�}|dur`|��r`t|�|_nd|_|j	j
t|�|_t|�|_
dS)N�Zasn1Specrr9r:��bytesr#)r	�decoder8�getComponentByNamerr>�hasValue�strr#�	__class__�opnames�intr9r:)r-�encodedControlValue�dr9�uuidr#rrr�decodeControlValue�sz#SyncStateControl.decodeControlValueN)rrrrr1rDrIrrrrr;�s	r;c	@s4eZdZdZe�e�de��e�de	�
d���ZdS)�
SyncDoneValuez�
       syncDoneValue ::= SEQUENCE {
           cookie          syncCookie OPTIONAL,
           refreshDeletes  BOOLEAN DEFAULT FALSE
       }
    r#�refreshDeletesFN�rrrrrr%r'rr(rr)r*rrrrrJ�s
�rJc@seZdZdZdZdd�ZdS)�SyncDoneControlaT
    The Sync Done Control is an LDAP Control [RFC4511] where the
    controlType is the object identifier 1.3.6.1.4.1.4203.1.9.1.3 and the
    controlValue contains a BER-encoded syncDoneValue.  The criticality
    is FALSE (and hence absent).
    [..]
    The Sync Done Control is only applicable to the SearchResultDone
    Message.
    z1.3.6.1.4.1.4203.1.9.1.3cCsdtj|t�d�}|d�d�}|��r2t|�|_nd|_|d�d�}|��rZt|�|_nd|_dS)Nr<rr#rK)	r	r?rJr@rArBr#�boolrK)r-rFrGr#Zrefresh_deletesrrrrI�sz"SyncDoneControl.decodeControlValueN)rrrrr1rIrrrrrM�s	rMc	@s4eZdZdZe�e�de��e�de	�
d���ZdS)�
RefreshDeletez�
           refreshDelete  [1] SEQUENCE {
               cookie         syncCookie OPTIONAL,
               refreshDone    BOOLEAN DEFAULT TRUE
           },
    r#�refreshDoneTNrLrrrrrO�s
�rOc	@s4eZdZdZe�e�de��e�de	�
d���ZdS)�RefreshPresentz�
           refreshPresent [2] SEQUENCE {
               cookie         syncCookie OPTIONAL,
               refreshDone    BOOLEAN DEFAULT TRUE
           },
    r#rPTNrLrrrrrQ�s
�rQc@seZdZdZe�ZdS)�	SyncUUIDsz(
    syncUUIDs      SET OF syncUUID
    N)rrrrrr*rrrrrR�srRc	@s@eZdZdZe�e�de��e�de	�
d��e�de���Z
dS)�	SyncIdSetz�
     syncIdSet      [3] SEQUENCE {
         cookie         syncCookie OPTIONAL,
         refreshDeletes BOOLEAN DEFAULT FALSE,
         syncUUIDs      SET OF syncUUID
     }
    r#rKF�	syncUUIDsN)rrrrrr%r'rr(rr)r&rRr*rrrrrS�s�rSc@s�eZdZdZe�e�de�je	�
e	je	jd�d��e�de
�je	�
e	je	jd�d��e�de�je	�
e	je	jd�d��e�d	e�je	�
e	je	jd
�d���ZdS)�
SyncInfoValuea`
       syncInfoValue ::= CHOICE {
           newcookie      [0] syncCookie,
           refreshDelete  [1] SEQUENCE {
               cookie         syncCookie OPTIONAL,
               refreshDone    BOOLEAN DEFAULT TRUE
           },
           refreshPresent [2] SEQUENCE {
               cookie         syncCookie OPTIONAL,
               refreshDone    BOOLEAN DEFAULT TRUE
           },
           syncIdSet      [3] SEQUENCE {
               cookie         syncCookie OPTIONAL,
               refreshDeletes BOOLEAN DEFAULT FALSE,
               syncUUIDs      SET OF syncUUID
           }
       }
    �	newcookier)ZimplicitTag�
refreshDeleter�refreshPresentr6�	syncIdSetrN)rrrrrr%r&rZsubtyperZTagZtagClassContextZtagFormatSimplerOrQrSr*rrrrrU�s6���������rUc@seZdZdZdZdd�ZdS)�SyncInfoMessagea	
    The Sync Info Message is an LDAP Intermediate Response Message
    [RFC4511] where responseName is the object identifier
    1.3.6.1.4.1.4203.1.9.1.4 and responseValue contains a BER-encoded
    syncInfoValue.  The criticality is FALSE (and hence absent).
    z1.3.6.1.4.1.4203.1.9.1.4cCs tj|t�d�}d|_d|_d|_d|_|d��}|d��}|du�r|�	��r|dkrjt
|�|_dSi}|�d�}|�	�r�t
|�|d<|�d�r�t
|�d��|d<nf|dk�rg}|�d�}tt|��D]&}	tt|�|	��d	�}
|�t
|
��q�||d<t
|�d
��|d
<t|||�dS)Nr<rrVr#ZrefreshrPrYrTr=rK)r	r?rUrVrWrXrY�getNameZgetComponentrArBr@�
startswithrN�range�lenrr>ZgetComponentByPosition�append�setattr)r-ZencodedMessagerG�attr�comp�valr#�uuidsZids�irHrrrr.5s4




zSyncInfoMessage.__init__N)rrrr�responseNamer.rrrrrZ,srZc@sVeZdZdZddd�Zddd	�Zd
d�Zdd
�Zddd�Zdd�Z	dd�Z
dd�ZdS)rz;
    SyncreplConsumer - LDAP syncrepl consumer object.
    rNcKs\|dur|��}t||d�}d|vr8|d|g7<n
|g|d<d|_|j||fi|��S)a�
        Starts syncrepl search operation.

        base, scope, and search_args are passed along to
        self.search_ext unmodified (aside from adding a Sync
        Request control to any serverctrls provided).

        mode provides syncrepl mode. Can be 'refreshOnly'
        to finish after synchronization, or
        'refreshAndPersist' to persist (continue to
        receive updates) after synchronization.

        cookie: an opaque value representing the replication
        state of the client.  Subclasses should override
        the syncrepl_set_cookie() and syncrepl_get_cookie()
        methods to store the cookie appropriately, rather than
        passing it.

        Only a single syncrepl search may be active on a SyncreplConsumer
        object.  Multiple concurrent syncrepl searches require multiple
        separate SyncreplConsumer objects and thus multiple connections
        (LDAPObject instances).
        N)r#r"ZserverctrlsF)�syncrepl_get_cookier+�_SyncreplConsumer__refreshDoneZ
search_ext)r-�baseZscoper"r#Zsearch_argsZsyncreqrrr�syncrepl_search`s
z SyncreplConsumer.syncrepl_search���rcCs�|j||dddd�\}}}}}}	|dkrj|D]8}
|
jjdkr>q,|jd|
jd�|
jdur,|�|
j�q,dS|d	k�r|D]�}|\}}
}|D]�}
|
jjd
kr�q�|
jdkr�|�|
jg�nB|
jdkr�|�	|
jg�n(|�
||
|
j�|jdur�|�|
jg�|
jdu�r|�|
j�qxq�qx�nR|d
k�rn|D�]@}|\}}}|tj
k�rJ�q*t|�}|jdu�rl|�|j�n�|jdu�r�|jddd�d|jv�r�|�|jd�|jd�rjd|_|��n�|jdu�r|jddd�d|jv�r�|�|jd�|jd�rjd|_|��nZ|jdu�r*|jddu�r>|�	|jd�n|�|jd�d|jv�r*|�|jd��q*|dkrdSqdS)a�
        polls for and processes responses to the syncrepl_search() operation.
        Returns False when operation finishes, True if it is in progress, or
        raises an exception on error.

        If timeout is specified, raises ldap.TIMEOUT in the event of a timeout.

        If all is set to a nonzero value, poll() will return only when finished
        or when an exception is raised.

        rr)�msgid�timeoutZadd_intermediatesZ	add_ctrls�all�erMN)rKF�dr;r3r7�yr#rPTrKrT)Zresult4rCr�syncrepl_presentrKr#�syncrepl_set_cookier9r:�syncrepl_delete�syncrepl_entryrhrZrfrVrX�syncrepl_refreshdonerWrY)r-rlrmrn�type�msgZmidZctrls�n�v�c�m�dn�attrsZrnameZrespZsimrrr�
syncrepl_poll�sz
�










zSyncreplConsumer.syncrepl_pollcCsdS)zY
        Called by syncrepl_poll() to store a new cookie provided by the server.
        Nr)r-r#rrrrs�sz$SyncreplConsumer.syncrepl_set_cookiecCsdS)zd
        Called by syncrepl_search() to retrieve the cookie stored by syncrepl_set_cookie()
        Nr�r-rrrrg�sz$SyncreplConsumer.syncrepl_get_cookieFcCsdS)aF
        Called by syncrepl_poll() whenever entry UUIDs are presented to the client.
        syncrepl_present() is given a list of entry UUIDs (uuids) and a flag
        (refreshDeletes) which indicates whether the server explicitly deleted
        non-present entries during the refresh operation.

        If called with a list of uuids, the syncrepl_present() implementation
        should record those uuids as present in the directory.

        If called with uuids set to None and refreshDeletes set to False,
        syncrepl_present() should delete all non-present entries from the local
        mirror, and reset the list of recorded uuids.

        If called with uuids set to None and refreshDeletes set to True,
        syncrepl_present() should reset the list of recorded uuids, without
        deleting any entries.
        Nr)r-rdrKrrrrr�sz!SyncreplConsumer.syncrepl_presentcCsdS)z�
        Called by syncrepl_poll() to delete entries. A list
        of UUIDs of the entries to be deleted is given in the
        uuids parameter.
        Nr)r-rdrrrrt�sz SyncreplConsumer.syncrepl_deletecCsdS)z�
        Called by syncrepl_poll() for any added or modified entries.

        The provided uuid is used to identify the provided entry in
        any future modification (including dn modification), deletion,
        and presentation operations.
        Nr)r-r}r~rHrrrruszSyncreplConsumer.syncrepl_entrycCsdS)z�
        Called by syncrepl_poll() between refresh and persist phase.

        It indicates that initial synchronization is done and persist phase
        follows.
        Nrr�rrrrvsz%SyncreplConsumer.syncrepl_refreshdone)rN)rkNr)F)rrrrrjrrsrgrrrtrurvrrrrr[s
%
Z

N),rrHrZpyasn1.typerrrrrZpyasn1.codec.berrr	Zldap.pkginfor
rrZ
ldap.controlsr
rr�__all__ZOctetStringrrr r�Sequencer!r+r2r8r;r1rJrMrOrQZSetOfrRrSZChoicerUrZrrrrr�<module>s4�




//