%PDF- %PDF-
Mini Shell

Mini Shell

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

�

�f�5���ddlZddlZddlZddlZddlZddlmZddlm	Z	ddl
mZmZm
Z
ddlmZddlmZddlmZGd�d�ZGd	�d
e�Zy)�N)�system_session)�Command�CommandError�Option)�get_fsmo_roleowner)�
setup_path)�SamDBc�"�eZdZdZd�Zd�Zd�Zy)�ldif_schema_updatez-Helper class for applying LDIF schema updatesc�<�d|_d|_d|_d|_y)NF�)�
is_defunct�unknown_oid�dn�ldif)�selfs �C/usr/lib/python3/dist-packages/samba/netcmd/domain/schemaupgrade.py�__init__zldif_schema_update.__init__*s�������������	�c��|j\}}|tjk(r%|jrt	d|j
z�y|j�&t	d|j�d|j
���yy)z>Checks if we can safely ignore failure to apply an LDIF updatez)Defunct object %s doesn't exist, skippingTzSkipping unknown OID z for object F)�args�ldb�ERR_NO_SUCH_OBJECTr�printrr)r�error�num�errstrs    r�can_ignore_failurez%ldif_schema_update.can_ignore_failure0sc���
�
�
��f��#�(�(�(�T�_�_��=����G�H��
�
�
�
)��T�=M�=M�t�w�w�W�X��rc��		|j|jdg��y	#tj$rZ}|jdtj
k(r/|j
�|j|jdg��n�Yd}~y	d}~wwxYw#tj$rX}|j|�rYd}~ytd|z�td�td�td|jz��d}~wwxYw)
z*Applies a single LDIF update to the schemazrelax:0)�controlsrN�
Exception: %sz4Encountered while trying to apply the following LDIFz4----------------------------------------------------z%s�)	�modify_ldifrr�LdbErrorr�ERR_INVALID_ATTRIBUTE_SYNTAX�set_schema_update_nowrr)r�samdb�es   r�applyzldif_schema_update.apply>s���	�
��!�!�$�)�)�y�k�!�B�2��1�<�<�
��6�6�!�9�� @� @�@��/�/�1��%�%�d�i�i�9�+�%�F��G���1
���|�|�		��&�&�q�)���o��)�*��L�M��L�M��d�T�Y�Y�&�'���		�s9�"�B�AB
�B�
B�B�C=�%C8�;=C8�8C=N)�__name__�
__module__�__qualname__�__doc__rrr)�rrrr's��7���rrc��eZdZdZdZejejejd�Z	e
dddedd�	�e
d
ddd
��e
dddd
��e
dddgd�dd��e
dedd��e
dedd��gZd�Z
d �Zd!�Zy)"�cmd_domain_schema_upgradezDomain schema upgradingz%prog [options])�	sambaopts�versionopts�credoptsz-Hz--URLz%LDB URL for database or target server�URL�H)�help�type�metavar�destz-qz--quietzBe quiet�
store_true)r6�actionz-vz	--verbosez
Be verbosez--schema�choice�SCHEMA)�2012�2012_R2�2016�2019z9The schema file to upgrade to. Default is (Windows) 2019.rA)r7r8�choicesr6�defaultz
--ldf-fileNzBJust apply the schema updates in the adprep/.LDF file(s) specified)r7rCr6z
--base-dirz4Location of ldf files Default is ${SETUPDIR}/adprep.c	��d}t�}|D�]�}|j�}|dk(r/|jdk(r�)||j|�z
}t�}�H|j	�jd�r*|dt
d�t|j��z}nH|j	�jd�r)|dt
d�t|j��z}|jd�}|dj�dk(r|dj�|_|dj�d	k(r�|j�jd
d�}|j�jdd
�}|j�jdd�}|j�jdd�}|dj�dvrr|\}}d|vri|j|j�d|�d|�d�dg��}	t
|	�dk7r||_n)t|	ddd�}
|j|d|
z�}|dj�dk(r+|dj�j�dk(rd|_|dj�dk(r&|dj�j�dk(rd}|xj|d zz
c_���|S)!z�
        Applies a series of updates specified in an .LDIF file. The .LDIF file
        is based on the adprep Schema updates provided by Microsoft.
        rr
zDC=XNzCN=X�:rr"�
changetypez: ntdsschemaaddz: addz: ntdsschemamodifyz: modifyz: ntdsschemamodrdnz: modrdnz: ntdsschemadeletez: delete)�rdnattid�
subclassof�systemposssuperiors�systemmaycontain�systemauxiliaryclass�.z(|(attributeId=z)(governsId=z))�ldapDisplayName)�base�
expression�attrs� �	isdefunct�trueT�add�showinadvancedviewonlyzreplace: showInAdvancedViewOnly�
)r�rstriprr)�upper�endswith�len�str�get_default_basedn�split�lower�stripr�replace�search�get_schema_basednrr)rr'�	ldif_file�count�ldif_op�line�values�_�value�res�display_names           r�_apply_updates_in_filez0cmd_domain_schema_upgrade._apply_updates_in_fileys���
��$�&���J	(�D��;�;�=�D��r�z��<�<�2�%������u�-�-��-�.����z�z�|�$�$�V�,��M�c�&�k�\�*�S��1I�1I�1K�-L�L������&�&�v�.��M�c�&�k�\�*�S��1I�1I�1K�-L�L���Z�Z��_�F��a�y��� �D�(�#�A�Y�_�_�.��
��a�y��� �L�0��z�z�|�+�+�,=�,3�5���z�z�|�+�+�,@�,6�8���z�z�|�+�+�,@�,6�8���z�z�|�+�+�,@�,6�8���a�y��� �%=�=�"���5��%�<��,�,�E�,C�,C�,E�(-�u�36�.?�-@�'�B�C�
�3�x�1�}�.3��+�'*�3�q�6�2C�+D�Q�+G�'H��#�|�|�E�3��3E�F���a�y��� �K�/�F�1�I�O�O�4E�4K�4K�4M�QW�4W�%)��"��a�y��� �E�)�f�Q�i�o�o�.?�.E�.E�.G�Kc�.c�8��
�L�L�D�4�K�'�L�UJ	(�X�rc��td|z�d}	ttjj	||��}|j||�}|r|j
�	td|z�|S#|r|j
�wwxYw)zBWrapper function for parsing an LDIF file and applying the updateszApplying %s updates...Nz%u changes applied)r�open�os�path�joinrl�close)rr'�update_file�base_dirrcrds      r�
_apply_updatez'cmd_domain_schema_upgrade._apply_update�s��	�&��4�5��	�	"��R�W�W�\�\�(�K�@�A�I��/�/��y�A�E�����!�
�"�U�*�+��������!��s�;A0�0Bc�	�	ddlm}ddlm}d}|jd�}|jd�}|j�}|j|�}	|jd	�}
|jd
�}|jd�}|jd�}
d}t|
t�|	|�
�}|jd��|jdd�td�d}tj ||j#��}t%|t'|j)��d
�}||k7rtd��|r|j+d�}�n�g}|j-|�}|j/|j)�tj0dg��}t3|�dk7rtd��t5|ddd�dz}t7d�}|
�+t9j:�}t7d�}	|||�|}
tC||dz�D�]}d|z}|jE|�tFjHjKtFjHjM||dz��}|s�]tFjHjO|�s�}	tQjRd|d|gtPjTtPjT|� �}|j[�\}}|j\r1td"|�d#|���t?j@|�td��td$|�d%|�����|
�t7d&�}
|j_�d}d}	|D]} ||ja|| |
�z
}�|dkDr|jc�td'�ntd(�|je�|r|jdd+�|rt?j@|�|rtd��y#t$r.}|jj	d|z�td��d}~wwxYw#t<$r3}td|z�t?j@|�td��d}~wwxYw#tVtXf$r!t?j@|�td!��wxYw#t<$r6}td)|z�td*�|je�d}Yd}~��d}~wwxYw),Nr)�read_ms_markdownz$Exception in importing markdown: %s
zIFailed to import module markdown, please install python3-markdown package)�SchemaFr1r3r5�schema�ldf_filert)�url�session_info�credentials�lpzdsdb:schema update allowed�yesz;Temporarily overriding 'dsdb:schema update allowed' settingTz%This server is not the schema master.�,�
objectVersion)rN�scoperPr"z*Could not determine current schema versionzadprep/WindowsServerDocsz*adprep/WindowsServerDocs/Schema-Updates.mdz!Exception in markdown parsing: %szFailed to upgrade schemaz	Sch%d.ldfz.diff�patchz-i)�stdout�stderr�cwdz6Failed to upgrade schema. Is '/usr/bin/patch' missing?zException in patch: rVzPatched z using �adprepzSchema successfully updatedzNo changes applied to schemar!z*Error encountered, aborting schema upgrade�no)3�samba.ms_schema_markdownrw�ImportError�outf�writer�samba.schemarx�get�get_loadparm�get_credentialsr	r�setrr�Dn�get_dsServiceNamerr[rbr]�get_versionra�
SCOPE_BASErZ�intr�tempfile�mkdtemp�	Exception�shutil�rmtree�range�appendrorp�abspathrq�exists�
subprocess�Popen�PIPE�OSError�IOError�communicate�
returncode�transaction_startru�transaction_commit�transaction_cancel)!r�kwargsrwr(rx�updates_allowed_overriddenr1r3r~�credsr5�
target_schema�	ldf_filesrt�temp_folderr'�own_dn�master�schema_updates�endrj�start�diff_dirrs�version�update�diff�pr�r�rd�error_encounteredrcs!                                 r�runzcmd_domain_schema_upgrade.run�sy��	l�A�	(�%*�"��J�J�{�+�	��:�:�j�)��
�
#�
#�
%���(�(��,���J�J�s�O���
�
�8�,�
��J�J�z�*�	��:�:�j�)�����!�.�*:��RT�U���6�6�.�/�7��F�F�/��7��O�P�)-�&�����u�6�6�8�9��#�E�3�u�/F�/F�/H�+I�$,�.���V���F�G�G��&�_�_�S�1�N��N��$�$�]�3�C��,�,�E�$;�$;�$=�%(�^�^�O�;L��N�C��3�x�1�}�"�#O�P�P���A���/��2�3�a�7�E�!�"<�=�H���&�.�.�0��(�)U�V��C�$�[�+�>�'�� ���a��0�
B��$�w�.���%�%�f�-��w�w���r�w�w�|�|�H�f�w�>N�'O�P���2�7�7�>�>�$�#7�K�&�,�,�g�v�t�T�-J�4>�O�O�4>�O�O��V��&'�]�]�_�N�F�F��|�|��f�f�M�N��
�
�k�2�*�+E�F�F��6�4�@�A�/
B�2��!�(�+�H�
���!���!��	%�+�
H�	���+�+�E�9�h�G�G��
H��q�y��(�(�*��3�4��4�5��(�(�*�&��F�F�/��6���M�M�+�&���9�:�:���o�	l��I�I�O�O�C�a�G�H��j�k�k��	l��r!�C��=��A�B��M�M�+�.�&�'A�B�B��C��$$�W�-�K��
�
�k�2�*�,J�K�K�K��@�	%��/�A�%�&��>�?��$�$�&� $���		%�sT�O�.	P�9Q�AR�	P� )P	�	P�	Q
�.Q�Q
�0R�	S�+R=�=S)r*r+r,r-�synopsis�options�SambaOptions�VersionOptions�CredentialsOptions�takes_optiongroupsrr[�
takes_optionsrlrur�r.rrr0r0_s���!� �H��)�)��-�-��.�.���	�t�W�#J�QT��3�	(��t�Y�Z��E��t�[�|�L�I��z��(�:�O��	�	�|�#�t�X�	Z��|�#�t�J�	L�
�M�U�n�&{;rr0)ror�r�r�r�samba.getopt�getoptr��
samba.authr�samba.netcmdrrr�samba.netcmd.fsmor�samba.provisionr�samba.samdbr	rr0r.rr�<module>r�sD��2
�
���
��%�6�6�0�&��5�5�p;��;r

Zerion Mini Shell 1.0