%PDF- %PDF-
Mini Shell

Mini Shell

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

�

�I�d�Q����ddlZddlmZddlZddlmZddlmZmZddl	m
Z
ddlZddlm
Z
mZmZmZddlmZd�Zd�Zd	�ZGd
�de
�ZGd�d
e
�ZGd�de
�ZGd�de�Zy)�N)�LdbError)�drsuapi�misc)�system_session)�Command�CommandError�SuperCommand�Option)�SamDBc�D�	|j|tjdg��}d|dvr0tj||dddjd��}|Sd}|S#t$r6}|j\}}|tj
k(rt
d|z���d}~wwxYw)znGets the owner of an FSMO role

    :param roledn: The DN of the FSMO role
    :param role: The FSMO role
    �
fSMORoleOwner��scope�attrsz+The '%s' role is not present in this domainNr�utf8)	�search�ldb�
SCOPE_BASEr�args�ERR_NO_SUCH_OBJECTr�Dn�decode)�samdb�roledn�role�res�e7�num�msg�master_owners        �3/usr/lib/python3/dist-packages/samba/netcmd/fsmo.py�get_fsmo_roleownerr"$s�����l�l�6�!$����7H��J���#�a�&� ����u�c�!�f�_�&=�a�&@�&G�&G��&O�P������������W�W�
��c��#�(�(�(��L�t�S�T�T�
��	�s�#A � 	B�)1B�Bc
���|dk(r|j�}d|z}n-|dk(r(tj|j��}d|z}|j	�}|jdgtjdg��}	d|	dvr�	ttjt
j||	dddjd	��jd
���}
tt
j||	dddjd	���}n|j#d|z�y|dk(r9|
�d|j%���}|j'��d|j%���}n=|dk(r8|
�d|j���}|j'��d|j���}|j)�}k7�rH|j+�}|j-|d��}t/d|zt1�||��}t
j2�}t
j||�|_t
j6|tj8d�|d<t
j6|tj:d�|d<	|j=|�	tj>jA|||�}	|d}|d}tDjF}|dd}tj>jI|||
||�|j#d|z�y|j#d|z�y#t$r/}|j\}
}t!d|	ddd�d|�d
���d}~wwxYw#t$r%}|j\}
}t!d|�d|����d}~wwxYw#tj>jB$r}t!d|��d}~wwxYw#tj>jB$r}t!d|��d}~wwxYw) zTransfer dns FSMO role. �	domaindns�$CN=Infrastructure,DC=DomainDnsZones,�	forestdns�$CN=Infrastructure,DC=ForestDnsZones,r
zextended_dn:1:1)rr�controlsrr�GUIDz"No GUID found in naming master DN z : z 
Nz0* The '%s' role does not have an FSMO roleowner
Fz._msdcs.T��fallback_machinez	ldap://%s��url�session_info�credentials�lp�fSMORoleOwner_Del�fSMORoleOwner_AddzFailed to add role 'z': zDrsuapi Connect failed��zReplication failed�&FSMO transfer of '%s' role successful
�'This DC already has the '%s' FSMO role
)%�	domain_dn�samba�dn_from_dns_name�forest_dns_name�
host_dns_namerrr�strrr)rr�get_extended_componentrrr�write�domain_dns_name�
get_ntds_GUID�get_dsServiceName�get_loadparm�get_credentialsrr�Message�dn�MessageElement�FLAG_MOD_DELETE�FLAG_MOD_ADD�modify�	drs_utils�drsuapi_connect�drsExceptionr�DRSUAPI_DRS_WRIT_REP�sendDsReplicaSync)�outf�	sambaopts�credoptsrrr7�role_object�	forest_dn�new_host_dns_namer�master_guidr �e3rr�master_dns_name�new_dns_name�	new_ownerr0�creds�m�e5�
connection�e�drsuapi_connection�drsuapi_handle�req_options�NC�estrs                             r!�transfer_dns_rolerd;s����{���O�O�%�	�<�y�H��	
��	��*�*�5�+@�+@�+B�C�	�<�y�H���+�+�-��
�,�,�{�-�.� �^�^�!2� 3��5�C�
�#�a�&� �	B��d�i�i����u�/2�1�v�o�/F�q�/I�/P�/P�QW�/X�)Z�)?�)?��)G�I�J�K��s�v�v�e�S��V�O�-D�Q�-G�-N�-N�v�-V�W�X�L�	
�
�
�F��M�N���{��,7�,1�,A�,A�,C�E��).�)<�)<�)>�).�)>�)>�)@�B��	
��	�,7�,1�,A�,A�,C�E��).�)<�)<�)>�).�)>�)>�)@�B���'�'�)�I��,�&�
�
#�
#�
%���(�(��d�(�C���+��9�#1�#3�"'�B�0��
�K�K�M���v�v�e�[�)���!$�!3�!3�L�47�4G�4G�4C�"E��
��"%�!3�!3�I�47�4D�4D�4C�"E��
��	L��L�L��O�
	<����8�8�9J�9;�U�D�J�

	;�!+�A���'��]�N�!�6�6�K��R�S�!�B��O�O�-�-�.@�.<�.9�.0�+�
?�	
�
�
�<�t�C�D���
�
�=��D�E���A�	B����J�S�#�� #�A��� 7�� :�C� A�B�
B��	B��L�	L����J�S�#���c�J�K�K��	L�����+�+�	<��7��;�;��	<�����+�+�	;��3�T�:�:��	;�sb�BL�:M�!N�.AN7�	M�#*M
�
M�	N� M>�>N�N4�#N/�/N4�7O%�O � O%c�(�|j�}d|z}d|j�z}d|z}t|j��}t	j
||j
��}t	j�}	t	j
|d�|	_|dk(r7t|||�}
t	jdtjd�|	d<�n5|dk(rtt|||�}
|j|tjd	g�
�}t|�dk(sJ�|dd	d}t	j|tjd
�|	d
<n�|dk(r6t|||�}
t	jdtjd�|	d<n�|dk(r6t|||�}
t	jdtjd�|	d<nF|dk(r6t|||�}
t	jdtjd�|	d<ntd��|
�|j!d|z�y|
|k7r'	|j#|	�|j!d|z�y|j!d|z�y#t$$r%}
|
j&\}}td|�d|����d}
~
wwxYw)zTransfer standard FSMO role. �CN=RID Manager$,CN=System,�CN=Partitions,%s�CN=Infrastructure,��rid�1�becomeRidMaster�pdc�	objectSidrr3r�	becomePdc�naming�becomeDomainMaster�infrastructure�becomeInfrastructureMaster�schema�becomeSchemaMaster�Invalid FSMO role.NzECannot transfer, no DC assigned to the %s role.  Try 'seize' instead
Fz
Transfer of 'z' role failed: r5Tr6)r7�get_config_basednr<�get_schema_basednrrrArDrEr"rF�FLAG_MOD_REPLACErr�lenrr>rIrr)rOrrr7�rid_dn�	naming_dn�infrastructure_dn�	schema_dnrYr[r r�sid�e6rrs                r!�
transfer_roler��s������!�I�
)�I�
5�F�"�U�%<�%<�%>�>�I�,�y�8���E�+�+�-�.�I����u�e�5�5�7�8�I����
�A��6�6�%���A�D��u�}�)�%���>��"�1�1���%�%�� ��
��
���)�%��D�A���l�l�9�!$����}��F���3�x�1�}��}��!�f�[�!�!�$���+�+���%�%����+��
��	�)�%��D�A��"%�"4�"4���%�%� �#"��
��
�!�	!�)�%�1B�D�I��*-�*<�*<���%�%�(�+*��
&�'�
��	�)�%��D�A��"%�"4�"4���%�%� �#"��
���/�0�0����
�
�[�^b�b�c���y� �	,��L�L��O�	
�
�
�<�t�C�D���
�
�=��D�E����	,����J�S�#�� $�c� +�,�
,��	,�s�(I#�#	J�, J�Jc���eZdZdZdZejejejd�Z	e
dddedd�	�e
d
dd�
�e
ddgd�d��gZgZ
d�Zd�Z		dd�Zy)�cmd_fsmo_seizezSeize the role.�%prog [options]�rPrQ�versionopts�-H�--URL�%LDB URL for database or target server�URL�H��help�type�metavar�destz--forcez5Force seizing of role without attempting to transfer.�
store_true)r��action�--role�choice�rjrmrrrtrpr$r&�all�IThe FSMO role to seize or transfer.

rid=RidAllocationMasterRole

schema=SchemaMasterRole

pdc=PdcEmulationMasterRole

naming=DomainNamingMasterRole

infrastructure=InfrastructureMasterRole

domaindns=DomainDnsZonesMasterRole

forestdns=ForestDnsZonesMasterRole

all=all of the above

You must provide an Admin user and password.�r��choicesr�c���|j�}|j�}d|z|_d|j�z|_t|j
��|_d|z|_tj�}|dk(r&tj||j�|_n�|dk(rtj||�|_n�|dk(r&tj||j�|_na|dk(r&tj||j�|_n6|dk(r&tj||j�|_ntd	��d
}t||j|�}|�a||k7r=|�\|jd�	t!|j"||�|jd
�y|j"j%d|z�y
d}|�|r�|jd|z�tj&|tj(d�|d<|j+�	|j-|�|dk(r|j/�|j9�|j"j%d|z�yy#d}|jd�Y��xYw#t0$r�}	|	j2\}
}|dk(r�|
tj4k(rt|j7�|j+�	|j-|�nb#t0$r5}|j2\}
}|j7�td|�d|����d}~wwxYw|j7�td|�d|����Yd}	~	��d}	~	wwxYw)zSeize standard fsmo role. rhrgrfrjrmrprrrtrvFN�Attempting transfer...z%Transfer successful, not seizing roleT�!Transfer unsuccessful, seizing...r6�Seizing %s FSMO role...r
�Failed to seize '�' role: �#FSMO seize of '%s' role successful
)rAr7r}rwr|r<rxr~r{rrDrrErr"�messager�rOr>rFry�transaction_startrI�create_own_rid_setrr�ERR_ENTRY_ALREADY_EXISTS�transaction_cancel�transaction_commit)
�selfrr�force�serviceNamer7r[�seizer �e1rrr^s
             r!�
seize_rolezcmd_fsmo_seize.seize_role�s���-�-�/���O�O�%�	�!5�	�!A���+�e�.E�.E�.G�G����U�4�4�6�7���2�Y�>����K�K�M���5�=��6�6�%����-�A�D�
�U�]��6�6�%��+�A�D�
�X�
��6�6�%����0�A�D�
�%�
%��6�6�%��!7�!7�8�A�D�
�X�
��6�6�%����0�A�D��3�4�4���)�%����t�<���#��{�*��=��L�L�!9�:�$�%�d�i�i��u�=����%L�M�#��	�	��� J� $�!%�&���E�����L�L�2�T�9�:�!$�!3�!3��S�1�1��"!�A�o��
�#�#�%�
4����Q���5�=��,�,�.�0
�$�$�&��I�I�O�O�B�T�I�J��M!&��J� $�����%H�I��0�
4��W�W�
��c��5�=�S�C�,H�,H�%H��,�,�.��+�+�-�8����Q���#�8�%&�V�V�
��c��0�0�2�*�,0�#�,7�8�8��8���,�,�.�&�(,�c�(3�4�4�(��
4�sI�I<�&&J�<J�	M&�AM!�'K9�8M!�9	L7�0L2�2L7�7$M!�!M&c��|j�}|j�}tj|j	��}	d|z|_d|	z|_tj�}
|dk(r&tj||j
�|
_
n6|dk(r&tj||j�|
_
ntd��d}t||
j|�}|�c||k7r?|�^|jd�	t|j||||�|jd	�y
|jj!d|z�yd
}|�|rm|jd
|z�tj"|tj$d�|
d<	|j'|
�|jj!d|z�y
y#d
}|jd�Y��xYw#t($r%}
|
j*\}}td|�d|����d}
~
wwxYw)zSeize DNS FSMO role. r%r'r$r&rvFNr�z&Transfer successful, not seizing role
Tr�r6r�r
r�r�r�)rAr7r8r9r:�domaindns_dn�forestdns_dnrrDrrErr"r�rdrOr>rFryrIrr)r�rrrQrPr�r�r�r7rSr[r�r �e2rrs                r!�seize_dns_rolezcmd_fsmo_seize.seize_dns_roleNs����-�-�/���O�O�%�	��*�*�5�+@�+@�+B�C�	�B�Y�N���B�Y�N����K�K�M���;���6�6�%��!2�!2�3�A�D�
�[�
 ��6�6�%��!2�!2�3�A�D��3�4�4���)�%����t�<���#��{�*��=��L�L�!9�:�	$�)�$�)�)�Y��$�*/�1����%N�O�#��	�	��� J� $�!%�&���E�����L�L�2�T�9�:�!$�!3�!3��S�1�1��"!�A�o��
0����Q��

�I�I�O�O�B�T�I�J��!&��J� $�����%H�I��$�
0��W�W�
��c�"�$(�#�$/�0�0��
0�s$�F?�G�?G�	H�" H�HNc��|j�}|j|d��}t|t�||��}	|dk(r�|j	d|	|�|j	d|	|�|j	d|	|�|j	d|	|�|j	d	|	|�|jd
|	||||�|jd|	||||�y|d
k(s|dk(r|j||	||||�y|j	||	|�y�NTr*r,r�rjrmrprrrtr$r&)rBrCrrr�r��
r�r�r�rrQrPr�r0rZrs
          r!�runzcmd_fsmo_seize.run�s���
#�
#�
%���(�(��d�(�C���!�.�*:�"'�B�0���5�=��O�O�E�5�%�0��O�O�E�5�%�0��O�O�H�e�U�3��O�O�,�e�U�;��O�O�H�e�U�3�����U�H�i� +�U�
4�����U�H�i� +�U�
4��{�"�d�k�&9��#�#�D�%��9�$/��8�����e�U�3��NNNNNN)�__name__�
__module__�__qualname__�__doc__�synopsis�options�SambaOptions�CredentialsOptions�VersionOptions�takes_optiongroupsr
r<�
takes_options�
takes_argsr�r�r��r�r!r�r��s���� �H��)�)��.�.��-�-���	�t�W�#J���S�	2��y�K�"�	$�	�x�h�1f�	0�	1�
�M�(�J�W�r7�r,0�7;�4r�r�c��eZdZdZdZejejejd�Z	e
dddedd�	�gZgZ
dd�Zy
)
�
cmd_fsmo_showzShow the roles.r�r�r�r�r�r�r�r�Nc	��|j�}|j|d��}t|t�||��}|j	�}tj|j��}	d|z}
d|j�z}|j�}d|z}
d|z}d|	z}|d	d
f|
ddf|
d
df|ddf|ddf|ddf|ddfg}|D]L}|\}}}	t|||�}|� |j|�dt|����n|jd|z��Ny#t$r*}|j|�d|j���Yd}~�~d}~wwxYw)NTr*r,rhrgrfr%r'rt�SchemaMasterRolerr�InfrastructureMasterRolerj�RidAllocationMasterRolerm�PdcEmulationMasterRolerp�DomainNamingMasterRoler$�DomainDnsZonesMasterRoler&�ForestDnsZonesMasterRolez owner: z%s has no current ownerz: * )rBrCrrr7r8r9r:rwrxr"r�r<r)r�r�rQrPr�r0rZrr7rSr}r|r~r{r�r��masters�masterrE�
short_name�	long_namer^s                      r!r�zcmd_fsmo_show.run�s���
�
#�
#�
%���(�(��d�(�C���!�.�*:�"'�B�0���O�O�%�	��*�*�5�+@�+@�+B�C�	�0�9�<��&��)@�)@�)B�B�	��+�+�-�	�-�	�9��=�	�I��=�	�I���x�);�<�%�'7�9S�T��E�#<�=��u�&>�?��x�)A�B� �+�/I�J� �+�/I�J�
���		B�F�*0�'�R��Y�
B�+�E�2�z�B���%��L�L�9�c�&�k�!J�K��L�L�!:�i�!H�I��		B�� �
B����9�a�i�i�@�A�A��
B�s�AD�	E� E�E)NNNN�r�r�r�r�r�r�r�r�r�r�r
r<r�r�r�r�r�r!r�r��s[��� �H��)�)��.�.��-�-���	�t�W�#J���S�	2��M�
�J�"Br�r�c��eZdZdZdZejejejd�Z	e
dddedd�	�e
d
dgd�d
��gZgZ
		dd�Zy)�cmd_fsmo_transferzTransfer the role.r�r�r�r�r�r�r�r�r�r�r�r�r�Nc�D�|j�}|j|d��}t|t�||��}	|dk(r�t	|j
d|	�t	|j
d|	�t	|j
d|	�t	|j
d|	�t	|j
d	|	�t
|j
||d
|	�t
|j
||d|	�y|d
k(s|dk(rt
|j
||||	�yt	|j
||	�yr�)rBrCrrr�rOrdr�s
          r!r�zcmd_fsmo_transfer.run�s����
#�
#�
%���(�(��d�(�C���!�.�*:�"'�B�0���5�=��$�)�)�U�E�2��$�)�)�U�E�2��$�)�)�X�u�5��$�)�)�%5�u�=��$�)�)�X�u�5��d�i�i��H�)�5�
2��d�i�i��H�k�#�
%��{�"�d�k�&9�!�$�)�)�Y��$��N��d�i�i��u�5r�r�r�r�r�r!r�r��sw��� �H��)�)��.�.��-�-���	�t�W�#J���S�	2��x�h�1f�	0�	1��M�"�J�+/�7;�6r�r�c�P�eZdZdZiZe�ed<e�ed<e�ed<y)�cmd_fsmoz:Flexible Single Master Operations (FSMO) roles management.r��show�transferN)r�r�r�r��subcommandsr�r�r�r�r�r!r�r�s0��D��K�)�+�K���'�/�K���/�1�K�
�r�r�)r8�samba.getopt�getoptr�rr�samba.dcerpcrr�
samba.authr�samba.drs_utils�samba.netcmdrrr	r
�samba.samdbrr"rdr�r�r�r�r�r�r�r!�<module>r�st��(
��
��&�%������.W�t<�~K4�W�K4�\4B�G�4B�n56��56�p2�|�2r�

Zerion Mini Shell 1.0