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

�

��d�����ddlZddlZddlZddlZddlmZddlmZddlm	Z	ddl
mZddlm
Z
mZmZmZmZddlmZmZmZej,d�ZGd�d	e�ZGd
�de�ZGd�d
e�ZGd�de�ZGd�de�Zy)�N)�Ldb)�
ndr_unpack)�security)�
SCOPE_SUBTREE�SCOPE_ONELEVEL�
SCOPE_BASE�ERR_NO_SUCH_OBJECT�LdbError)�Command�CommandError�Optionz^([^;]+);range=(\d+)-(\d+|\*)$c��eZdZddddddddejej
dfd�Zd�Zd�Zd	�Z	d
�Z
d�Zd�Zd
�Z
d�Zd�Zd�Zd�Zy)�LDAPBaseF�section��SUBTc��g}|}d|vr*tjj|�rd|z}nd|z}|j�j	d�rdg}||_|
|_t||||��|_|
|_	||_
||_||_||_
||_|	|_||_||_||_t'|jj)��|_t'|jj-��|_t'|jj1��|_t'|jj5��|_|j9�|_|j=�|_tAjBdd|j*�jEd	d
�|_#|jI�|_%|jM�|jr�|js�|j
jOd|j"z�|j
jOdd
|j*zz�|j
jOdd|j:zz�|j
jOdd|j>zz�|j
jOdd|jFzz�yyy)Nz://ztdb://%sz	ldap://%szldap://zmodules:paged_searches)�url�credentials�lp�optionsz	[Dd][Cc]=r�,�.z
* Place-holders for %s:
�    z${DOMAIN_DN}      => %s
z${DOMAIN_NETBIOS} => %s
z${SERVER_NAME}     => %s
z${DOMAIN_NAME}    => %s
)(�os�path�isfile�lower�
startswith�outf�errfr�ldb�search_base�search_scope�two_domains�quiet�
descriptor�	sort_aces�view�verbose�host�skip_missing_dn�str�get_default_basedn�base_dn�get_root_basedn�root_dn�get_config_basedn�	config_dn�get_schema_basedn�	schema_dn�find_netbios�domain_netbios�find_servers�server_names�re�sub�replace�domain_name�find_domain_sid�
domain_sid�get_sid_map�write)�selfr+�credsr�twor&r'r(r*r)�base�scoper r!r,�ldb_options�	samdb_urls                 �6/usr/lib/python3/dist-packages/samba/netcmd/ldapcmp.py�__init__zLDAPBase.__init__-sa�����	�����w�w�~�~�d�#�&��-�	�'�$�.�	��?�?��'�'�	�2�3�4�K���	���	��9�#(��*�,��� ���!��������
�$���"�����	������	�.����4�8�8�6�6�8�9����4�8�8�3�3�5�6����T�X�X�7�7�9�:����T�X�X�7�7�9�:���"�/�/�1��� �-�-�/����6�6�+�r�4�<�<�@�H�H��c�R����.�.�0����������D�J�J��I�I�O�O�9�D�I�I�E�F��I�I�O�O�G�&A� �L�L�')�)�
*��I�I�O�O�G�&A� �/�/�'0�0�
1��I�I�O�O�G�&B� �-�-�'.�.�
/��I�I�O�O�G�&A� �,�,�'-�-�
.�%/��c��|jj|jdt��}t	t
j|ddd�S)Nz(objectClass=*))rE�
expressionrFr�	objectSid)r"�searchr/rrr�dom_sid�rB�ress  rIr>zLDAPBase.find_domain_sidbsA���h�h�o�o�4�<�<�<M�U_�o�`���(�*�*�C��F�;�,?��,B�C�CrKc���|jjd|jztddg��}t	|�dkDsJ�|D�cgc]}t|dd���c}Scc}w)z	
        zOU=Domain Controllers,%sz(objectClass=computer)�cn)rErFrM�attrsr)r"rOr/r�lenr-)rBrR�xs   rIr8zLDAPBase.find_serversfsd���h�h�o�o�#=����#L�$1�>V�_c�^d��f���3�x�!�|��|�),�-�A��A�d�G�A�J��-�-��-s�A!c�4�	|jjd|jztdg��}t
�dk(rtd��|D]}d|vs�|ddj�cSy#t$r}|\}}|dvrt||��Yd}~�`d}~wwxYw)NzCN=Partitions,%s�nETBIOSName�rErFrU)z,Operation unavailable without authenticationrzCould not find netbios name)r"rOr3rr
rrV�decode)rBrR�e�enum�estrrWs      rIr6zLDAPBase.find_netbiosns���	,��(�(�/�/�'9�D�N�N�'J�(5�m�_�"�N�C��s�8�q�=��<�=�=��	4�A���!���'��*�1�1�3�3�	4���	,��J�D�$��G�G�"�4��+�+�H��	,�s�0A/�/	B�8B�Bc���d}	|jj|t��}t
|�dk(S#t$r#}|j\}}|t
k(rYd}~y�d}~wwxYw)N)rErFF�)r"rOrr
�argsr	rV)rB�	object_dnrR�e2r]r^s      rI�
object_existszLDAPBase.object_exists~s`����	��(�(�/�/�y�
�/�C�C��3�x�1�}����	��7�7�L�T�4��)�)����		�s�!3�	A�A�A�Ac��	|jj|�y#tj$r}dt	|�vsJ�Yd}~yd}~wwxYw)NzNo such object)r"�deleterr
r-)rBrbr\s   rI�delete_forcezLDAPBase.delete_force�s=��	.��H�H�O�O�I�&���|�|�	.�#�s�1�v�-�-�-��	.�s��A
�A�A
c�V�tj|�}|�|S|jd�S)zi Returns the real attribute name
            It resolved ranged results e.g. member;range=0-1499
        r`)�RE_RANGED_RESULT�match�group)rB�key�ms   rI�get_attribute_namezLDAPBase.get_attribute_name�s,��

�"�"�3�'���9��J��w�w�q�z�rKc��tj|�}|�|S|jd�}t|jd��}	d||dzfz}|jj|t|g��}t|�dk(sJ�t|d�}|d=d}	d}
|D]@}tj|�}|��|jd�|k7r�0|}	t||�}
n|	�	|S|j|
�|	jd�dk(r	|St|	jd	��|dzk(sJ�t|	jd��}��)
zp Returns list with all attribute values
            It resolved ranged results e.g. member;range=0-1499
        Nr`�z
%s;range=%d-*rZr�dn�*�)rirjrk�intr"rOrrV�dict�list�extend)rBrbrl�valsrm�attr�hi�nrR�fm�fvalss           rI�get_attribute_valueszLDAPBase.get_attribute_values�s\��

�"�"�3�'���9��K��w�w�q�z��
������_����4��a��.�0�A��(�(�/�/�y�
�1�#�/�N�C��s�8�q�=� �=��s�1�v�,�C��D�	��B��E��
��$�*�*�3�/���9���7�7�1�:��%�����S��X����
��z����
�K�K����x�x��{�c�!��
���r�x�x��{�#�r�A�v�-�-�-��R�X�X�a�[�!�B�CrKc�&�|jj|tdg��}t|�dk(sJ�t	|d�}|d=i}|j�D]7\}}|j
|�}t|�}|j|||�||<�9|S)z: Returns dict with all default visible attributes
        rrrZr`rrq)	r"rOrrVru�itemsrn�sortedr~)rBrbrR�
attributesrlrx�names       rI�get_attributeszLDAPBase.get_attributes�s����h�h�o�o�9�J�s�e�o�L���3�x�1�}��}��3�q�6�l����I��
�����	O�I�C���*�*�3�/�D��$�<�D�#�8�8��C��N�J�t��		O��rKc���|jj|tdg��}|ddd}ttj
|�}|j
|j�S)N�nTSecurityDescriptorrZr)r"rOrrrr'�as_sddlr?)rBrbrR�descs    rI�get_descriptor_sddlzLDAPBase.get_descriptor_sddl�sW���h�h�o�o�9�J�G]�F^�o�_���1�v�,�-�a�0���(�-�-�t�4���|�|�D�O�O�,�,rKc��d|z}gd�}d}d}d}|t|�kr�d}d}|||krjtt||��jdd�}	dd|	z|	gt|	�}	d|zt|�kr|	|z}n||	z
}|d	z
}|d	z
}|||kr�j||d
zz
}|d	z
}|t|�kr��|t|�k(sJ�|j	�jd
d�S)z� Translate binary representation of schemaIDGUID to standard string representation.
            @gid_blob: binary schemaIDGUID
        �%s)�rsrsrs�rr�0xN�0rsr`� �-)rV�hex�ordr<�strip)
rB�	guid_blob�blob�stops�indexrRrW�tmp�y�cs
          rI�guid_as_stringzLDAPBase.guid_as_string�s���i���������
���#�e�*�n��C��A��e�A�h�,���D��K�(�)�1�1�$��;���3��7�A�&�s�1�v�.���u�9�s�4�y�(��c�'�C��1�H�C���
���Q����e�A�h�,�
�3��9��C�
��F�A��#�e�*�n���D�	�!�!�!��y�y�{�"�"�3��,�,rKc	��i|_|jj|jdtddg��}|D]B}	t|dd�|jdt
tj|dd�z<�Dy#t$rY�QwxYw)za Build dictionary that maps GUID to 'name' attribute found in Schema or Extended-Rights.
        z
(objectSid=*)rN�sAMAccountName)rErMrFrUrr�N)
�sid_mapr"rOr/rr-rrrP�KeyError)rBrR�items   rIr@zLDAPBase.get_sid_maps�������h�h�o�o�4�<�<�)8�
�Va�cs�Ut��v���	�D�
�Z]�^b�cs�^t�uv�^w�Zx����T�J�x�/?�/?��k�AR�ST�AU�$V�V�W�	���
��
�s�?A?�?	B�
BN)�__name__�
__module__�__qualname__�sys�stdout�stderrrJr>r8r6rdrgrnr~r�r�r�r@�rKrIrr+se���%�E�U�TY��b���j�j�s�z�z�4�3.�jD�.�4� 	�.�	�2�h�$-�-�4
rKrc�X�eZdZejej
fd�Zd�Zd�Zd�Z	d�Z
y)�
Descriptorc��||_||_||_||_|jj	|j�|_|j
�|_|jjr|jj�yy�N)
r r!�conrqr��sddl�extract_dacl�	dacl_listr(�sort)rB�
connectionrqr r!s     rIrJzDescriptor.__init__sj����	���	��������H�H�0�0����9��	��*�*�,����8�8����N�N���!�rKc�,�	d|jvr0tjd|j�jd�}n/tjd|j�jd�}tj
d|�S#t$rgcYSwxYw)zH Extracts the DACL as a list of ACE string (with the brackets).
        zS:zD:(.*?)(\(.*?\))S:rszD:(.*?)(\(.*\))z	(\(.*?\)))r�r:rOrk�AttributeError�findallrQs  rIr�zDescriptor.extract_dacls|��	��t�y�y� ��i�i� 5�t�y�y�A�G�G��J���i�i� 2�D�I�I�>�D�D�Q�G���z�z�,��,�,���	��I�	�s�A-B�B�Bc���d|z}tjd|�}t|�dk(r|S|D].}	|jj|}|j||�}�0|S#t$rY�>wxYw)Nr�z	S-[-0-9]+r)r:r�rVr�r�r<r�)rB�acerR�sids�sidr�s      rI�fix_sidzDescriptor.fix_sid$s~���S�j���z�z�+�s�+���t�9��>��J��	�C�
��x�x�'�'��,���k�k�#�t�,��	��
���
��
�s�+A!�!	A-�,A-c�Z�d}t|j�t|j�k7rA|dz
}|ddt|j�zzz
}|ddt|j�zzz
}d}d}	d}d}	d|j|z}	d|j|z}t|�t|�zdk(r	||fSd|j|�z}d|j|�z}||k7r||d�d	|�d
�z
}d}n||d�d|�d
�z
}|d
z
}��#t$rd}Y��wxYw#t$rd}Y��wxYw)Nr�    Difference in ACE count:
�        �=> %s
rTr�z>60z * �
Fz | r`)rVr��
IndexErrorr�)	rB�otherrR�i�flag�self_ace�	other_ace�self_ace_fixed�other_ace_fixeds	         rI�diff_1zDescriptor.diff_13s_�����t�~�~��#�e�o�o�"6�6��9�9�C��7�Y��T�^�^�)<�<�<�<�C��7�Y��U�_�_�)=�=�=�=�C�
������H��I�
��$�.�.��"3�3��
� �5�?�?�1�#5�5�	��8�}�s�9�~�-��2���c�{��"�D�L�L��$:�:�N�"�U�]�]�9�%=�=�O���0����H�H�������H�H��
��F�A�+��
�
���
��
�
��	�
�s$�9D�D�D�D�D*�)D*c��d}t|j�t|j�k7rA|dz
}|ddt|j�zzz
}|ddt|j�zzz
}g}g}g}|jD�cgc]}|j|���}}|jD�cgc]}|j|���}}|D]%}	|j|�|j	|��'t
|�}t|�dkDr1|dd|jjzzz
}|D]
}|d|zdzz
}�|D]%}	|j|�|j	|��'t
|�}t|�dkDr1|dd|jjzzz
}|D]
}|d|zdzz
}�t
tt|���}|jjr|d	z
}|D]
}|d|zdzz
}�|gk(xr|gk(|fScc}wcc}w#t
$r|j	|�Y��ewxYw#t
$r|j	|�Y��wxYw)
Nrr�r�r�rrzACEs found only in %s:
r�z    ACEs found in both:
)rVr�r�r��append�
ValueErrorr�r�r+rv�setr*)	rBr�rR�common_aces�	self_aces�
other_acesr��self_dacl_list_fixed�other_dacl_list_fixeds	         rI�diff_2zDescriptor.diff_2Ts{�����t�~�~��#�e�o�o�"6�6��9�9�C��7�Y��T�^�^�)<�<�<�<�C��7�Y��U�_�_�)=�=�=�=�C����	��
�=A�^�^�L�c����S� 1�L��L�?D��� O�����s�!3� O�� O�'�	(�C�
(�%�+�+�C�0��"�"�3�'�
	(��9�%�	��y�>�A���7�7�$�(�(�-�-�G�G�G�C� �
,���w��}�t�+�+��
,�)�	(�C�
(�$�*�*�3�/��"�"�3�'�
	(��J�'�
��z�?�Q���7�7�%�)�)�.�.�H�H�H�C�!�
,���w��}�t�+�+��
,��T�#�k�"2�3�4���8�8����4�4�C�"�
,���w��}�t�+�+��
,��R��4�J�"�$4�c�:�:��C M�� O���
&�� � ��%�
&���
'��!�!�#�&�
'�s0�H�+H
�H�?H0�H-�,H-�0I�
IN)r�r�r�r�r�r�rJr�r�r�r�r�rKrIr�r�
s)��,/�J�J�S�Z�Z�"�
-�
��B+;rKr�c�p�eZdZejej
fd�Zd�Zd�Zd�Z	d�Z
d�Zd�Zd�Z
d	�Zy
)�
LDAPObjectc�V�||_||_||_|jj|_|jj|_|jj
|_||_|jd|jj�|_	|jjdd|jjz�|_	|jjD]&}|jjdd|z�|_	�(|jj|j�|_
gd�|_|j|_|xjdgz
c_|r|xj|z
c_g|_g|_g|_g|_g|_|j�r%|xjgd�z
c_gd�|_|j D�cgc]}|j+���c}|_gd	�|_|j"D�cgc]}|j+���c}|_gd
�|_|j$D�cgc]}|j+���c}|_gd�|_|j&D�cgc]}|j+���c}|_dd
g|_|j(D�cgc]}|j+���c}|_t-|jD�cgc]}|j+���c}�|_ycc}wcc}wcc}wcc}wcc}wcc}w)N�${DOMAIN_DN}�CN=${DOMAIN_NETBIOS}�CN=%s�CN=${SERVER_NAME}) �badPasswordTime�badPwdCount�dSCorePropagationData�
lastLogoff�	lastLogon�
logonCount�
modifiedCountzmsDS-Cached-Membershipz!msDS-Cached-Membership-Time-StampzmsDS-EnabledFeatureBLzmsDS-ExecuteScriptPasswordzmsDS-NcTypezmsDS-ReplicationEpochzmsDS-RetiredReplNCSignatureszmsDS-USNLastSyncSuccess�partialAttributeDeletionList�partialAttributeSet�pekList�	prefixMap�replPropertyMetaData�replUpToDateVector�repsFrom�repsTo�
rIDNextRID�rIDPreviousAllocationPool�schemaUpdate�serverState�subRefs�
uSNChanged�
uSNCreated�
uSNLastObjRem�whenChanged�msExchServer1HighestUSN)$�objectCategory�
objectGUIDrN�whenCreatedr��
pwdLastSetr��creationTimer��priorSetTime�rIDManagerReference�gPLink�ipsecNFAReference�fRSPrimaryMember�
fSMORoleOwner�
masteredBy�ipsecOwnersReference�wellKnownObjects�otherWellKnownObjectsr��ipsecISAKMPReference�ipsecFilterReferencezmsDs-masteredBy�lastSetTime�ipsecNegotiationPolicyReferencer��gPCFileSysPath�accountExpires�invocationId�operatingSystem�operatingSystemVersion�oEMInformation�
schemaInfo�
targetAddress�msExchMailboxGuid�siteFolderGUID)&�distinguishedName�defaultObjectCategory�member�memberOf�siteList�nCName�homeMDB�homeMTA�interSiteTopologyGenerator�serverReferencezmsDS-HasInstantiatedNCs�hasMasterNCszmsDS-hasMasterNCszmsDS-HasDomainNCs�dMDLocation�msDS-IsDomainFor�rIDSetReferences�serverReferenceBL�msExchHomeRoutingGroup�msExchResponsibleMTAServer�siteFolderServer�msExchRoutingMasterDN�msExchRoutingGroupMembersBL�	homeMDBBL�msExchHomePublicMDB�msExchOwningServer�
templateRoots�addressBookRoots�msExchPolicyRoots�globalAddressList�msExchOwningPFTree�msExchResponsibleMTAServerBL�msExchOwningPFTreeBLz$msDS-MembersOfResourcePropertyListBLzmsDS-ValueTypeReferencez"msDS-MembersOfResourcePropertyListzmsDS-ValueTypeReferenceBLzmsDS-ClaimTypeAppliesToClass)�proxyAddresses�mail�userPrincipalName�"msExchSmtpFullyQualifiedDomainName�dnsHostName�networkAddress�dnsRoot�servicePrincipalName)rr��CNr��dNSHostNamer5rrrrr)r5r6rrYr�r��DC)r r!r�r%r&r*�summaryr<r/rqr7r9r�r��non_replicated_attributes�ignore_attributes�
dn_attributes�domain_attributes�servername_attributes�netbios_attributes�other_attributes�upperr�)rBr�rqr9�filter_listr r!rWs        rIrJzLDAPObject.__init__�s�����	���	�����8�8�/�/����X�X�^�^��
��x�x�'�'�������*�*�^�T�X�X�-=�-=�>����'�'�/�/�"8�'�D�H�H�D[�D[�:[�\������&�&�	H�A��g�g�o�o�&9�7�Q�;�G�D�G�	H��(�(�1�1�$�'�'�:���#*
��&�H"&�!?�!?������#<�"=�=����"�"�k�1�"����!#���%'��"�"$��� "�������"�"�'H�
H�"�""�D��"6:�5G�5G�!H��!�'�'�)�!H�D��&V�D�"�:>�9O�9O�%P�A�a�g�g�i�%P�D�"�*^�D�&�>B�=W�=W�)X��!�'�'�)�)X�D�&�&r�D�#�:>�:Q�:Q�&R�Q�q�w�w�y�&R�D�#�%+�T�$4�D�!�8<�8M�8M�$N�1�Q�W�W�Y�$N�D�!�!$��9O�9O�%P�A�a�g�g�i�%P�!Q����)"I��&Q��*Y��'S��%O��%Ps$�L
�L�L�L�7L!�)L&c�Z�|js|jj|dz�yy�zE
        Log on the screen if there is no --quiet option set
        r�N�r&r rA�rB�msgs  rI�logzLDAPObject.logs$���z�z��I�I�O�O�C��I�&�rKc��d|z}|js|S|j�j|jjj��r1|dt|�t|jj�z
dz}|S)Nr�r�)r%rA�endswithr�r/rV�rB�srRs   rI�fix_dnzLDAPObject.fix_dnso���Q�h������J��9�9�;������ 0� 0� 6� 6� 8�9��7�s�3�x�#�d�h�h�&6�&6�"7�7�8�>�I�C��
rKc�@�d|z}|js|S|j|jjj	�|jjj��}|j|jjj�d�}|S)Nr�z${DOMAIN_NAME})r%r<r�r=rrArKs   rI�fix_domain_namezLDAPObject.fix_domain_namesx���Q�h������J��k�k�$�(�(�.�.�4�4�6����8L�8L�8R�8R�8T�U���k�k�$�(�(�.�.�4�4�6�8H�I���
rKc�@�d|z}|js|S|j|jjj	�|jjj��}|j|jjj�d�}|S)Nr�z${DOMAIN_NETBIOS})r%r<r�r7rrArKs   rI�fix_domain_netbioszLDAPObject.fix_domain_netbiossx���Q�h������J��k�k�$�(�(�1�1�7�7�9�4�8�8�;R�;R�;X�;X�;Z�[���k�k�$�(�(�1�1�7�7�9�;N�O���
rKc���d|z}|jr"t|jj�dkDr|S|jjD]"}|j	�j|d�}�$|S)Nr�r`z${SERVER_NAME})r%rVr�r9rAr<)rBrLrRrWs    rI�fix_server_namezLDAPObject.fix_server_name#sf���Q�h�����3�t�x�x�'<�'<�#=��#A��J����&�&�	;�A��)�)�+�%�%�a�)9�:�C�	;��
rKc�r�|jjr|j|�S|j|�Sr�)r�r'�cmp_desc�	cmp_attrs)rBr�s  rI�__eq__zLDAPObject.__eq__+s-���8�8����=�=��'�'��~�~�e�$�$rKc��t|j|j|j|j��}t|j|j|j|j��}|jj
dk(r|j
|�}nM|jj
dk(r|j|�}n"td|jj
����|d|_	|d|_	|dS)N)r r!r�	collisionzUnknown --view option value: r`r)
r�r�rqr r!r)r�r�r��
screen_output)rBr��d1�d2rRs     rIrUzLDAPObject.cmp_desc0s���
����$�'�'��	�	��	�	�
J��
��	�	�5�8�8�$�)�)�$�)�)�
L���8�8�=�=�I�%��)�)�B�-�C�
�X�X�]�]�k�
)��)�)�B�-�C��<�T�X�X�]�]�O�L�M�M� ��V���!�!�f����1�v�
rKc�$
�d}g|_t|jD�cgc]}|j���c}�}t|jD�cgc]}|j���c}�}||z
|jz
}|r1|dd|j
jzzz
}|D]
}|d|zdzz
}�||z
|jz
}|r1|dd|j
jzzz
}|D]
}|d|zdzz
}�||z}	d}
|jD�]+}|j�|jvs|j�|	vr�3|j|}|jj|�}t|t�r&t|t�rt|�}t|�}||k7s��d}
d}d}d}|j�|jvrw|D�cgc]-}|j
jjd�d|k(��/}
}|D�cgc]-}|j
jjd�d|k(��/}}|
|k(re��4|j�|jvrG|}|}|D�cgc]}|j|���}
}|D�cgc]}|j|���}}|
|k(r���|j�|j vrO|
}|}|
s|s|}|}|D�cgc]}|j#|���}
}|D�cgc]}|j#|���}}|
|k(r��|j�|j$vrO|
}|}|
s|s|}|}|D�cgc]}|j'|���}
}|D�cgc]}|j'|���}}|
|k(r��m|j�|j(vrO|
}|}|
s|s|}|}|D�cgc]}|j+|���}
}|D�cgc]}|j+|���}}|
|k(r���|
r
||
dzz
}d}
|
r|r|d|zd	|
�d|��zdzz
}n|d|zd	|�d|��zdzz
}|jj-|���.|	r||k7sJ�|j.d
xxt|�z
cc<|j.dxx|jz
cc<|j.d
xxt|�z
cc<|j.dxx|jz
cc<||_||_|dk(Scc}wcc}wcc}wcc}wcc}wcc}wcc}wcc}wcc}wcc}wcc}wcc}w)NrrzAttributes found only in %s:r�r�z#    Difference in attribute values:rrz => 
�unique_attrs�df_value_attrs)r_r�r�rAr;r�r+�get�
isinstancervr�r@r=�splitr<rMr=rOr>rSr?rQr�r9rZ)rBr�rRry�
self_attrs�other_attrs�self_unique_attrsrW�other_unique_attrs�
missing_attrs�title�ours�theirs�p�qrmr{�js                  rIrVzLDAPObject.cmp_attrs?s#���� ����4�?�?�C�4�$�*�*�,�C�D�
��E�4D�4D�E�D�4�:�:�<�E�F��&��4�u�7N�7N�N����7�;�d�h�h�m�m�K�K�K�C�&�
*���w��{�T�)�)��
*�)�:�5��8N�8N�N����7�;�e�i�i�n�n�L�L�L�C�'�
*���w��{�T�)�)��
*�*�,>�>�
�;�����I	.�A��w�w�y�D�2�2�2�a�g�g�i�=�6P���?�?�1�%�D��%�%�)�)�!�,�F��$��%�*�V�T�*B��d�|�������v�~����������7�7�9�� 5� 5�5�JN�O�Q����-�-�3�3�C�8��;�q�@�O�A�O�KQ�R�a����.�.�4�4�S�9�!�<��A�R�A�R��A�v� ��W�W�Y�$�"4�"4�4��A��A�12�3�A����Q��3�A�3�23�4�Q����a��4�A�4��A�v� ��7�7�9�� 6� 6�6��A��A��Q� ��"��:;�<�Q��-�-�a�0�<�A�<�;<�=�a��.�.�q�1�=�A�=��A�v� ��7�7�9�� :� :�:��A��A��Q� ��"��:;�<�Q��-�-�a�0�<�A�<�;<�=�a��.�.�q�1�=�A�=��A�v� ��7�7�9�� 7� 7�7��A��A��Q� ��"��=>�?���0�0��3�?�A�?�>?�@���1�1�!�4�@�A�@��A�v� ���5�4�<�'�C� �E����7�Q�;�1�a�)@�@�4�G�G�C��7�Q�;�4��)H�H�4�O�O�C��#�#�*�*�1�-�SI	.�V�$�(:�:�:�:����^�$��->�(?�?�$����%�&�$�*=�*=�=�&�
�
�
�n�%��.@�)A�A�%�
�
�
�&�'�4�+>�+>�>�'� ���!����b�y���MD��E��DP��R��4��4��=��=��=��=��@��@sG�S�S�
2S �2S%�!S*�?S/�S4�*S9�7S>�T�"T�T
N)r�r�r�r�r�r�rJrHrMrOrQrSrWrUrVr�rKrIr�r��s@���j�j�s�z�z�R�B'�����%�

�jrKr�c�b�eZdZddejej
fd�Zd�Zd�Zd�Z	d�Z
d�Zy)�
LDAPBundleNc��||_||_||_|jj|_|jj|_|jj
|_|jj|_|jj|_|jj|_i|_	g|jd<g|jd<g|jd<g|jd<||_
|r||_nI|j�dvr,|j�|_
|j|�|_ntd��d}|t!|j�k�r|jr�|j|}|dt!|�t!|jj"�z
dz}|j%d	|jj&zd
�}t!|jj(�dk(r0|jj(D]}	|j%d	|	zd�}�||j|<|dz
}|t!|j�kr
|jr��t+t-|j��|_t/|j�|_t!|j�|_y)
Nr^r_�known_ignored_dn�abnormal_ignored_dn��DOMAIN�
CONFIGURATION�SCHEMA�	DNSDOMAIN�	DNSFORESTz-Unknown initialization data for LDAPBundle().rr�r�r�r`r�)r r!r�r%r&r*r#r$r,r9rB�dn_listrA�context�get_dn_list�	ExceptionrVr/r<r7r9rvr�r��size)
rBr�rzryrBr r!�counterr�rWs
          rIrJzLDAPBundle.__init__�s3����	���	�����8�8�/�/����X�X�^�^��
��x�x�'�'����8�8�/�/��� �H�H�1�1���#�x�x�7�7������')����^�$�)+����%�&�+-����'�(�.0����*�+�&����"�D�L�
�]�]�_� _�
_�"�=�=�?�D�L��+�+�G�4�D�L��K�L�L�����D�L�L�)�)�d�.>�.>��,�,�w�'�C��7�s�3�x�#�d�h�h�&6�&6�"7�7�8�>�I�C��+�+�g����(?�(?�?�AW�X�C��4�8�8�(�(�)�Q�.����.�.�H�A��+�+�g��k�3F�G�C�H�$'�D�L�L��!��q�L�G���D�L�L�)�)�d�.>�.>��C����-�.����d�l�l�+�������%��	rKc�Z�|js|jj|dz�yyrDrErFs  rIrHzLDAPBundle.log�s$���z�z��I�I�O�O�C�$�J�'�rKc�l�t|j�|_t|j�|_yr�)rVryr}r�)rBs rI�update_sizezLDAPBundle.update_size�s"������%��	��d�l�l�+��rKc	�&�d}|j|jk7r9|jd|j�d|j���|jsd}t|jD�cgc]}|j���c}�}t|jD�cgc]}|j���c}�}|jtk7r�|js�||z
}|rNd}|jd|jjz�t|�D]}|jd|z��||z
}|rNd}|jd|jjz�t|�D]}|jd|z��||z}	|jdt|	�z�|	D�]}
	t|j|
|j|j|j|j ��}	t|j|
|j|j|j|j ��}
||
k(r�|jj$�r:|jd�|jd|j&�d
|jj�d��|jd|
j&�d
|
jj�d��|jd�n�|jd�|jd|j&�d
|jj�d��|jd|
j&�d
|
jj�d��|j|j(�|jd�d}|j|_
|
j|_
��|Scc}wcc}w#t"$r"}|jd	|
�d
|���Yd}~��9d}~wwxYw#t"$r"}|jd	|
�d
|���Yd}~��gd}~wwxYw)NTz!
* DN lists have different size: z != Fz
* DNs found only in %s:rz
* Objects to be compared: %d)r�rqr9rBr r!zLdbError for dn z: z
Comparing:�'z' [�]z    OKz
    FAILED)r}rHr,r�ryrAr$rr�r+r�rVr�r9rBr r!r
r*rqrZ)rBr�rRrl�self_dns�	other_dns�	self_onlyrW�
other_only�
common_dnsrq�object1r\�object2s              rI�diffzLDAPBundle.diff�s%�����9�9��
�
�"��H�H�T�Y�Y�PU�PZ�PZ�[�\��'�'����4�<�<�8�a����	�8�9���E�M�M�:�q�����:�;�	����
�*�4�3G�3G� �9�,�I�������4�t�x�x�}�}�D�E��	�*�*�A��H�H�W�q�[�)�*�#�X�-�J�������4�u�y�y�~�~�E�F��
�+�*�A��H�H�W�q�[�)�*��	�)�
����1�C�
�O�C�D��$	,�B�
�$����(*�-1�\�\�15�1A�1A�*.�)�)�$�)�)�	E��
�$��	�	�(*�-2�]�]�15�1A�1A�*.�)�)�$�)�)�	E���'�!��8�8�#�#��H�H�^�,��H�H�G�J�J����8H�8H�I�J��H�H�G�J�J����8H�8H�I�J��H�H�^�,�����(�����
�
�G�K�K�4D�4D�E�F�����
�
�G�K�K�4D�4D�E�F�����.�.�/����+�,���"�?�?�D�L�#�O�O�E�M�I$	,�L�
��A9��:��B�
����R��;�<���
���
����R��;�<���
�s>�(N-�N2�)AN7�-AO%�7	O"�O�O"�%	P�.P�Pc�4�|j�dk(r|jj}n�|j�dk(r|jj}n�|j�dk(r|jj}nY|j�dk(rd|jjz}n,|j�dk(rd|jj
z}g}|js|_|jj�|_|jdk(rt|_nA|jd	k(rt|_n&|jd
k(rt|_ntd��	|jjj|j|jdg�
�}|D]$}|j%|dj'���&|S#t$r=}|j\}}|j j#d|jz��d}~wwxYw)z� Query LDAP server about the DNs of certain naming self.con.ext Domain (or Default), Configuration, Schema.
            Parse all DNs and filter those that are 'strange' or abnormal.
        rtrurvrwzDC=DomainDnsZones,%srxzDC=ForestDnsZones,%sr�BASE�ONEz0Wrong 'scope' given. Choose from: SUB, ONE, BASErqrZzFailed search of base=%s
N)rAr�r/r3r5r1r#r$rrrr�r"rOr
rar rAr��get_linearized)	rBrzr#ryrR�e3r]r^rWs	         rIr{zLDAPBundle.get_dn_list)s����=�=�?�h�&��(�(�*�*�K�
�]�]�_��
/��(�(�,�,�K�
�]�]�_��
(��(�(�,�,�K�
�]�]�_��
+�0�4�8�8�3C�3C�C�K�
�]�]�_��
+�0�4�8�8�3C�3C�C�K������*�D�� �-�-�3�3�5�������%� -�D��
�
�
�&�
(� *�D��
�
�
�%�
'� .�D���O�P�P�	��(�(�,�,�%�%�4�+;�+;�4�CT�CT�]a�\b�%�c�C�
�	5�A��N�N�1�T�7�1�1�3�4�	5����
�	��7�7�L�T�4��I�I�O�O�8�4�;K�;K�K�L���	�s�)=G�	H�8H�Hc��tt|jd��|jd<tt|jd��|jd<|jdro|jd|jj
z�|jdj
|jdD�cgc]}td|z���c}��|jdrh|jd�|jdj
|jdD�cgc]}td|z���c}��g|jd<yycc}wcc}w)Nr^r_z
Attributes found only in %s:rz
    z"
Attributes with different values:)rvr�r9rHr�r+�joinr-)rBrWs  rI�
print_summaryzLDAPBundle.print_summaryNs
��'+�C����^�0L�,M�'N����^�$�)-�c�$�,�,�?O�2P�.Q�)R����%�&��<�<��'��H�H�5����
�
�E�F��H�H�R�W�W�t�|�|�N�?[�\�!�c�.�1�"4�5�\�]�^��<�<�(�)��H�H�:�;��H�H�R�W�W�t�|�|�L\�?]�^�!�c�.�1�"4�5�^�_�`�-/�D�L�L�)�*�*��]��_s�;E�"E)r�r�r�r�r�r�rJrHr�r�r{r�r�rKrIroro�s6��48�d��j�j�s�z�z�%&�N(�,�G�R#�J0rKroc��eZdZdZdZejejejd�Z	gd�Z
eddddd	d
��edd
ddd	d��eddddd	d��edddd	d��edddd	d��edddddgd��ed d!d"d#�$�ed%d&d"d'�$�ed(d)d*gd+�d,��ed-d.d"d/�$�ed0d1dd	d2��gZ				d5d4�Z
y3)6�cmd_ldapcmpzCompare two ldap databases.zO%prog <URL1> <URL2> (domain|configuration|schema|dnsdomain|dnsforest) [options])�	sambaopts�versionopts�credopts)�URL1�URL2z	context1?z	context2?z	context3?z	context4?z	context5?z-wz--tworD�
store_trueFz"Hosts are in two different domains)�dest�action�default�helpz-qz--quietr&z1Do not print anything but relay on just exit codez-vz	--verboser*z*Print all DN pairs that have been comparedz--sdr'z,Compare nTSecurityDescriptor attributes onlyz--sort-acesr(z=Sort ACEs before comparison of nTSecurityDescriptor attributez--viewr)rrYzUDisplay mode for nTSecurityDescriptor results. Possible values: section or collision.)r�r��choicesr�z--baserErz:Pass search base that will build DN list for the first DC.)r�r�r�z--base2�base2znPass search base that will build DN list for the second DC. Used when --two or when compare two different DNs.z--scoperFr)rr�r�z>Pass search scope that builds DN list. Options: SUB, ONE, BASEz--filter�filterz>List of comma separated attributes to ignore in the comparisonz--skip-missing-dnr,zCSkip report and failure due to missing DNs in one server or anotherNc��|j�}|jd�xs|jd�}|r|j|d��}nd}|j|d��}|j	�r|}n"|jd�|j
d�|r|j�std��g}|�
|r|rdg}nSgd	�}nN|||||fD]D}|��|j�d	vrtd
|z��|j|j���F|
r
|	rtd��|s|s|r
|std��t|||||	|||
|
|||j|j|�
�}t|j�dkDsJ�t|||||	|||
|
|||j|j|�
�}t|j�dkDsJ�|j!d�}d}|D�]Z} |	s|jj#d| z�t%|| ||j|j��}!t%|| ||j|j��}"|!j'|"�r"|	r��|jj#d| z���|	s�|jj#d| z�|s�t|!j(d�t|"j(d�k(sJ�g|"j(d<|jj#d�|jj#d�|!j+�|"j+�d}��]|dk7rtd|z��y)N�ldapT)�fallback_machineF)�guessrz3You must supply at least one username/password pairrtrszIncorrect argument: %sz-You cannot set --verbose and --quiet togetherz<You need to specify both --base and --base2 at the same time)rDr&r'r(r*r)rErFr r!r,rrz
* Comparing [%s] context...
)rzrBr r!z
* Result for [%s]: SUCCESS
z
* Result for [%s]: FAILURE
r_z	
SUMMARY
z
---------
���zCompare failed: %d)�get_loadparmr�get_credentials�get_credentials2�is_anonymous�
set_domain�set_workstation�authentication_requestedrrAr�rr r!rVr/rbrAror�r9r�)#rBr�r��context1�context2�context3�context4�context5rDr&r*r'r(r)rEr�rFr�r�r�r�r,r�
using_ldaprC�creds2�contextsr��con1�con2rB�statusrz�b1�b2s#                                   rI�runzcmd_ldapcmp.run�s1���
#�
#�
%���_�_�V�,�G�����0G�
���,�,�R�$�,�G�E��E��*�*�2�U�*�;����� ��F����b�!��"�"�2�&��e�<�<�>��T�U�U�������%�:��[����(�H�h�G�
+���9���w�w�y�$c�c�&�'?�!�'C�D�D�������	�*�
+��u��N�O�O���D���]�^�^���e�R��u��y� '�d��U�!�Y�Y�T�Y�Y��Y���4�<�<� �1�$�$�$���f�b��u��y� '�d��e�!�Y�Y�T�Y�Y��Y���4�<�<� �1�$�$�$��l�l�3�'�����	�G���	�	��� A�G� K�L��D�'�{�!%������<�B��D�'�{�!%������<�B��w�w�r�{���I�I�O�O�$D�$+�%,�-���I�I�O�O�$D�w�$N�O�%�"�2�:�:�.>�#?�@�C��
�
�Sc�Hd�De�e�e�e�79��
�
�#3�4��	�	���
�6��	�	���
�6��(�(�*��(�(�*���1	�2�Q�;��3�f�<�=�=�rK)NNNNNFFFFFrrrrrNNNF)r�r�r��__doc__�synopsisr�SambaOptions�VersionOptions�CredentialsOptionsDouble�takes_optiongroups�
takes_argsr
�
takes_optionsr�r�rKrIr�r�\s=��%�`�H��)�)��-�-��4�4���c�J�	�t�W�5��u�8�	:��t�Y�W�\�5�G�	I��t�[�y��u�@�	B��v�L��u�B�	D��}�;�|�U�S�	U��x�f�i�)�[�AY�k�	m��x�f�b�P�	R��y�w��E�	F��y�w��?U�T�	V��z��"�T�	V��"�):�<�Y^�Y�	[�+�M�4RV�OT�CE�MR�	W>rKr�)rr:r��samba�samba.getopt�getoptrr�	samba.ndrr�samba.dcerpcrr"rrrr	r
�samba.netcmdrrr
�compileri�objectrr�r�ror�r�rKrI�<module>r�s���0
�	�
���� �!�W�W����2�:�:�?�@��_�v�_�Dr;��r;�jg��g�T	m0��m0�`|>�'�|>rK

Zerion Mini Shell 1.0