%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /lib/python3/dist-packages/samba/__pycache__/
Upload File :
Create Path :
Current File : //lib/python3/dist-packages/samba/__pycache__/drs_utils.cpython-312.pyc

�

�I�dPO����ddlmZmZmZddlmZddlmZddlm	Z	ddlm
Z
ddlmZddlZddlZddl
mZmZmZddlZGd	�d
e�Zdd�Zd�Zd
�Zd�Zd�ZGd�de�ZGd�de�Zy)�)�drsuapi�misc�drsblobs)�Net)�
ndr_unpack)�dsdb)�werror)�WERRORErrorN)�DRSUAPI_ATTID_name�(DRSUAPI_SUPPORTED_EXTENSION_GETCHGREQ_V8�)DRSUAPI_SUPPORTED_EXTENSION_GETCHGREQ_V10c��eZdZdZd�Zd�Zy)�drsExceptionzBase element for drs errorsc��||_y�N��value)�selfrs  �1/usr/lib/python3/dist-packages/samba/drs_utils.py�__init__zdrsException.__init__%s	����
�c� �d|jzS)NzdrsException: r)rs r�__str__zdrsException.__str__(s���$�*�*�,�,rN)�__name__�
__module__�__qualname__�__doc__rr�rrrr"s��%��-rrc�
�d}|j�dk\r|dz
}|�|d|��z
}d|�d|�d�}n	d|�d|�d�}	tj|||�}t|�\}}|||fS#t$r}	t	d	|�d
|	����d}	~	wwxYw)a�Make a DRSUAPI connection to the server.

    :param server: the name of the server to connect to
    :param lp: a samba line parameter object
    :param creds: credential used for the connection
    :param ip: Forced target server name
    :return: A tuple with the drsuapi bind object, the drsuapi handle
                and the supported extensions.
    :raise drsException: if the connection fails
    �seal�	z,printNz,target_hostname=z
ncacn_ip_tcp:�[�]zDRS connection to z	 failed: )�	log_levelr�
drs_DsBind�	Exceptionr)
�server�lp�creds�ip�binding_options�binding_string�drsuapiBind�
drsuapiHandle�bindSupportedExtensions�es
          r�drsuapi_connectr1,s����O�	�|�|�~����8�#��
�~��.�v�h�7�7��(���A�o�->�a�@���39�/�J��L��o�o�n�b�%�@��3=�k�3J�0��/�
��(?�@�@���L����J�K�K��L�s�%A#�#	B�,A=�=Bc��tj�}||_tj�}||_||_t
j|�|_	|j|d|�y#t$r}td|z��d}~wwxYw)a�Send DS replica sync request.

    :param drsuapiBind: a drsuapi Bind object
    :param drsuapi_handle: a drsuapi handle on the drsuapi connection
    :param source_dsa_guid: the guid of the source dsa for the replication
    :param naming_context: the DN of the naming context to replicate
    :param req_options: replication options for the DsReplicaSync call
    :raise drsException: if any error occur while sending and receiving the
        reply for the dsReplicaSync
    �zDsReplicaSync failed %sN)r�DsReplicaObjectIdentifier�dn�DsReplicaSyncRequest1�naming_context�optionsr�GUID�source_dsa_guid�
DsReplicaSyncr&r)r-�drsuapi_handler:r7�
req_option�nc�req1�estrs        r�sendDsReplicaSyncrALs��
�	*�	*�	,�B��B�E��(�(�*�D��D���D�L��9�9�_�5�D��=��!�!�.�!�T�:���=��4�t�;�<�<��=�s�A-�-	B	�6B�B	c��
�tj�}d|_tj�|_|jxj
tjzc_|jxj
tjzc_|jxj
tjzc_|jxj
tjzc_|jxj
tjzc_|jxj
tjzc_|jxj
tjzc_|jxj
tjzc_|jxj
tjzc_|jxj
tjzc_|jxj
tj zc_|jxj
tj"zc_|jxj
tj$zc_|jxj
tj&zc_|jxj
tj(zc_|jxj
tj*zc_|jxj
tj,zc_|jxj
tj.zc_|jxj
tj0zc_|jxj
tj2zc_|jxj
tj4zc_|jxj
tj6zc_|jxj
tj8zc_|jxj
tj:zc_|jxj
tj<zc_|jxj
tj>zc_|jxj
tj@zc_|jxj
tjBzc_|jEtGjHtjJ�|�\}}||jj
fS)z0make a DsBind call, returning the binding handle�)&r�
DsBindInfoCtr�length�DsBindInfo28�info�supported_extensions� DRSUAPI_SUPPORTED_EXTENSION_BASE�-DRSUAPI_SUPPORTED_EXTENSION_ASYNC_REPLICATION�%DRSUAPI_SUPPORTED_EXTENSION_REMOVEAPI�&DRSUAPI_SUPPORTED_EXTENSION_MOVEREQ_V2�+DRSUAPI_SUPPORTED_EXTENSION_GETCHG_COMPRESS�%DRSUAPI_SUPPORTED_EXTENSION_DCINFO_V1�4DRSUAPI_SUPPORTED_EXTENSION_RESTORE_USN_OPTIMIZATION�'DRSUAPI_SUPPORTED_EXTENSION_KCC_EXECUTE�'DRSUAPI_SUPPORTED_EXTENSION_ADDENTRY_V2�4DRSUAPI_SUPPORTED_EXTENSION_LINKED_VALUE_REPLICATION�%DRSUAPI_SUPPORTED_EXTENSION_DCINFO_V2�8DRSUAPI_SUPPORTED_EXTENSION_INSTANCE_TYPE_NOT_REQ_ON_MOD�'DRSUAPI_SUPPORTED_EXTENSION_CRYPTO_BIND�)DRSUAPI_SUPPORTED_EXTENSION_GET_REPL_INFO�-DRSUAPI_SUPPORTED_EXTENSION_STRONG_ENCRYPTION�&DRSUAPI_SUPPORTED_EXTENSION_DCINFO_V01�1DRSUAPI_SUPPORTED_EXTENSION_TRANSITIVE_MEMBERSHIP�+DRSUAPI_SUPPORTED_EXTENSION_ADD_SID_HISTORY�&DRSUAPI_SUPPORTED_EXTENSION_POST_BETA3�,DRSUAPI_SUPPORTED_EXTENSION_GET_MEMBERSHIPS2�(DRSUAPI_SUPPORTED_EXTENSION_GETCHGREQ_V6�)DRSUAPI_SUPPORTED_EXTENSION_NONDOMAIN_NCSr�*DRSUAPI_SUPPORTED_EXTENSION_GETCHGREPLY_V5�*DRSUAPI_SUPPORTED_EXTENSION_GETCHGREPLY_V6�,DRSUAPI_SUPPORTED_EXTENSION_ADDENTRYREPLY_V3�*DRSUAPI_SUPPORTED_EXTENSION_GETCHGREPLY_V7�)DRSUAPI_SUPPORTED_EXTENSION_VERIFY_OBJECT�DsBindrr9�DRSUAPI_DS_BIND_GUID)�drs�	bind_inforG�handles    rr%r%gsT���%�%�'�I��I���)�)�+�I�N�
�N�N�'�'�7�+S�+S�S�'�
�N�N�'�'�7�+`�+`�`�'�
�N�N�'�'�7�+X�+X�X�'�
�N�N�'�'�7�+Y�+Y�Y�'�
�N�N�'�'�7�+^�+^�^�'�
�N�N�'�'�7�+X�+X�X�'�
�N�N�'�'�7�+g�+g�g�'�
�N�N�'�'�7�+Z�+Z�Z�'�
�N�N�'�'�7�+Z�+Z�Z�'�
�N�N�'�'�7�+g�+g�g�'�
�N�N�'�'�7�+X�+X�X�'�
�N�N�'�'�7�+k�+k�k�'�
�N�N�'�'�7�+Z�+Z�Z�'�
�N�N�'�'�7�+\�+\�\�'�
�N�N�'�'�7�+`�+`�`�'�
�N�N�'�'�7�+Y�+Y�Y�'�
�N�N�'�'�7�+d�+d�d�'�
�N�N�'�'�7�+^�+^�^�'�
�N�N�'�'�7�+Y�+Y�Y�'�
�N�N�'�'�7�+_�+_�_�'�
�N�N�'�'�7�+[�+[�[�'�
�N�N�'�'�7�+\�+\�\�'�
�N�N�'�'�7�+[�+[�[�'�
�N�N�'�'�7�+]�+]�]�'�
�N�N�'�'�7�+]�+]�]�'�
�N�N�'�'�7�+_�+_�_�'�
�N�N�'�'�7�+]�+]�]�'�
�N�N�'�'�7�+\�+\�\�'��Z�Z��	�	�'�*F�*F� G��S�N�T�6��D�I�I�2�2�3�3rc��tj�}d|_g}|j�}|j	|t
jdgd���}|D]�}t|dd�}d|vrJ|dd}t|�tjjtjjzzr�bd|vr/|dd}t|�tjjzr��|j|�}	|jt|	����|j!�||_t%|�|_|S)	z-get a list of attributes for RODC replicationr3zobjectClass=attributeSchema)�lDAPDisplayName�systemFlags�searchFlags)�base�scope�
expression�attrsrjrrkrl)r�DsPartialAttributeSet�version�get_schema_basedn�search�ldb�
SCOPE_SUBTREE�str�int�sambar�DS_FLAG_ATTR_NOT_REPLICATED�DS_FLAG_ATTR_IS_CONSTRUCTED�SEARCH_FLAG_RODC_ATTRIBUTE�get_attid_from_lDAPDisplayName�append�sort�attids�len�
num_attids)
�samdb�partial_attribute_setr��	schema_dn�res�r�ldap_display_name�system_flags�search_flags�attids
          r�"drs_get_rodc_partial_attribute_setr��s;��#�9�9�;��$%��!�
�F�
�'�'�)�I�
�,�,�I�S�->�->�"?�-��.�C�
�"����"3� 4�Q� 7�8���A�� !�-� 0�� 3�L��L�!�U�Z�Z�%K�%K�%*�Z�Z�%K�%K�&L�M���A���]�+�A�.�L��L�!�E�J�J�$I�$I�I���4�4�5F�G���
�
�c�%�j�!�"� �K�K�M�+1�� �'*�6�{��$� � rc�j�|j|_|j|_|j|_y)z�
    Copies the highwater mark by value, rather than by object reference. (This
    avoids lingering talloc references to old GetNCChanges reply messages).
    N)�tmp_highest_usn�reserved_usn�highest_usn)�hwm�new_hwms  r�drs_copy_highwater_markr��s-��
"�1�1�C���+�+�C���)�)�C�Orc�b�eZdZdZd�Zd�Zed��Zd�Zd�Z	de
jddd	dd
fd�Zy)�
drs_ReplicatezDRS replication callsc��tj|||�|_t|j�\|_|_t||��|_||_t|tj�std��|tjd�k(rtd��|jj|j||j|�|_
d|_y)N)r)r(z"Must supply GUID for invocation_id�$00000000-0000-0000-0000-000000000000zGMust not set GUID 00000000-0000-0000-0000-000000000000 as invocation_idr)rrfr%�
drs_handle�supports_extr�netr��
isinstancerr9�RuntimeError�replicate_init�replication_state�
more_flags)rr,r(r)r��
invocation_ids      rrzdrs_Replicate.__init__�s����?�?�>�2�u�=���/9�$�(�(�/C�,���$�+��U�r�*�����
��-����3��C�D�D��D�I�I�&L�M�M��h�i�i�!%���!8�!8����R����S`�!a�����rc��|j}|tjk(xr+|tzxr |jt
jzdk(S�Nr)r�r	�WERR_DS_DRA_RECYCLED_TARGETr
r�r�DRSUAPI_DRS_GET_TGT)r�
error_code�reqr�s    r�_should_retry_with_get_tgtz(drs_Replicate._should_retry_with_get_tgt�sO��
�(�(���f�@�@�@�D��H�H�D����'�"=�"=�=�!�C�	Erc�l�|tjk(xr |jtjzdk7Sr�)r	�WERR_DS_DRA_MISSING_PARENT�
replica_flagsr�DRSUAPI_DRS_GET_ANC)r�r�s  r�%_should_calculate_missing_anc_locallyz3drs_Replicate._should_calculate_missing_anc_locally�s7���v�@�@�@�G��"�"�W�%@�%@�@�Q�F�	Hrc�R�t�|_|j}	|�y|jjt	|j
jj��|j��|jtjd�k7r�t	|j�|jvrjtj|j|j
jj�}|j�}t!d|�d|j�d��|j"}��)Nr�zObject z with GUID z) was not sent by the server in this chunk)�set�
guids_seen�first_object�addrw�object�
identifier�guid�parent_object_guidrr9ru�Dnr�r5�parent�print�next_object)r�ctr�object_to_check�obj_dn�	parent_dns     r�_calculate_missing_anc_locallyz,drs_Replicate._calculate_missing_anc_locally�s����%���
�*�*����&���O�O����O�$:�$:�$E�$E�$J�$J� K�L��1�1�=�"�5�5��)�)�B�C�D���9�9�:�$�/�/�Q�����
�
�O�,B�,B�,M�,M�,P�,P�Q��"�M�M�O�	���	�{�+�-�@�@�A�BA�A�B�.�9�9�O�!rc�Z�|jj|j|||||��y)�5Processes a single chunk of received replication data)�schema�	req_levelr�N)r��replicate_chunkr�)r�levelr�r�r�r��first_chunks       r�
process_chunkzdrs_Replicate.process_chunk�s/��	
��� � ��!7�!7���(.�)��	!�	NrFNTrc	�
�|jtzr+tj�}|
|jz|_d}nd}tj
�}||_||_tj�|_	||j_
d}
tj�}d|_d|_
d|_|�sS|jj!|t"j$dg��}d|dvrW|ddD]L}t't(j*|�}|j,j|k(s�7|j,j.}�Ntj0�}
d|
_d|
_d|
_g}t9j:|j|jj=��}|D]I}tj>�}|j|_|j|_|jA|��K||
_!tE|�|
_#||_|
|_$|�||_%n�|tjLk(rd|_%n�tjNtjPztjRztjTztjVz|_%|r$|xjJtjXzc_%n#|xjJtjZzc_%|	r#|xjJtj\zc_%d|_/d	|_0||_1d|_2d|_3d|_4d|jj_6d|jj_7|s|rtq|j�|_3|jtrzsHd
}tjt�}tw|�D]"}|ddk7s�ty||t{||���$|}d}d}d}	|j|j|j�||�\}}|j��'|j�dk7rt�d
|j�z��	|j�||||||�d}||j�z
}	||j�z
}|j�dk(r	||fSt�|j.|j����#t�$r�}|j�|j�d|�r6t�d�|xjtj�zc_d}Yd}~��)|j�|j�d|�rt�d�|j�|�|�d}~wwxYw#t�$rY��wxYw)zreplicate a single DN�
�Nr�repsFrom)rmrnrpr3i�i�"��_Tz6DsGetNCChanges: NULL first_object with object_count=%uz1Missing target object - retrying with DRS_GET_TGTz;Missing parent object - calculating missing objects locallyF)Qr�r
r�DsGetNCChangesRequest10r��DsGetNCChangesRequest8�destination_dsa_guid�source_dsa_invocation_idr4r7r5�DsReplicaHighWaterMarkr�r�r�r�rtru�
SCOPE_BASErr�repsFromToBlobr��
highwatermark�DsReplicaCursorCtrExrr�	reserved1�	reserved2r�_dsdb_load_udv_v2�get_default_basedn�DsReplicaCursorr~�cursorsr��count�uptodateness_vectorr��DRSUAPI_EXOP_REPL_SECRET�DRSUAPI_DRS_INIT_SYNC�DRSUAPI_DRS_PER_SYNCr��DRSUAPI_DRS_NEVER_SYNCED�$DRSUAPI_DRS_GET_ALL_GROUP_MEMBERSHIP�%DRSUAPI_DRS_SPECIAL_SECRET_PROCESSING�DRSUAPI_DRS_WRIT_REP�DRSUAPI_DRS_SYNC_FORCED�max_object_count�max_ndr_size�extended_op�	fsmo_infor��partial_attribute_set_ex�mapping_ctr�num_mappings�mappingsr�r�DsGetNCChangesRequest5�dir�setattr�getattrrf�DsGetNCChangesr�r��object_countr�r�r
r��argsr�r�r�r��linked_attributes_count�AttributeError�	more_datar��new_highwatermark)rr5r�r�r��exop�rodcr��	full_sync�sync_forcedr�r�r��udvr�r��reps_from_packed�
reps_from_obj�
cursors_v1�
cursors_v2�	cursor_v2�	cursor_v1�req5�a�num_objects�	num_linksr�r�r�r0s                              r�	replicatezdrs_Replicate.replicates������H�H��1�1�3�C�(�4�?�?�:�C�N��I��I��0�0�2�C�#7�� �'?��$�$�>�>�@��� "��������,�,�.�������������*�*�#�#��3�>�>�+5�,�$�8�C��S��V�#�(+�A��z�(:�>�$�$.�x�/F�/F�HX�$Y�M�$�(�(�A�A�E]�]�+�/�/�=�=��>�
�.�.�0�C��C�K��C�M��C�M��J��/�/��
�
�04�
�
�0M�0M�0O�Q�J�'�
-�	�#�3�3�5�	�5>�5W�5W�	�2�(1�(=�(=�	�%��!�!�)�,�	
-�%�C�K��J��C�I����"%����$� -�C��
�W�5�5�
5� !�C��!(�!>�!>�!(�!=�!=�">�!(�!<�!<�"=�")�!A�!A�"B�")�!M�!M�	"N�C��
��!�!��B�B�D�!��!�!�W�%A�%A�A�!������!@�!@�@��"���!��������
�$(��!�'+��$�'(����$�#'���� ��$�(J�4�:�:�(V�C�%�� � �#K�K��I��1�1�3�D���Y�
6���Q�4�3�;��D�!�W�S�!�_�5�
6��C����	�����8�8�2�2�4�?�?�I�s�S�L�U�C����'�C�,<�,<��,A�"�#[�_b�_o�_o�#p�q�q�
��"�"�5�#�v�y�#�{�S�( �K��3�+�+�+�K�
��S�8�8�8�	��}�}��!��
�Y�'�'�
$�C�$5�$5�s�7L�7L�M�O���
��2�2�1�6�6�!�9�c�B��M�N��N�N�g�&A�&A�A�N�#'�K���=�=�a�f�f�Q�i�>A�C��W�X��7�7��<����#
��2"�
��
�s1�2R�U�	T>�'AT9�<=T9�9T>�	U
�U
)
rrrrrr��staticmethodr�r�r�r�DRSUAPI_EXOP_NONErrrrr�r��sP���
�	E��H��H�:�6N��W�%>�%>�U� $��%�TU�K(rr�c�>��eZdZdZ�fd�Zd�Zd�Zd�Z�fd�Z�xZ	S)�drs_ReplicateRenamerz,Uses DRS replication to rename the entire DBc�z��tt|�|||||�||_||_t
j|_yr)�superrr�old_base_dn�new_base_dnrr�r�)	rr,r(r)r�r�rr�	__class__s	        �rrzdrs_ReplicateRenamer.__init__�s>���
�"�D�2�>�2�u�38�-�	I�&���&���"�5�5��rc�^�tjd|jz|j|�S)z/Uses string substitution to replace the base DNz%s$)�re�subrr)r�dn_strs  r�	rename_dnzdrs_ReplicateRenamer.rename_dn�s&���v�v�e�d�.�.�.��0@�0@�&�I�Irc�D�|jjD]�}|jtk(s�t	j
|j|jj�}|j�}|jd�|jjd_
��y)z3Updates the 'name' attribute for the base DN objectz	utf-16-lerN)�
attribute_ctr�
attributesr�rrur�r�r�r5�
get_rdn_value�encode�	value_ctr�values�blob)r�base_obj�attr�base_dn�new_names     r�update_name_attrz%drs_ReplicateRenamer.update_name_attr�sz���*�*�5�5�	M�D��z�z�/�/��&�&����X�-@�-@�-C�-C�D��"�0�0�2��08����0L����%�%�a�(�-�		Mrc�L�|jj}|j|jj�|j_td|�d|jj���|jj|jk(r|j|�yy)z1Renames the first/top-level object in a partitionzRenaming partition z --> N)r�r5rr�rr#)r�	first_obj�old_dns   r�rename_top_level_objectz,drs_ReplicateRenamer.rename_top_level_object�s����%�%�(�(��"&�.�.��1E�1E�1H�1H�"I�	����
��09�0D�0D�0G�0G�I�	J�
���"�"�d�&6�&6�6��!�!�)�,�7rc�"��|jr4|j|jj�|j_|r4|jdk7r%|j	|j
j�tt|�'||||||�y)r�rN)
r7rr5r�r'r�r�rrr�)rr�r�r�r�r�r�rs       �rr�z"drs_ReplicateRenamer.process_chunk�s~���
���$(�N�N�3�3E�3E�3H�3H�$I�C���!��3�+�+�q�0��(�(��)9�)9�)@�)@�A�	�"�D�7��s�F�8A�3�8C�	Er)
rrrrrrr#r'r��
__classcell__)rs@rrr�s(���6�6�J�M�
-�E�Errr)�samba.dcerpcrrr�	samba.netr�	samba.ndrrryrr	r
ru�samba.dcerpc.drsuapirrr
rr&rr1rAr%r�r�r�r�rrrr�<module>r.sy��(1�0�� �����
�M�M�
�-�9�-�A�@=�6#4�L#!�L*�Q(�F�Q(�l8E�=�8Er

Zerion Mini Shell 1.0