%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__/remove_dc.cpython-312.pyc

�

�I�dI����ddlZddlZddlmZddlmZddlmZddlmZm	Z	ddl
mZmZm
Z
mZmZmZGd�de�Zd	�Zdd
�Zd�Z					dd�Z							dd
�Zd�Zd�Zy)�N)�LdbError)�werror)�
ndr_unpack)�misc�dnsp)�DNS_TYPE_NS�
DNS_TYPE_A�
DNS_TYPE_AAAA�DNS_TYPE_CNAME�DNS_TYPE_SRV�DNS_TYPE_PTRc��eZdZdZd�Zd�Zy)�DemoteExceptionzBase element for demote errorsc��||_y�N��value)�selfrs  �1/usr/lib/python3/dist-packages/samba/remove_dc.py�__init__zDemoteException.__init__ s	����
�c� �d|jzS)NzDemoteException: r)rs r�__str__zDemoteException.__str__#s��"�T�Z�Z�/�/rN)�__name__�
__module__�__qualname__�__doc__rr�rrrrs��(��0rrc	���|j�}dd|zfD]�}tj||�}	|j|j	��	|jd�|jdd|�	|jd	|z�|j|���d
D]�}tj||�}	|j|j��	|jd�|jdd|�	|jd	|z�|j|���y#tj
$r t
d|�d|j	�����wxYw#tj
$rt
d|z��wxYw#tj
$r/}|j\}}|tjk(rn�Yd}~���d}~wwxYw#tj
$r t
d|�d|j�����wxYw#tj
$rt
d|�d|�d���wxYw#tj
$r/}	|	j\}}|tjk(rn�Yd}	~	���d}	~	wwxYw)
Nz3CN=Enterprise,CN=Microsoft System Volumes,CN=Systemz+CN=%s,CN=Microsoft System Volumes,CN=SystemzFailed constructing DN z by adding base zCN=Xz.Failed constructing DN %s by adding child CN=Xr�CNzRemoving Sysvol reference: %s)zMCN=Domain System Volumes (SYSVOL share),CN=File Replication Service,CN=SystemzDCN=Topology,CN=Domain System Volume,CN=DFSR-GlobalSettings,CN=Systemz% by adding child CN=X (soon to be CN=�))�domain_dns_name�ldb�Dn�add_base�get_config_basednrr�	add_child�
set_component�info�delete�args�ERR_NO_SUCH_OBJECT�get_default_basedn)
�samdb�logger�dc_name�realm�s�dn�e�enum�estr�e1s
          r�remove_sysvol_referencesr8'sm���!�!�#�E�C�;�e�C�E���
�V�V�E�1�
��	E��K�K��/�/�1�2�	*��L�L�� �	����D�'�*�	��K�K�7�"�<�=��L�L���'�8V����V�V�E�1�
��	F��K�K��0�0�2�3�	M��L�L�� �	����D�'�*�	��K�K�7�"�<�=��L�L���'��)�|�|�	E�!�%'��)@�)@�)B�#D�E�
E�	E��
�|�|�	*�!�"R�%'�#)�*�
*�	*���|�|�	��6�6�L�T�4��s�-�-�-�����	���|�|�	F�!�%'��)A�)A�)C�#E�F�
F�	F��
�|�|�	M�!�?A�7�#L�M�
M�	M���|�|�	��7�7�L�T�4��s�-�-�-�����	�s_�D'�E�7%F�:G�G=�?%H&�'3E�"E?�G�$F?�?G�3G:�=&H#�&I(�9$I#�#I(c
�d�����jdtjdgdg��}t|�dk(ry|j	�}	�j|�\}��j|g��jdtjdg�	�}
t|
�d
k(sJ�|
dd}�fd��t�fd�|D��}�fd
�}
|D]�}	|j!d|z��j|�\}}t|�}|D�cgc]
}|
|�r�|��}}t|�|k7s�^|j#d|t|�|t|�z
fz��j||���t�|||�y#t$r`}|j\}}	|tjk(s|tjk(r|rt�|||�Yd}~ytd|�d|	����d}~wwxYw#t$r>}|j\}}	|tjk(rYd}~ytd|�d|	����d}~wwxYwcc}w)N�z.(&(objectClass=dnsZone)(!(dc=RootDNSServers)))�search_options:0:2)�base�scope�
expression�attrs�controlsrz
lookup of z	 failed: �namingContexts�r=r?�c�r��tj�|�j�jdd�dS)N�/rCr)r#r$�
canonical_str�split)r3r.s �r�dns_name_from_dnz/remove_dns_references.<locals>.dns_name_from_dn�s1����v�v�e�R� �.�.�0�6�6�s�A�>�q�A�Arc3�@�K�|]}�t|�����y�wr)�str)�.0r3rHs  �r�	<genexpr>z(remove_dns_references.<locals>.<genexpr>�s�����
6�B��s�2�w�'�
6�s�c����|jtk(s|jtk(r<�D]7}|j|jk(s�|j|jk(s�7yy�NTF)�wTyper	r
�data)�	dnsRecord�rec�primary_recss  �r�a_rec_to_removez.remove_dns_references.<locals>.a_rec_to_remove�sP����?�?�j�(�I�O�O�}�,L�#�
 ���9�9�	���/�C�H�H�	���4N��
 �rz(checking for DNS records to remove on %s�1updating %s keeping %d values, removing %s values)�searchr#�
SCOPE_SUBTREE�len�upper�
dns_lookup�RuntimeErrorr+r�"WERR_DNS_ERROR_NAME_DOES_NOT_EXIST�WERR_DNS_ERROR_RCODE_NAME_ERROR�remove_hanging_dns_referencesr�dns_replace�
SCOPE_BASE�set�debugr))r.r/�dnsHostName�ignore_no_name�zones�dnsHostNameUpperr3�e4r5r6�res�ncs�a_names_to_remove_fromrT�a_name�a_rec_dn�a_recs�e2�
orig_num_recs�rrHrSs`                   @@r�remove_dns_referencesrqbsG���
�L�L�b��(9�(9�$T�!�#7�"8�
�
:�E��5�z�Q���"�(�(�*��O�"�-�-�k�:���\�
���k�2�&�
�,�,�r� �^�^�4D�3E��G�C��s�8�q�=��=�

�a�&�!�
"�C�B��
6�#�
6�
6���)�.��	N��L�L�C�f�L�M�!&�!1�!1�&�!9��X�v��F��
�#�>��?�1�+=�!�>��>��v�;�-�'��K�K�K���V��m�c�&�k�.I�J�K�
L����f�f�-�!.�$"�%��1A�5�I���	O��w�w���t��F�=�=�=��F�:�:�:��-�e�V�.>�.3�5�
��;��M�N�N��	O��b�	N��7�7�L�T�4��v�@�@�@��!�v�t�"L�M�M��		N��?sI�	E7�(G#�
H-�H-�7	G �AG�
G�G �#	H*�,"H%�H%�%H*c�<���fd�}|D]�}|jd|jz�|j|jtjddg��}|D]�}	|d}|D�	cgc]$}	||	�st
tj|	���&}
}	t|
�t|�k7s�P|jd|jt|
�t|�t|
�z
fz�|j|j|
�����y#t
$rY��wxYwcc}	w)Nc�`��ttj|�}|jtk(s&|jt
k(s|jtk(r|jj��k(ryy|jtk(r(|jjj��k(ryyrN)rr�DnssrvRpcRecordrOrrr
rPrYr�
nameTarget)rrQrfs  �r�	to_removez0remove_hanging_dns_references.<locals>.to_remove�s�����t�3�3�U�;�	��?�?�k�)��o�o��/��o�o��-��~�~�#�#�%�)9�9����_�_��
,��~�~�(�(�.�.�0�4D�D��rzchecking %sz/(&(objectClass=dnsNode)(!(dNSTombstoned=TRUE)))rQ)r<r=r>r?rU)rbr3rVr#rW�KeyErrorrrrtrXr)�dns_replace_by_dn)r.r/rfrerv�zone�records�record�orig_values�v�valuess  `        rr^r^�s(���

��;�����]�T�W�W�,�-��,�,�D�G�G�3�3D�3D�+:�&1�]��4���	;�F�
�$�[�1�� +�@��)�A�,�!��!5�!5�q�9�@�F�@��6�{�c�+�.�.����O�%�y�y�#�f�+�"�;�/�#�f�+�=�?�?�@��'�'��	�	�6�:�#	;�
;���
��
��@s�D
�')D�
	D�Dc�$�|jdtjdg��}t|�dk(sJ�|ddd}	|j|gd�tjd��}
|
d}t	|d	d�}	tj
||d
dj
d��}
	t	|dd�}|r|j|d
g�|
��|j|
dgd�tj��}d|dvr9t	|ddd�}|jd|z�|j|�d|dvr9t	|ddd�}|jd|z�|j|�|r'|jd|
z�|j|
d
g�d|vrt	|dd�}|r�|jdtj|��d|�d�gtj|j���}t|�dk(r?|jd|djz�|j|dj�|�|r
t|||�|rt|||�yy#t$rd}
Y���wxYw#t$rd}Y���wxYw)Nr:�
dsServiceNamerBrCr)�serverReference�cnrcz(objectClass=server)�r<r?r=r>r�r��utf8rc�
tree_delete:0zobjectclass=computer)�msDS-KrbTgtLink�rIDSetReferencesr��r<r>r?r=r�zRemoving RID Set: %sr�zRemoving RODC KDC account: %sz5Removing computer account: %s (and any child objects)z(&(objectclass=user)(cn=dns-z)(servicePrincipalName=DNS/z)))r>r?r=r<z/Removing Samba-specific DNS service account: %s)rVr#r`rXrJr$�decoderwr*r)�
binary_encoderWr-r3rqr8)r.r/�	server_dn�remove_computer_obj�remove_server_obj�remove_sysvol_obj�remove_dns_names�remove_dns_accountrh�my_serviceName�msgs�msgr0�computer_dnrc�
computer_msgs�
rid_set_dn�krbtgt_link_dns                  r�offline_remove_serverr��s����,�,�r� �^�^�O�3D��F�C��s�8�q�=��=���V�O�,�Q�/�N��<�<�Y�.�!�n�n�#9�	�;�D�
�q�'�C��#�d�)�A�,��G���f�f�U�C�(9�$:�1�$=�$D�$D�V�$L�M����#�m�,�Q�/�0���	���Y�� 1�2������+�0F�,2�,/�>�>�%�;�
���q�!1�1��]�1�-�.@�A�!�D�E�J��K�K�.��;�<��L�L��$��
�a� 0�0� ��q�!1�2C�!D�Q�!G�H�N��K�K�7�.�H�I��L�L��(���K�K�O�R]�]�^��L�L���&7�8��C���c�-�0��3�4�K���l�l��-�-�g�6��'E�!#�3�+<�+<� %� 8� 8� :��<���s�8�q�=��K�K�I�C�PQ�F�I�I�U�V��L�L��Q����#���#3��e�V�[�9�� ����8���c������
�����s$�;+I.�'J�.I=�<I=�J�Jc

� �|jdtjdg��}
t|
�dk(sJ�tj||
dddjd��}|j
�}||k(rtd|z��	|j|dd	gtj�
�}
t|
�dk(rt|�d|j�����|
d}|jj�d
k7s|jj�dk7rtd|z��tt j"|d	d�}|rd|j|j%�d|z��}|D];}|j'd|jz�|j)|j��=|r�|jdtj*d|zdg��}|D]�}t-|�}tj.�}|j|_tj0|tj2d�|d<|j5d|j�d|�d��|j7|���	|j'd|z�|j)|dg�t9||||||||	��y#t$r6}|j\}}|tjk(rtd|z���d}~wwxYw#t$r"}|j\}}td|z��d}~wwxYw)Nr:r�rBrCrr�z#Refusing to demote our own DSA: %s zobjectClass=ntdsDSA�
objectGUIDr�zGiven DN %s doesn't existz is not an ntdsda in r z
NTDS Settingsz)Given DN (%s) wasn't the NTDS Settings DNz5(&(objectclass=nTDSConnection)(fromServer=<GUID=%s>)))r<r>zRemoving nTDSConnection: %sz(fsmoRoleOwner=<GUID=%s>))r;)r<r=r>r@�
fsmoRoleOwnerrzSeizing FSMO role on: z (now owned by r!z'Removing nTDSDSA: %s (and any children)r�z,Failed to remove the DCs NTDS DSA object: %s�r�r�r�r�r�)rVr#r`rXr$r��parentrrr+r,r"r3�get_rdn_name�
get_rdn_valuerr�GUIDr&r)r*rWrJ�Message�MessageElement�FLAG_MOD_REPLACE�warning�modifyr�)r.r/�ntds_dnr�r��remove_connection_obj�seize_stale_fsmor�r�r�rhr�r�r��e5r5r6r��	ntds_guid�stale_connections�conn�stale_fsmo_roles�role�val�m�e6s                          r�offline_remove_ntds_dcr�)s���,�,�r� �^�^�O�3D��F�C��s�8�q�=��=��V�V�E�3�q�6�/�#:�1�#=�#D�#D�V�#L�M�N���� �I��� ��C�n�T�U�U���|�|��5J�#/�.�����H��	�D�	�Q���!(�%�*?�*?�*A�C�D�	D��q�'�C��������%�������/�1��I�%�&�'�	'��4�9�9�c�,�&7��&:�;�I��"�L�L�e�.E�.E�.G�5C�EN�5O�)�P��&�	"�D��K�K�5����?�@��L�L����!�	"�� �<�<�R�s�7H�7H�3O�*3�44�2F�1G�(�I��%�	�D��n�%�C����
�A��7�7�A�D��+�+�C��1E�1E�,;�=�A�g�J��N�N�"�g�g�~�7�
8��L�L��O�	�&����=��G�H�
���W��/�0��%���.A�,=�,=�+;�-?�A��o���w�w���t��3�)�)�)�!�"=��"G�H�H�����d�&��w�w���t��L� $�%�&�	&��&�s0�$J �%'K"� 	K�)1K�K�"	L
�+L�L
c��|j�d}	tj|��}d|z}	|j	|gtj"d��}
t|
�dk(rD|�.|j�t|�d	|j�����t'|||ddddd��n"t)|||
djddddddd��
|j+�y#t$r�	|j	|j�gdt
j|�z��}nB#t$r6}|j\}}	td|�d|j��d|	����d}~wwxYwt|�dk(r.|j�t|�d	|j�����|dj}t
j|d
�}|j!|�Y���wxYw#t$rb}|j\}}	|tj$k(rg}
n2|j�td|�d
|j��d|	����Yd}~���d}~wwxYw)N)�hexz	<GUID=%s>z(&(objectClass=server)(cn=%s)))r<r?r>zFailure checking if z is an server object in z: rz is not an AD DC in zCN=NTDS Settingsz(objectClass=ntdsdsa)r�z is an NTDS DSA in Tr�)r�r�r�r�r�r�r�)�transaction_start�uuid�UUID�
ValueErrorrVr&r#r�rr+rr"rX�transaction_cancelr3r$r%r`r,r�r��transaction_commit)r.r/r0r�r�r��server_msgs�e3r5r6�	ntds_msgs�e7s            r�	remove_dcr�~s`��

�����I�$��I�I�'�*�	��	�)��0:��L�L�g�R�s�~�~�,C�!�E�	�	�I��!�����$�$�&�!�%,�e�.C�.C�.E�#G�H�
H�	�e�V�'�26�04�04�/3�15�
	7�	�u�f�(��|���37�15�59�04�15�04�26�	8�
�����}�$�
	N��,�,�E�,C�,C�,E�-/�32�),�):�):�7�)C�3D�'�E�K��
�	N��7�7�L�T�4�!�%,�e�.C�.C�.E�t�#M�N�
N��	N��
����!��$�$�&�!�%,�e�.C�.C�.E�#G�H�
H���N�%�%�	��&�&�� 2�3������#�)$��4�:��w�w���t��3�)�)�)��I��$�$�&�!��%�/�/�1�4�9�:�
:�
��:�sN�C�#G�	G�"8D�G�	E�$1E�E�A5G�G�	I�AH<�<Ic�^�|j�t||d�|j�yr)�start_transactionr��commit_transaction)r.r�s  r� offline_remove_dc_RemoveDsServerr��s&��	�����5�'�4�0�	���r)F)FFFFF)FFFFFFF)r�r#r�sambar�	samba.ndrr�samba.dcerpcrr�samba.dcerpc.dnsprr	r
rrr
�	Exceptionrr8rqr^r�r�r�r�rrr�<module>r�s���&�
��� �#�/�/�0�i�0�8�vMJ�`(;�Z/4�,1�,1�+0�-2�
I9�^05�-2�16�,1�-2�,1�.3�RA�jK�\r

Zerion Mini Shell 1.0