%PDF- %PDF-
Mini Shell

Mini Shell

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

�

�I�d�W����ddlZddlZddlZddlmZddlmZmZmZddl	m
Z
ddlmZm
Z
ddlmZGd�de�ZGd	�d
e�Zed�ej*j-�D��ZGd�d
e�ZGd�de�ZGd�de�ZGd�de�ZGd�de�ZGd�de�ZGd�de�ZGd�de�ZGd�de�Z Gd�de�Z!Gd �d!e�Z"d"�Z#d#�Z$d$�Z%y)%�N)�dsdb)�drsblobs�drsuapi�misc)�dsdb_Dn)�
ndr_unpack�ndr_pack)�Counterc��eZdZy)�KCCErrorN)�__name__�
__module__�__qualname__���5/usr/lib/python3/dist-packages/samba/kcc/kcc_utils.pyrr%s��rrc�*�eZdZedd�\ZZZZZy)�NCTyper�N)	r
rr�range�unknown�schema�domain�config�applicationrrrrr)s��5:�1�a�[�2�W�f�f�f�krrc#�<K�|]\}}|dddk7s�||f���y�w)N��__r)�.0�k�vs   r�	<genexpr>r".s$����N�T�Q���"�1���
�1�a�&�N�s��	c�4�eZdZdZd�Zd�Zd�Zd�Zd�Zd�Z	y)	�
NamingContextz�Base class for a naming context.

    Holds the DN, GUID, SID (if available) and type of the DN.
    Subclasses may inherit from this and specialize
    c�X�||_d|_d|_tj|_y)zKInstantiate a NamingContext

        :param nc_dnstr: NC dn string
        N)�nc_dnstr�nc_guid�nc_sidrr�nc_type��selfr&s  r�__init__zNamingContext.__init__8s$��
!��
��������~�~��rc��|jj�d�d|jzzdt|j�zz}|j
�|dz}n|dz}|dt|j�d|j�d�z}|S)	�!Debug dump string output of class�:z
	nc_dnstr=%sz
	nc_guid=%sz
	nc_sid=<absent>z
	nc_sid=<present>z

	nc_type=� (�))�	__class__r
r&�strr'r(�
nctype_lutr)�r+�texts  r�__str__zNamingContext.__str__Bs������/�/�1� �4�=�=�0�1��#�d�l�l�"3�3�4���;�;���/�/�D��0�0�D��z�$�,�,�/G�/3�|�|�=�=���rc��ddg}	|j|jtj|��}|d}d|vr0tj|jd|dd��|_
d|vr
|dd|_|j�J�y#tj$r0}|j
\}}t
d|j�d|�d���d}~wwxYw)N�
objectGUID�	objectSid��base�scope�attrszUnable to find naming context (�) - (r1r)�searchr&�ldb�
SCOPE_BASE�LdbError�argsrr�GUID�schema_format_valuer'r()r+�samdbr>�res�e�enum�estr�msgs        r�load_nczNamingContext.load_ncQs�������	2��,�,�D�M�M�%(�^�^�5��B�C��!�f���3���9�9�U�%>�%>�|�%(��%6�q�%9�&;�<�D�L��#���k�*�1�-�D�K��|�|�'�'�'���|�|�	2��6�6�L�T�4�� �M�M�4�1�2�
2��	2�s�,B�C�+C	�	Cc�z�|jtjk7sJ�|jtjk(S)zReturn True if NC is config)r)rrr�r+s r�	is_configzNamingContext.is_configes+���|�|�v�~�~�-�-�-��|�|�v�}�}�,�,rc��|j�|j|�|jt|j	��k(rt
j|_y|jt|j��k(rt
j|_y|j�t
j|_yt
j|_y)zoGiven an NC object, identify what type is is thru
           the samdb basedn strings and NC sid value
        N)
r'rMr&r3�get_schema_basednrrr)�get_config_basednrr(rr)r+rGs  r�identify_by_basednz NamingContext.identify_by_basednjs����<�<���L�L����=�=�C�� 7� 7� 9�:�:�!�=�=�D�L�
�]�]�c�%�"9�"9�";�<�
<�!�=�=�D�L�
�[�[�
$�!�=�=�D�L�!�-�-�D�Lrc��|dk(rtj|_n1|dk(rtj|_n|dk(r|j|�|jtjk(r|j|�yy)a>Given an NC which has been discovered thru the
        nTDSDSA database object, determine what type of NC
        it is (i.e. schema, config, domain, application) via
        the use of the schema attribute under which the NC
        was found.

        :param attr: attr of nTDSDSA object where NC DN appears
        �msDS-HasDomainNCs�hasPartialReplicaNCs�hasMasterNCsN)rrr)rTr�r+rG�attrs   r�identify_by_dsa_attrz"NamingContext.identify_by_dsa_attr�sk���&�&�!�=�=�D�L��+�
+�!�=�=�D�L��^�
#��#�#�E�*��<�<�6�>�>�)��#�#�E�*�*rN)
r
rr�__doc__r,r7rMrPrTr[rrrr$r$1s%���&�
�(�(-�
.�.+rr$c�|�eZdZdZd�Zd�Zdd�Zd�Zd�Zd�Z	d�Z
d	�Zd
�Zdd�Z
d�Zd
�Zd�Zd�Zd�Zd�Zdd�Zy)�	NCReplicaz�Naming context replica that is relative to a specific DSA.

    This is a more specific form of NamingContext class (inheriting from that
    class) and it identifies unique attributes of the DSA's replica for a NC.
    c���|j|_|j|_d|_d|_d|_d|_d|_g|_	g|_
d|_tj||�y)z�Instantiate a Naming Context Replica

        :param dsa_guid: GUID of DSA where replica appears
        :param nc_dnstr: NC dn string
        FrN)�	dsa_dnstr�
rep_dsa_dnstr�dsa_guid�rep_dsa_guid�rep_default�rep_partial�rep_ro�rep_instantiated_flags�rep_fsmo_role_owner�rep_repsFrom�
rep_repsTo�rep_present_criteria_oner$r,)r+�dsar&s   rr,zNCReplica.__init__�sr��!�]�]����L�L��� ��� ������&'��#�#'�� �������).��%�	���t�X�.rc���d|jjzd|jzzd|jzzd|jzzd|j
zzd|jzzd|j�zzd|jzzd	jd
�|jD��zd	jd�|jD��z}tj|��d|��S)
r.�%s:�
	dsa_dnstr=%s�
	dsa_guid=%sz
	default=%s�
	ro=%sz
	partial=%sz
	present=%sz
	fsmo_role_owner=%s�c3�&K�|]	}d|z���y�w��
%sNr�r�reps  rr"z$NCReplica.__str__.<locals>.<genexpr>�s����A��v��|�A���c3�&K�|]	}d|z���y�wrtrrvs  rr"z$NCReplica.__str__.<locals>.<genexpr>�s����?��v��|�?�rx�
)r2r
rarcrdrfre�
is_presentrh�joinrirjr$r7r5s  rr7zNCReplica.__str__�s����t�~�~�.�.�.�!�D�$6�$6�6�7� �4�#4�#4�4�5� �$�"2�"2�2�3��T�[�[�(�	)�
 �$�"2�"2�2�3� �$�/�/�"3�3�
4�(�$�*B�*B�B�C��w�w�A�t�/@�/@�A�A�B��w�w�?�t���?�?�	@��)�0�0��6��=�=rc��||_y)z*Set or clear NC replica instantiated flagsN)rg)r+�flagss  r�set_instantiated_flagsz NCReplica.set_instantiated_flags�s
��&+��#rc��|dk(rd|_d|_n�|dk(rd|_n�|dk(r[d|_|jt	|j��k7rU|jt	|j
��k7r/d|_n'|dk(rd|_d|_n|dk(rd|_d|_tj|||�y)	z�Given an NC which has been discovered thru the
        nTDSDSA database object, determine what type of NC
        replica it is (i.e. partial, read only, default)

        :param attr: attr of nTDSDSA object where NC DN appears
        rWTrVrX�msDS-hasFullReplicaNCs�msDS-hasMasterNCsFN)
rerkrdr&r3rRrSrfr$r[rYs   rr[zNCReplica.identify_by_dsa_attr�s����)�)�#�D��,0�D�)�
�(�
(�#�D���^�
#�,0�D�)��}�}��E�$;�$;�$=� >�>��}�}��E�$;�$;�$=� >�>�#'�� ��-�
-�,0�D�)��D�K��(�
(�,0�D�)��D�K�
	�*�*�4���=rc��|jS)zMWhether this is a default domain for the dsa that this NC appears on
        )rdrOs r�
is_defaultzNCReplica.is_defaults�����rc��|jS)z&Return True if NC replica is read only)rfrOs r�is_rozNCReplica.is_ros���{�{�rc��|jS)z$Return True if NC replica is partial)rerOs r�
is_partialzNCReplica.is_partials�����rc�^�|jr!|jtjzdk(ryy)a7Given an NC replica which has been discovered thru the
        nTDSDSA database object and populated with replica flags
        from the msDS-HasInstantiatedNCs; return whether the NC
        replica is present (true) or if the IT_NC_GOING flag is
        set then the NC replica is not present (false)
        rTF)rkrgr�INSTANCE_TYPE_NC_GOINGrOs rr{zNCReplica.is_presents,���(�(��&�&��)D�)D�D��I��rc��	|j|jtjdg��}|d}d|vrW|dD]N}	ttj|�}t|j|�}
|jj!|
��Pyy#tj$r0}|j
\}}t
d|j�d|�d���d}~wwxYw#t$r(}	td|ztj�	�Yd}	~	��d}	~	wwxYw)
a*Given an NC replica which has been discovered thru the nTDSDSA
        database object, load the repsFrom attribute for the local replica.
        held by my dsa.  The repsFrom attribute is not replicated so this
        attribute is relative only to the local DSA that the samdb exists on
        �repsFromr;�Unable to find NC for (r?r1Nrzbad repsFrom NDR: %r��file)r@r&rArBrCrDrrr�repsFromToBlob�RuntimeError�print�sys�stderr�
RepsFromTori�append)r+rGrH�e1rJrKrL�value�unpackedrIrws           r�
load_repsFromzNCReplica.load_repsFrom%s���	2��,�,�D�M�M����&0�\��3�C��!�f������Z��
.���)�(�*A�*A�5�I�H�
!�����9���!�!�(�(��-�
.����|�|�	2��7�7�L�T�4�� �M�M�4�1�2�
2��	2��$���0�E�:�"�z�z�+�����/�-B�C�C�#+C�C�	D�D�Dc��d}g}g}|jD]h}|jr|j|�d}�#|j�r|j	�d}|jt|j���j|D]}|jj|��g}|r|rytj�}tj||j�|_tj|tjd�|d<	|j|�y#tj $r!}t#d|j�d|�d���d}~wwxYw)zCommit repsFrom to the databaseFTNr�zCould not set repsFrom for (r?r1)ri�
to_be_deletedr��is_modified�set_unmodifiedr	�ndr_blob�removerA�Message�Dnr&�dn�MessageElement�FLAG_MOD_REPLACE�modifyrCr)	r+rG�ror��newreps�delrepsr��mrKs	         r�commit_repsFromzNCReplica.commit_repsFromBs4���������)�)�	8�H��%�%����x�(�����#�#�%��'�'�)���
�N�N�8�H�$5�$5�6�7�'	8�, �	/�H����$�$�X�.�	/�������K�K�M���v�v�e�T�]�]�+���
���w��(<�(<�j�I�	
�*�
�	2��L�L��O���|�|�	2�� �M�M�4�1�2�
2��	2���	D�E�.E
�
Ec���	|j|jtjdg��}|d}d|vre|dd}ttj|�}|jdk7rtd	|jz��|jj|_yg|_y#tj$r0}|j
\}}t
d|j�d|�d���d}~wwxYw)
aFGiven an NC replica which has been discovered thru the nTDSDSA
        database object, load the replUpToDateVector attribute for the
        local replica. held by my dsa. The replUpToDateVector
        attribute is not replicated so this attribute is relative only
        to the local DSA that the samdb exists on

        �replUpToDateVectorr;r�r?r1Nrrz(Unexpected replUpToDateVector version %d)r@r&rArBrCrDrrr�replUpToDateVectorBlob�version�AttributeError�ctr�cursors�rep_replUpToDateVector_cursors)	r+rGrH�e2rJrKrLr��blobs	         r�load_replUpToDateVectorz!NCReplica.load_replUpToDateVector�s���	2��,�,�D�M�M����&:�%;��=�C��!�f�� �3�&��,�-�a�0�E��h�=�=�#�%�D��|�|�q� �$�%O�'+�|�|�&4�5�5�37�(�(�2B�2B�D�/�24�D�/��'�|�|�	2��7�7�L�T�4�� �M�M�4�1�2�
2��	2�s�-B%�%C(�8+C#�#C(c�F�djd�|jD��S)Nrzc3�LK�|]}|js�t|����y�w�N)r�r3�r�xs  rr"z2NCReplica.dumpstr_to_be_deleted.<locals>.<genexpr>�s����N�A�a�o�o��Q��N�s�$�$�r|rirOs r�dumpstr_to_be_deletedzNCReplica.dumpstr_to_be_deleted�����y�y�N��):�):�N�N�Nrc�F�djd�|jD��S)Nrzc3�TK�|] }|j�s�t|����"y�wr�)r�r3r�s  rr"z3NCReplica.dumpstr_to_be_modified.<locals>.<genexpr>�s����N�A�a�m�m�o��Q��N�s�(�(r�rOs r�dumpstr_to_be_modifiedz NCReplica.dumpstr_to_be_modified�r�rc��	|j|jtjdg��}|d}d|vr|d|_yy#tj$r0}|j
\}}t
d|j�d|�d���d}~wwxYw)z�Given an NC replica which has been discovered thru the nTDSDSA
        database object, load the fSMORoleOwner attribute.
        �
fSMORoleOwnerr;r�r?r1Nr)r@r&rArBrCrDrrh)r+rGrH�e3rJrKrLs       r�load_fsmo_roleszNCReplica.load_fsmo_roles�s���	2��,�,�D�M�M����&5�%6��8�C��!�f���c�!�'*�?�';�D�$�"���|�|�	2��7�7�L�T�4�� �M�M�4�1�2�
2��	2�s�-A�B�+B�Bc�<�|j�|j|k(ryy)NTF)rh�r+r`s  r�is_fsmo_role_ownerzNCReplica.is_fsmo_role_owner�s"���#�#�/��#�#�y�0��rc��	|j|jtjdg��}|d}d|vrW|dD]N}	ttj|�}t|j|�}
|jj!|
��Pyy#tj$r0}|j
\}}t
d|j�d|�d���d}~wwxYw#t$r(}	td|ztj�	�Yd}	~	��d}	~	wwxYw)
a�Given an NC replica which has been discovered thru the nTDSDSA
        database object, load the repsTo attribute for the local replica.
        held by my dsa.  The repsTo attribute is not replicated so this
        attribute is relative only to the local DSA that the samdb exists on

        This is responsible for push replication, not scheduled pull
        replication. Not to be confused for repsFrom.
        �repsTor;r�r?r1Nrzbad repsTo NDR: %rr�)r@r&rArBrCrDrrrr�r�r�r�r�r�rjr�)r+rGrH�e4rJrKrLr�r�rIrws           r�load_repsTozNCReplica.load_repsTo�s���	2��,�,�D�M�M����&.�Z��1�C��!�f���s�?��X��
,���)�(�*A�*A�5�I�H�
!�����9�����&�&�s�+�
,����|�|�	2��7�7�L�T�4�� �M�M�4�1�2�
2��	2��$���.�%�8�"�z�z�+����r�c��d}g}g}|jD]h}|jr|j|�d}�#|j�r|j	�d}|jt|j���j|D]}|jj|��g}|r|rytj�}tj||j�|_tj|tjd�|d<	|j|�y#tj $r!}t#d|j�d|�d���d}~wwxYw)zCommit repsTo to the databaseFTNr�zCould not set repsTo for (r?r1)rjr�r�r�r�r	r�r�rAr�r�r&r�r�r�r�rCr)	r+rGr�r�r�r�r�r�rKs	         r�
commit_repsTozNCReplica.commit_repsTo�s.���������o�o�	6�F��#�#����v�&�����!�!�#��%�%�'���
�N�N�8�F�O�O�4�5�'	6�,�	+�F��O�O�"�"�6�*�	+�������K�K�M���v�v�e�T�]�]�+���
���w��(<�(<�h�G�	
�(��	2��L�L��O���|�|�	2�� �M�M�4�1�2�
2��	2�r�N)r�F)r
rrr\r,r7rr[r�r�r�r{r�r�r�r�r�r�r�r�r�rrrr^r^�sb���/�>
>�,�/>�b �
� �
�.�:=2�~5�BO�O�<�&�,�@=2rr^c��eZdZd�Zd�Zd�Zd�Zd�Zd�Zd�Z	d�Z
d	�Zd
�Zd�Z
d�Zd
�Zd�Zdd�Zd�Zd�Zd�Zd�Zd�Zd�Zy)�DirectoryServiceAgentc��||_d|_d|_d|_d|_d|_d|_d|_i|_i|_	i|_
y)z�Initialize DSA class.

        Class is subsequently fully populated by calling the load_dsa() method

        :param dsa_dnstr:  DN of the nTDSDSA
        NFr)r`rb�dsa_ivid�	dsa_is_ro�dsa_is_istg�options�dsa_behavior�
default_dnstr�current_rep_table�needed_rep_table�
connect_tabler�s  rr,zDirectoryServiceAgent.__init__#s]��#�����
���
���� ���������!���"$���!#���
 ��rc��d|jjz}|j�|d|jzz}|j�|dt	|j�zz}|j
�|dt	|j
�zz}|d|j
�zd|j�zzd|j�zzdzd	|j�zzd
zd	|j�zzdzd	|j�zzz
}|S)r.rnrorpz
	dsa_ivid=%srqz
	gc=%sz	
	istg=%sz
current_replica_table:ruz
needed_replica_table:z
connect_table:)r2r
r`rbr3r�r��is_gc�is_istg�dumpstr_current_replica_table�dumpstr_needed_replica_table�dumpstr_connect_tabler5s  rr7zDirectoryServiceAgent.__str__@s&���t�~�~�.�.�.���>�>�%��,�t�~�~�=�=�D��=�=�$��+�c�$�-�-�.@�@�@�D��=�=�$��+�c�$�-�-�.@�@�@�D���d�j�j�l�*��d�j�j�l�*�+������.�/�+�+���;�;�=�=�	>�
*�*���:�:�<�<�
=�#�#���3�3�5�5�6�	6���rc�8�|jj|�Sr�)r��getr*s  r�get_current_replicaz)DirectoryServiceAgent.get_current_replicaWs���%�%�)�)�(�3�3rc�6�|jxs|jS)zAReturns True if dsa is intersite topology generator for it's site)r�r�rOs rr�zDirectoryServiceAgent.is_istgZs�����1�4�>�>�1rc��|jS)z1Returns True if dsa a read only domain controller)r�rOs rr�zDirectoryServiceAgent.is_ro_s���~�~�rc�F�|jtjzdk7ryy)z*Returns True if dsa hosts a global catalogrTF)r�r�DS_NTDSDSA_OPT_IS_GCrOs rr�zDirectoryServiceAgent.is_gccs���L�L�4�4�4�4��:��rc�$�|j|k\ryy)z�Is dsa at minimum windows level greater than or equal to (version)

        :param version: Windows version to test against
            (e.g. DS_DOMAIN_FUNCTION_2008)
        TF)r�)r+r�s  r�is_minimum_behaviorz)DirectoryServiceAgent.is_minimum_behavioris������'��rc�F�|jtjzdk7ryy)z>Whether this allows NTDSConnection translation in its options.rTF)r�r�%DS_NTDSDSA_OPT_DISABLE_NTDSCONN_XLATErOs r�is_translate_ntdsconn_disabledz4DirectoryServiceAgent.is_translate_ntdsconn_disabledss���L�L�4�E�E�E�!�K��rc�2�|j|jfS)z5Return DSA current and needed replica tables
        )r�r�rOs r�get_rep_tablesz$DirectoryServiceAgent.get_rep_tablesys���%�%�t�'<�'<�<�<rc�D�|jjd�\}}}|S)z(Get the parent DN string of this object.�,)r`�	partition)r+�head�sep�tails    r�get_parent_dnstrz&DirectoryServiceAgent.get_parent_dnstr~s!���.�.�2�2�3�7���c�4��rc��gd�}	|j|jtj|��}|d}tj|jd|dd��|_
d	|vr0tj|jd|d	d��|_d
|vrt|d
d�|_
d|vrt|dd�dk(rd
|_nd|_d|vrt|dd�|_|j#|�|j%|�y#tj$r0}|j
\}}t
d|j�d|�d���d}~wwxYw)z�Load a DSA from the samdb.

        Prior initialization has given us the DN of the DSA that we are to
        load.  This method initializes all other attributes, including loading
        the NC replica table for this DSA.
        )r9�invocationIDr��msDS-isRODC�msDS-Behavior-Versionr;zUnable to find nTDSDSA for (r?r1Nrr9�invocationIdr�r��TRUETFr�)r@r`rArBrCrDrrrErFrbr��intr�r3r�r��load_current_replica_table�load_connection_table)r+rGr>rH�e5rJrKrLs        r�load_dsazDirectoryServiceAgent.load_dsa�sf��*��
	3��,�,�D�N�N�#�.�.�%*��,�C��!�f���	�	�%�";�";�L�"%�l�"3�A�"6�#8�9��
�
�S� � �I�I�e�&?�&?��&)�.�&9�!�&<�'>�?�D�M�����s�9�~�a�0�1�D�L��C��C��M�(:�1�(=�$>�&�$H�!�D�N�"�D�N�"�c�)� #�C�(?�$@��$C� D�D��	
�'�'��.�	
�"�"�5�)��=�|�|�	3��7�7�L�T�4�� �N�N�D�2�3�
3��	3�s�,D�E�,+E�Ec���gd�}	|j|jtj|��}i}t|d�dkDr�|dj�D]�}|dk(r�	|d|D]�}	t||	jd	��}
|
j�}t|
j�}||vrt||�}
|
||<n||}
|d
k(r|
j|��u|
j!||�|
j#�s��||_����||_yt
d|jz��#tj$r0}|j
\}}t
d|j�d|�d���d}~wwxYw)a#Method to load the NC replica's listed for DSA object.

        This method queries the samdb for (hasMasterNCs, msDS-hasMasterNCs,
        hasPartialReplicaNCs, msDS-HasDomainNCs, msDS-hasFullReplicaNCs, and
        msDS-HasInstantiatedNCs) to determine complete list of NC replicas that
        are enumerated for the DSA.  Once a NC replica is loaded it is
        identified (schema, config, etc) and the other replica attributes
        (partial, ro, etc) are determined.

        :param samdb: database to query for DSA replica list
        )rXr�rWrVr��msDS-HasInstantiatedNCsr;z Unable to find nTDSDSA NCs for (r?r1Nrr��utf8rzNo nTDSDSA NCs for (%s))r@r`rArBrCrDr�len�keysr�decode�get_binary_integerr3r�r^rr[r�r�r�)r+rG�ncattrsrH�e6rJrK�	tmp_tabler r��dsdnr~�dnstrrws              rrz0DirectoryServiceAgent.load_current_replica_table�s��

��	3��,�,�D�N�N�#�.�.�%,��.�C��	��s�1�v�;��?���V�[�[�]�
3����9��
!��V�A�Y�3�E�#�5�%�,�,�v�*>�?�D� �3�3�5�E�����L�E��I�-�'��e�4��+.�	�%�(�'��.���5�5��2�2�5�9� ��,�,�U�A�6��~�~�'�-2��*�-3�
3�D"+����4�t�~�~�E�F�F��a�|�|�	3��7�7�L�T�4�� �N�N�D�2�3�
3��	3�s�,D,�,E/�?+E*�*E/c�6�||j|j<y)z]Method to add a NC replica that "should be present" to the
        needed_rep_table.
        N)r�r&)r+rws  r�add_needed_replicaz(DirectoryServiceAgent.add_needed_replicas��/2����c�l�l�+rc��	|j|jtjd��}|D]Q}t|j�}||jvr�'t|�}|j|�||j|<�Sy#tj$r0}|j
\}}t
d|j�d|�d���d}~wwxYw)z�Method to load the nTDSConnections listed for DSA object.

        :param samdb: database to query for DSA connection list
        z(objectClass=nTDSConnection)�r<r=�
expression�#Unable to find nTDSConnection for (r?r1N)r@r`rA�
SCOPE_SUBTREErCrDrr3r�r��NTDSConnection�load_connection)	r+rGrH�e7rJrKrLr�connects	         rrz+DirectoryServiceAgent.load_connection_tables���
	3��,�,�D�N�N�%(�%6�%6�*H��J�C��
	0�C�����K�E���*�*�*��$�U�+�G��#�#�E�*�(/�D���u�%�
	0���|�|�	3��7�7�L�T�4�� �N�N�D�2�3�
3��	3�s�,B�C�+C�Cc�L�g}|jj�D]q\}}|jr|j||�|jr|j||�|js�O|j||�|j|��s|D]}|j|=�y)a{Method to commit any uncommitted nTDSConnections
        modifications that are in our table.  These would be
        identified connections that are marked to be added or
        deleted

        :param samdb: database to commit DSA connection list to
        :param ro: if (true) then perform internal operations but
            do not write to the database (readonly)
        N)	r��items�to_be_added�commit_added�to_be_modified�commit_modifiedr��commit_deletedr�)r+rGr��delconnrrs      r�commit_connectionsz(DirectoryServiceAgent.commit_connections's�����"�0�0�6�6�8�		&�N�E�7��"�"��$�$�U�B�/��%�%��'�'��r�2��$�$��&�&�u�b�1����u�%�		&��	*�E��"�"�5�)�	*rc�B�||jvsJ�||j|<yr�)r�)r+rrs   r�add_connectionz$DirectoryServiceAgent.add_connectionBs&���D�.�.�.�.�.�$+����5�!rc��g}|jj�D]'}|j�|k(s�|j|��)|S)z�Scan DSA nTDSConnection table and return connection
        with a "fromServer" dn string equivalent to method
        input parameter.

        :param from_dnstr: search for this from server entry
        )r��values�get_from_dnstrr�)r+�
from_dnstr�answerrs    r�get_connection_by_from_dnstrz2DirectoryServiceAgent.get_connection_by_from_dnstrFsK�����)�)�0�0�2�	'�G��%�%�'�:�5��
�
�g�&�	'��
rc�F�djd�|jD��S)z1Debug dump string output of current replica tablerzc3�2K�|]}t|����y�wr��r3r�s  rr"zFDirectoryServiceAgent.dumpstr_current_replica_table.<locals>.<genexpr>Vs����@�A��Q��@���)r|r�rOs rr�z3DirectoryServiceAgent.dumpstr_current_replica_tableTs���y�y�@��)?�)?�@�@�@rc�F�djd�|jD��S)z0Debug dump string output of needed replica tablerzc3�2K�|]}t|����y�wr�r.r�s  rr"zEDirectoryServiceAgent.dumpstr_needed_replica_table.<locals>.<genexpr>Zs����?�A��Q��?�r/)r|r�rOs rr�z2DirectoryServiceAgent.dumpstr_needed_replica_tableXs���y�y�?��)>�)>�?�?�?rc�F�djd�|jD��S)z)Debug dump string output of connect tablerzc3�2K�|]}t|����y�wr�r.r�s  rr"z>DirectoryServiceAgent.dumpstr_connect_table.<locals>.<genexpr>^s����<�A��Q��<�r/)r|r�rOs rr�z+DirectoryServiceAgent.dumpstr_connect_table\s���y�y�<��);�);�<�<�<rc�Z�dttj��z|jz}t	|�}d|_d|_||_||_||_	|�"|j|_|j|_
|�||_nt�|_|j!||�|S)z�Set up a new connection for the DSA based on input
        parameters.  Connection will be added to the DSA
        connect_table and will be marked as "to be added" pending
        a call to commit_connections()
        zCN=%s,T)r3�uuid�uuid4r`rr�enabledr)r��system_flagsr�transport_dnstr�guid�transport_guid�schedule�new_connection_scheduler%)r+r�r8�	transportr)�schedrrs        r�new_connectionz$DirectoryServiceAgent.new_connection`s����3�t�z�z�|�,�,�t�~�~�=�� ��'��"������'���!���+���� �&/�o�o�G�#�%.�^�^�G�"���$�G�� 7�8�G�����E�7�+��rNr�)r
rrr,r7r�r�r�r�r�r�r�r�rrrrr#r%r+r�r�r�r@rrrr�r�!sp�� �:�.4�2�
����=�
�
.*�`Q+�f2�0�6*�6,��A�@�=�rr�c��eZdZdZd�Zd�Zd�Zd�Zdd�Zdd�Z	dd�Z
d	�Zd
�Zd�Z
d�Zd
�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zy)rz5Class defines a nTDSConnection found under a DSA
    c��||_d|_d|_d|_d|_d|_d|_d|_d|_d|_	d|_
d|_d|_y)NFr)
rr:r7�whenCreatedrr�rr�r8r9r;r)r<�r+rs  rr,zNTDSConnection.__init__�sd����
���	������� ���"���#���������#���"��������
rc���|jj�d|j��d|jzzd|jzzd|j
zzd|jzzd|jzzd|jzzd|jzzd	|jzz}|j�|d
t|j�zz
}|j�|dt|j�zz
}|d|jzz}|j��|d
|jj zd|jj"zzd|jj$zzz
}t'|jj(�D]n\}}|d||j*fzd||j,fzzd|zzdj/d�|jj0|j2D��zdzz
}�p|S)z1Debug dump string output of NTDSConnection object�:
	dn=z
	enabled=%sz
	to_be_added=%sz
	to_be_deleted=%sz
	to_be_modified=%sz
	options=0x%08Xz
	system_flags=0x%08Xz
	whenCreated=%dz
	transport_dn=%s�	
	guid=%s�
	transport_guid=%sz
	from_dn=%s�
	schedule.size=%s�
	schedule.bandwidth=%s�
	schedule.numberOfSchedules=%s�"
	schedule.headerArray[%d].type=%d�$
	schedule.headerArray[%d].offset=%d� 
	schedule.dataArray[%d].slots[ rrc3�&K�|]	}d|z���y�w�z0x%X Nr�r�slots  rr"z)NTDSConnection.__str__.<locals>.<genexpr>������\�4��$��\�rx�])r2r
rr7rr�rr�r8rCr9r:r3r;r)r<�size�	bandwidth�numberOfSchedules�	enumerate�headerArray�type�offsetr|�	dataArray�slots)r+r6�i�headers    rr7zNTDSConnection.__str__�s��"&���!8�!8�$�*�*�E��$�,�,�.�/�#�d�&6�&6�6�7�&��(:�(:�:�;�'��)<�)<�<�	=�
$�d�l�l�2�3�)�4�+<�+<�<�
=�$�d�&6�&6�6�7�%�t�';�';�;�<���9�9� ��M�C��	�	�N�2�2�D����*��+�c�$�2E�2E�.F�F�F�D��&����8�8���=�=�$��*�T�]�]�-?�-?�?�/�$�-�-�2I�2I�I�J�8��]�]�4�4�5�6�
6�D�
'�t�}�}�'@�'@�A�
�	��6��?��F�K�K�(�)�A��V�]�]�+�,�-�=�q�@�	A�
���\�4�=�=�;R�;R�ST�;U�;[�;[�\�\�]��
���
��rc�~�gd�}	|j|jtj|��}|d}d|vrt|dd�|_d	|vrEt|d	d�j�j�j�d
k(rd|_
d|vrt|dd�|_	tj |j#d
|d
d��|_d|vrFt)||ddj+d��}|j-|t|j.��d|vr%t1t2j4|dd�|_d|vr)tj6t|dd��|_d|vrJt)||ddj+d��}t|j.�|_|j:�J�yy#tj$r0}|j
\}}t
d|j�d|�d���d}~wwxYw#t&$rt
d|jz��wxYw)z�Given a NTDSConnection object with an prior initialization
        for the object's DN, search for the DN and load attributes
        from the samdb.
        )r��enabledConnectionr<rCr9�
transportType�
fromServer�systemFlagsr;rr?r1Nrr�rar�Trdr9z4Unable to find objectGUID in nTDSConnection for (%s)rbrr<rCrc)r@rrArBrCrDrr�r�r3�upper�lstrip�rstripr7r8rrErFr:�KeyErrorrr	�load_connection_transportr�rrr<�string_to_timerCr))	r+rGr>rH�e8rJrKrLrs	         rrzNTDSConnection.load_connection�s;��
 ��	/��,�,�D�J�J�c�n�n�%*��,�C��!�f������s�9�~�a�0�1�D�L��#�%��3�*�+�A�.�/�5�5�7�>�>�@�G�G�I�V�S�#����C�� #�C�
�$6�q�$9� :�D��	6��	�	�%�3�3�L�47��4E�a�4H�J�K�
�I��c�!��5�#�o�"6�q�"9�"@�"@��"H�I�D��*�*�5�#�d�g�g�,�?����&�x�'8�'8�#�j�/�!�:L�M�D�M��C��"�1�1�#�c�-�6H��6K�2L�M�D���3���5�#�l�"3�A�"6�"=�"=�f�"E�F�D�!�$�'�'�l�D�O��?�?�.�.�.���G�|�|�	/��7�7�L�T�4�� �J�J��.�/�
/��	/��*�	6��&�)-���5�6�
6�	6�s#�,G�50H�H�'+H�H�"H<c��dg}	|j|tj|��}d|dvr<|d}||_tj|jd|dd��|_
|j�J�|j�J�y#tj$r&}|j\}}td|�d|�d���d}~wwxYw)z�Given a NTDSConnection object which enumerates a transport
        DN, load the transport information for the connection object

        :param tdnstr: transport DN to load
        r9r;zUnable to find transport (r?r1Nr)r@rArBrCrDrr9rrErFr;)	r+rG�tdnstrr>rH�e9rJrKrLs	         rriz(NTDSConnection.load_connection_transport�s������	+��,�,�F�%(�^�^�5��B�C��3�q�6�!��a�&�C�#)�D� ��	�	�%�3�3�L�47��4E�a�4H�J�K�
���#�#�/�/�/��"�"�.�.�.���|�|�	+��7�7�L�T�4��"�D�*�+�
+��	+�s�"B�C�!B;�;Cc��|jsJ�d|_|ry	|j|j�y#tj$r0}|j
\}}t
d|j�d|�d���d}~wwxYw)z�Local helper routine for commit_connections() which
        handles committed connections that are to be deleted from
        the database database
        FNz%Could not delete nTDSConnection for (r?r1)r��deleterrArCrDr)r+rGr��e10rJrKs      rr!zNTDSConnection.commit_deleted	st��
�!�!�!�!�"�����	/��L�L����$���|�|�	/��8�8�L�T�4�� �J�J��.�/�
/��	/�s�6�A9�	+A4�4A9c�B�|jsJ�d|_|ryd}	|j|jtj��}t|�dk7rd}|rtd	|jz��|jrd
}nd}tj�}	tj||j�|	_
tjdtjd
�|	d
<tjd
tjd�|	d<tj|tjd�|	d<tj|j tjd�|	d<tjt#|j$�tjd�|	d<tjt#|j&�tjd�|	d<|j(�;tjt#|j(�tjd�|	d<|j*�;tjt-|j*�tjd�|	d<	|j/|	�y#tj$rI}|j\}}|tjk7rtd|j�d|�d���Yd}~��|d}~wwxYw#tj$r0}
|
j\}}td|j�d|�d���d}
~
wwxYw)z�Local helper routine for commit_connections() which
        handles committed connections that are to be added to the
        database
        FN�r<r=rT�Unable to search for (r?r1z'nTDSConnection for (%s) already exists!r��FALSE�nTDSConnection�objectClass�showInAdvancedViewOnlyrarcr�rdrbr<z"Could not add nTDSConnection for ()rr@rrArBrrCrD�ERR_NO_SUCH_OBJECTrr7r�r�r�r��FLAG_MOD_ADDr)r3r�r8r9r<r	�add)r+rGr��foundrL�e11rJrK�	enablestrr��e12s           rrzNTDSConnection.commit_addeds���
����� �������		3��,�,�D�J�J�c�n�n�,�E�C��3�x�1�}�����D��:�:�&�'�
'��<�<��I��I�
�K�K�M���v�v�e�T�Z�Z�(���
���/��1A�1A�,�
.�	
�-��
���v�s�'7�'7�7�
9�	
�
"�#�
���y�#�*:�*:�2�
4�	
�
��
���t����0@�0@�,�O�	
�,��
���s�4�<�<�0�#�2B�2B�I�N�	
�)��
���s�4�#4�#4�5�s�7G�7G�,�
.�	
�-�����+��"�"�3�t�';�';�#<�c�>N�>N�#2�4�
�o���=�=�$��"�"�8�D�M�M�#:�#&�#3�#3�Z�A�
�j�M�	/��I�I�a�L��[�|�|�	3��8�8�L�T�4��s�-�-�-�� $�
�
�D� 2�3�3�.��	3��\�|�|�	/��8�8�L�T�4�� �J�J��.�/�
/��	/�s/�;I<�*K�<K�>K�K�L�.+L�Lc��|jsJ�d|_|ry	|j|jtj��|jrd}nd	}tj�}tj||j�|_tj|tjd
�|d
<tj|jtjd�|d<tjt!|j"�tjd�|d<tjt!|j$�tjd
�|d
<|j&�<tjt!|j&�tjd�|d<n(tjgtj(d�|d<|j*�<tjt-|j*�tjd�|d<n(tjgtj(d�|d<	|j/|�y#tj
$r[}|j\}}|tjk(rtd|jz��td|j�d|�d���d}~wwxYw#tj
$r0}|j\}}td|j�d|�d���d}~wwxYw)z�Local helper routine for commit_connections() which
        handles committed connections that are to be modified to the
        database
        FNrsz&nTDSConnection for (%s) doesn't exist!rtr?r1r�rurarcr�rdrbr<z%Could not modify nTDSConnection for ()rr@rrArBrCrDryrr7r�r�r�r�r�r)r3r�r8r9�FLAG_MOD_DELETEr<r	r�)	r+rGr��e13rJrKr~r��e14s	         rr zNTDSConnection.commit_modifiedcs���
�"�"�"�"�#�����	/�
�L�L�d�j�j����L�?��<�<��I��I�
�K�K�M���v�v�e�T�Z�Z�(���
���y�#�*>�*>�2�
4�	
�
��
���t����0D�0D�+�
-�	
�,��
���s�4�<�<�0�#�2F�2F�(�
*�	
�)��
���s�4�#4�#4�5�s�7K�7K�,�
.�	
�-�����+��"�"�3�t�';�';�#<�#&�#7�#7��J�
�o��
�"�"�2�s�':�':�O�L�
�o���=�=�$��"�"�8�D�M�M�#:�#&�#7�#7��E�
�j�M�
�"�"�2�s�':�':�J�G�
�j�M�	/��L�L��O��]�|�|�	/��8�8�L�T�4��s�-�-�-��G�#�z�z� *�+�+�� �J�J��.�/�
/��	/��^�|�|�	/��8�8�L�T�4�� �J�J��.�/�
/��	/�s0�+I�K�K�%AJ;�;K�L�+L�Lc��||_yr�)r)r+�	truefalses  r�set_modifiedzNTDSConnection.set_modified�s
��'��rc��|j�|jjd�y|jjdjD]}|dzdk7s�yy)zzReturns True if our schedule includes at least one
        replication interval within the week.  False otherwise
        rF�T)r<r\r])r+rRs  r�!is_schedule_minimum_once_per_weekz0NTDSConnection.is_schedule_minimum_once_per_week�s]���=�=� �D�M�M�$;�$;�A�$>�$F���M�M�+�+�A�.�4�4�	�D��t���#��	�rc���|j�|duS|�y|jj|jk7sF|jj|jk7s#|jj|jk7ryt	|jj
�D]�\}}|jj
|j|j
|jk7ry|jj
|j|j
|jk7ryt|jj|j|j|j�D]
\}}||k7s�y��y)z�Returns True if our schedule is equivalent to the input
        comparison schedule.

        :param shed: schedule to compare to
        NFT)r<rUrVrWrXrYrZr[�zipr\r])r+r?r^r_�a�bs      r�is_equivalent_schedulez%NTDSConnection.is_equivalent_schedule�s>���=�=� ��D�=� ��=��
�]�]�
�
�5�:�:�
-�
�]�]�
$�
$����
7�
�]�]�
,�
,��0G�0G�
G��"�4�=�=�#<�#<�=�	!�I�A�v��}�}�(�(��+�0�0�E�4E�4E�a�4H�4M�4M�M���}�}�(�(��+�2�2�� � ��#�*�*�+���D�M�M�3�3�A�6�<�<�!�O�O�A�.�4�4�6�
!���1���6� �
!�	!�rc�F�|jtjzdk(ryy)zMReturns True if NTDS Connection specifies RODC
        topology only
        rFT)r�r�NTDSCONN_OPT_RODC_TOPOLOGYrOs r�is_rodc_topologyzNTDSConnection.is_rodc_topology�s!���<�<�$�9�9�9�Q�>��rc�F�|jtjzdk(ryy)z�Returns True if NTDS Connection was generated by the
        KCC topology algorithm as opposed to set by the administrator
        rFT)r�r�NTDSCONN_OPT_IS_GENERATEDrOs r�is_generatedzNTDSConnection.is_generated�s!���<�<�$�8�8�8�A�=��rc�F�|jtjzdk(ryy)zGReturns True if NTDS Connection should override notify default
        rFT)r�r�$NTDSCONN_OPT_OVERRIDE_NOTIFY_DEFAULTrOs r�is_override_notify_defaultz)NTDSConnection.is_override_notify_default�s!���<�<�$�C�C�C�q�H��rc�F�|jtjzdk(ryy)z:Returns True if NTDS Connection should use notify
        rFT)r�r�NTDSCONN_OPT_USE_NOTIFYrOs r�
is_use_notifyzNTDSConnection.is_use_notify�s!���<�<�$�6�6�6�!�;��rc�F�|jtjzdk(ryy)z?Returns True if NTDS Connection should use twoway sync
        rFT)r�r�NTDSCONN_OPT_TWOWAY_SYNCrOs r�is_twoway_synczNTDSConnection.is_twoway_syncs!���<�<�$�7�7�7�1�<��rc�F�|jtjzdk(ryy)zRReturns True if NTDS Connection intersite compression
        is disabled
        rFT)r�r�*NTDSCONN_OPT_DISABLE_INTERSITE_COMPRESSIONrOs r�!is_intersite_compression_disabledz0NTDSConnection.is_intersite_compression_disableds!���<�<�$�I�I�I�Q�N��rc�F�|jtjzdk(ryy)zBReturns True if NTDS Connection has a user owned schedule
        rFT)r�r� NTDSCONN_OPT_USER_OWNED_SCHEDULErOs r�is_user_owned_schedulez%NTDSConnection.is_user_owned_schedules!���<�<�$�?�?�?�1�D��rc��|jS)z3Returns True if NTDS Connection is enabled
        )r7rOs r�
is_enabledzNTDSConnection.is_enableds���|�|�rc��|jS)z%Return fromServer dn string attribute)r)rOs rr(zNTDSConnection.get_from_dnstrs�����rNr�)r
rrr\r,r7rrir!rr r�r�r�r�r�r�r�r�r�r�r�r(rrrrrsm���
�$�L7/�r/�2/�&E/�NE/�N(��&�P��������
rrc�4�eZdZdZd�Zd�Zd�Zd�Zd�Zd�Z	y)	�	Partitiona!A naming context discovered thru Partitions DN of the config schema.

    This is a more specific form of NamingContext class (inheriting from that
    class) and it identifies unique attributes enumerated in the Partitions
    such as which nTDSDSAs are cross referenced for replicas
    c�v�||_d|_d|_g|_g|_t
j
|d�y)NTr)�partstrr7r8�rw_location_list�ro_location_listr$r,)r+r�s  rr,zPartition.__init__(s:����������� "��� "���
	���t�T�*rc�H�gd�}	|j|jtj|��}|d}|j�D�]}|dk(r�
|d	k(rNt||d�j�j�j�d
k(rd|_nd|_�]|d
k(rt||d�|_�y||D]�}	t||	j!d��}
t|
j"�}|dk(r||_�@|dk(r|j&j)|��a|dk(s�g|j*j)|�����|j-|�y#tj$r0}|j
\}}t
d|j�d|�d���d}~wwxYw)a�Given a Partition class object that has been initialized with its
        partition dn string, load the partition from the sam database, identify
        the type of the partition (schema, domain, etc) and record the list of
        nTDSDSAs that appear in the cross reference attributes
        msDS-NC-Replica-Locations and msDS-NC-RO-Replica-Locations.

        :param samdb: sam database to load partition from
        )�nCName�Enabledrd�msDS-NC-Replica-Locations�msDS-NC-RO-Replica-Locationsr;zUnable to find partition for (r?r1Nrr�r�r�TFrdrr�r�r�)r@r�rArBrCrDrrr3rerfrgr7r�r8rr	r�r&r�r�r�rT)r+rGr>rH�e15rJrKrLr r�rrs            r�load_partitionzPartition.load_partition4s���1��
	1��,�,�D�L�L����%*��,�C��!�f������	�A��D�y���I�~��s�1�v�a�y�>�'�'�)�0�0�2�9�9�;�v�E�#'�D�L�#(�D�L���M�!�$'��A��q�	�N��!���Q��
���u�e�l�l�6�&:�;���D�G�G�����=�$)�D�M���3�3��)�)�0�0��7���6�6��)�)�0�0��7��
�	�B	
����&��M�|�|�	1��8�8�L�T�4�� �L�L�$�0�1�
1��	1�s�,E�F!�1+F�F!c��|jS)z-Returns True if partition is enabled
        )r�rOs rr�zPartition.is_enabledns�����rc�F�|jtjzdk(ryy)z�Returns True if this is not an Active Directory NC in our
        forest but is instead something else (e.g. a foreign NC)
        rTF)r8r�SYSTEM_FLAG_CR_NTDS_NCrOs r�
is_foreignzPartition.is_foreignss#��
���� ;� ;�;��A��rc���d}d}|jtjk(xsW|jtjk(xs8|jtjk(xr|j
|jk(}|jtjk(rE|j�r|j|jvrd}n|j|jvrd}|j�rj|jtjk(rM|j
|jk7r4|j|jvs|j|jvrd}d}|r|j�s|rd}|||fS)z�Tests whether this partition should have an NC replica
        on the target dsa.  This method returns a tuple of
        needed=True/False, ro=True/False, partial=True/False

        :param target_dsa: should NC be present on target dsa
        FT)
r)rrrrr&r�rr�r`r�r�r�)r+�
target_dsar��partial�neededs     r�should_be_presentzPartition.should_be_present|s>������
�,�,�&�-�-�/�>��,�,�&�-�-�/�>��<�<�6�=�=�0�=��=�=�J�$<�$<�<�	��<�<�6�-�-�-����!��'�'�4�+@�+@�@�!�F��'�'�4�+@�+@�@�!�F�

�����L�L�F�M�M�)��M�M�Z�5�5�5�
�
!�
!�T�%:�%:�
:�
�
!�
!�T�%:�%:�
:��F��G��z�'�'�)�W��B��r�7�"�"rc���dtj|�zd|jzzdjd�|jD��zdjd�|j
D��z}|S)r.z%sz
	partdn=%srrc3�&K�|]	}d|z���y�w)z
	msDS-NC-Replica-Locations=%sNr�rr s  rr"z$Partition.__str__.<locals>.<genexpr>�s����]�!�9�A�=�]�rxc3�&K�|]	}d|z���y�w)z!
	msDS-NC-RO-Replica-Locations=%sNrr�s  rr"z$Partition.__str__.<locals>.<genexpr>�s����`�Q�<�q�@�`�rx)r$r7r�r|r�r�r5s  rr7zPartition.__str__�sm���m�+�+�D�1�1�����-�.��w�w�]�t�G\�G\�]�]�^��w�w�`�$�J_�J_�`�`�a���rN)
r
rrr\r,r�r�r�r�r7rrrr�r�!s'���
+�8'�t�
�.#�`rr�c�^�eZdZdZd�Zd�Zd�Zd�Zd�Zd�Z	d�Z
d	�Zd
�Zd�Z
d�Zd
�Zd�Zy)�Sitez�An individual site object discovered thru the configuration
    naming context.  Contains all DSAs that exist within the site
    c�t�||_d|_d|_d|_d|_i|_i|_||_y�Nr)�
site_dnstr�	site_guid�site_options�site_topo_generator�site_topo_failover�	dsa_table�rw_dsa_table�nt_now)r+r�r�s   rr,z
Site.__init__�s>��$���������#'�� �"#�����������rc�|�d|jz}gd�}	|j|tj|��}|j|jtjdg��}|d	}	d
|	vrt|	d
d	�|_d|	vrt|	dd	�|_
d|	vrt|	dd	�|_|d	}	d|	vr0tj|jd|	dd	��|_|j!|�y#tj$r&}|j
\}}t
d|�d|�d���d}~wwxYw)
z�Loads the NTDS Site Settings options attribute for the site
        as well as querying and loading all DSAs that appear within
        the site.
        �CN=NTDS Site Settings,%s)r��interSiteTopologyFailover�interSiteTopologyGeneratorr;r9z"Unable to find site settings for (r?r1Nrr�r�r�)r�r@rArBrCrDrr�r�r3r�r�rrErFr��load_all_dsa)
r+rG�ssdnr>rH�self_res�e16rJrKrLs
          r�	load_sitezSite.load_site�sU��
*�D�O�O�;��/��	)��,�,�D����%*��,�C��|�|�������+7�.�$�:�H��!�f����� #�C�	�N�1�$5� 6�D��'�3�.��C�4�5�a�8�9�
�$�'�#�-�&)�#�.I�*J�1�*M�&N�D�#��q�k���3��!�Y�Y�u�'@�'@��'*�<�'8��';�(=�>�D�N�	
���%� ��+�|�|�	)��8�8�L�T�4�� �$�(�)�
)��	)�s�AD�D;�!D6�6D;c��	|j|jtjd��}|D]q}t|j�}||jvr�'t|�}|j|�||j|<|j�r�c||j|<�sy#tj$r"}|j
\}}t
d|z��d}~wwxYw)z�Discover all nTDSDSA thru the sites entry and
        instantiate and load the DSAs.  Each dsa is inserted
        into the dsa_table by dn string.
        z(objectClass=nTDSDSA))r=rzUnable to find nTDSDSAs - (%s)N)r@r�rArrCrDrr3r�r�r�rr�r�)	r+rGrH�e17rJrKrLrrls	         rr�zSite.load_all_dsa�s���
	D��,�,�t���%(�%6�%6�*A��C�C��	/�C�����K�E�����&��'��.�C��L�L���%(�D�N�N�5�!��9�9�;�+.��!�!�%�(�	/��	�|�|�	D��8�8�L�T�4��;�d�B�C�C��	D�s�,B%�%C�8C�Cc�8�|jj|�S)z�Return a previously loaded DSA object by consulting
        the sites dsa_table for the provided DSA dn string

        :return: None if DSA doesn't exist
        )r�r�rDs  r�get_dsazSite.get_dsas���~�~�!�!�%�(�(rc���|jrd|_|j|_yt	|�}|j|�|j
|�t|jj�d���}|jdk(rd}n|jdzdz}|jj|j�}|�|||urx|j|�}d	}	|jD]}
|j|
j k(s�d}	n|	s|}d}nM|j"
j$z
|kDrd}d}n,|}|
j$}n|j|�}|j"}||j"|z
|zzt'|�z}
||
}d|_||ury	|j|jk(ry|j|_|ryd
|j(z}t+j,�}t+j.||�|_t+j2|jt*j4d�|d<	|j7|�y#t*j8$r}t;d|�d
|�d���d}~wwxYw)alDetermine if my DC should be an intersite topology
        generator.  If my DC is the istg and is both a writeable
        DC and the database is opened in write mode then we perform
        an originating update to set the interSiteTopologyGenerator
        attribute in the NTDS Site Settings object.  An RODC always
        acts as an ISTG for itself.
        Tc�,�t|j�Sr�)r	rb)rls r�<lambda>z"Site.select_istg.<locals>.<lambda>5s��H�S�\�\�2�r)�keyrlPC�<i���NFr�r�z.Could not set interSiteTopologyGenerator for (r?r1)r�r�r`r��get_dsa_config_repr�r��sortedr�r'r�r�r��indexr�r��source_dsa_invocation_idr��last_sync_successrr�rAr�r�r�r�r�r�rCr)r+rG�mydsar��c_rep�D_sort�f�d_dsa�j_idxr|�cursor�i_idx�t_time�k_idxr�r�rKs                 r�select_istgzSite.select_istgsh���?�?� $�E��',���D�$��"�5�)��
	���E�"�
�%�%�e�,� ����$�$�&�2�4��$�"�"�a�'�&�A��'�'�"�,�x�7�A����"�"�4�#;�#;�<�����e�!3�(�L�L��'�E��E��>�>�
���>�>�V�%D�%D�D� �E��
�
�����
���v�7�7�7�!�;��������1�1���L�L��'�E��[�[�F��4�;�;��/�A�5�6�#�f�+�E���u�
�� ��������#�#�u���6��#(�?�?�� ���*�D�O�O�;���K�K�M���v�v�e�T�"���
���u����0D�0D�;�
=�	
�
&�'�	��L�L��O���	�|�|�	���t���
��	�s�.I�I*�I%�%I*c�B�|jtjzdk7S)z8Returns True if intra-site topology is disabled for siter)r�r�-DS_NTDSSETTINGS_OPT_IS_AUTO_TOPOLOGY_DISABLEDrOs r�is_intrasite_topology_disabledz#Site.is_intrasite_topology_disabled�s)���!�!��B�B�C�GH�I�	Irc�B�|jtjzdk7S)z8Returns True if inter-site topology is disabled for siter)r�r�8DS_NTDSSETTINGS_OPT_IS_INTER_SITE_AUTO_TOPOLOGY_DISABLEDrOs r�is_intersite_topology_disabledz#Site.is_intersite_topology_disabled�s'���"�"��N�N�O���	rc�B�|jtjzdk7S)z:Returns True if selection of random bridgehead is disabledr)r�r�1DS_NTDSSETTINGS_OPT_IS_RAND_BH_SELECTION_DISABLEDrOs r�is_random_bridgehead_disabledz"Site.is_random_bridgehead_disabled��)���!�!��F�F�G�KL�M�	Mrc�B�|jtjzdk7S)z1Returns True if detect stale is disabled for siter)r�r�1DS_NTDSSETTINGS_OPT_IS_TOPL_DETECT_STALE_DISABLEDrOs r�is_detect_stale_disabledzSite.is_detect_stale_disabled�r�rc�B�|jtjzdk7S)z<Returns True if NTDS Connection cleanup is disabled for siter)r�r�,DS_NTDSSETTINGS_OPT_IS_TOPL_CLEANUP_DISABLEDrOs r�is_cleanup_ntdsconn_disabledz!Site.is_cleanup_ntdsconn_disabled�s)���!�!��A�A�B�FG�H�	Hrc�<�|j|j�ryy)z"Return True if dsa is in this siteTF)r�r`)r+rls  r�	same_sitezSite.same_site�s���<�<��
�
�&��rc�f�t|j�dkDrt|j�dk(ryy)NrTF)rr�r�rOs r�is_rodc_sitezSite.is_rodc_site�s+���t�~�~���"�s�4�+<�+<�'=��'B��rc��d|jjzd|jzzd|jzzd|jzzd|j
zz}|jj�D]
\}}|d|zz}�|S)r.rnz
	dn=%sz
	options=0x%Xz
	topo_generator=%sz
	topo_failover=%dru)r2r
r�r�r�r�r�r)r+r6r�rls    rr7zSite.__str__�s����t�~�~�.�.�.��T�_�_�,�-�!�D�$5�$5�5�6�'��)A�)A�A�B�&��(?�(?�?�	@��
���,�,�.�	'�H�C���&�3�,�&�D�	'��rN)r
rrr\r,r�r�r�r�r�r�r�r�r�rrr7rrrr�r��sO����#!�J/�<)�g�RI�
�M�
M�
H�
��
	rr�c�4�eZdZdZd�Zd�Zd�Zd�Zd�Zd�Z	y)	�	GraphNodez�A graph node describing a set of edges that should be directed to it.

    Each edge is a connection for a particular naming context replica directed
    from another node in the forest to this node.
    c�.�||_||_g|_y)z�Instantiate the graph node according to a DSA dn string

        :param max_node_edges: maximum number of edges that should ever
            be directed to the node
        N)�	max_edgesr`�	edge_from)r+r`�max_node_edgess   rr,zGraphNode.__init__�s��(���"�����rc���d|jjzd|jzzd|jzz}t	|j
�D] \}}t
|t�s�|d||fzz
}�"|S)Nrnroz
	max_edges=%dz
	edge_from[%d]=%s)r2r
r`rrXr�
isinstancer3)r+r6r^�edges    rr7zGraphNode.__str__�s{���t�~�~�.�.�.�!�D�N�N�2�3�!�D�N�N�2�3��!����0�	;�G�A�t��$��$��.�!�T��:�:��	;��rc���t|t�sJ�||jk(ry||jvryt	|j�|j
k\ry|jj
|�y)z�Add an edge from the dsa to our graph nodes edge from list

        :param from_dsa_dnstr: the dsa that the edge emanates from
        FT)rr3r`rrrr�)r+�from_dsa_dnstrs  r�
add_edge_fromzGraphNode.add_edge_fromsa��
�.�#�.�.�.��T�^�^�+���T�^�^�+���t�~�~��$�.�.�0�������n�-�rc�x�|jj�D]}|j|j��y)aeFor each nTDSConnection object associated with a particular
        DSA, we test if it implies an edge to this graph node (i.e.
        the "fromServer" attribute).  If it does then we add an
        edge from the server unless we are over the max edges for this
        graph node

        :param dsa: dsa with a dnstr equivalent to his graph node
        N)r�r'rr))r+rlrs   r�add_edges_from_connectionsz$GraphNode.add_edges_from_connectionss6���(�(�/�/�1�	3�G����w�1�1�2�	3rc��|jD]x}|j|�}d}|D]}|j�r�d}�|r�3tj}tj
tjz}|j||||d��zy)z�For each edge directed to this graph node, ensure there
           is a corresponding nTDSConnection object in the dsa.
        FTN)rr+r�rr��SYSTEM_FLAG_CONFIG_ALLOW_RENAME�SYSTEM_FLAG_CONFIG_ALLOW_MOVEr@)	r+rlr>�
edge_dnstr�connections�found_validr�optr~s	         r�add_connections_from_edgesz$GraphNode.add_connections_from_edges#s����.�.�!	H�J��:�:�:�F�K� �K�&�
#���+�+�-��"��
#�
���0�0�C��9�9��7�7�8�E�
���s�E�9�j�$�G�C!	Hrc�J�t|j�|jk\ryy)z<Return True if we have met the maximum "from edges" criteriaTF)rrrrOs r�has_sufficient_edgeszGraphNode.has_sufficient_edgesJs���t�~�~��$�.�.�0��rN)
r
rrr\r,r7rrrrrrrrr�s'����	��&
3�%H�Nrrc�"�eZdZdZd�Zd�Zd�Zy)�	Transportz;Class defines a Inter-site transport found under Sites
    c�X�||_d|_d|_d|_d|_g|_yr�)rr�r:�name�address_attr�bridgehead_listrDs  rr,zTransport.__init__Us.����
������	���	� ���!��rc�(�|jj�d|j��dt|j�zzd|j
zzd|jzzd|jzzdjd�|jD��z}|S)�,Debug dump string output of Transport objectrFrG�
	options=%dz
	address_attr=%sz	
	name=%srrc3�&K�|]	}d|z���y�w)z
	bridgehead_list=%sNr)rrs  rr"z$Transport.__str__.<locals>.<genexpr>es����Z�E�/�%�7�Z�rx)
r2r
rr3r:r�r rr|r!r5s  rr7zTransport.__str__]s���"&���!8�!8�$�*�*�E��s�4�9�9�~�-�.��$�,�,�.�/�%�t�'8�'8�8�9��t�y�y�(�	)�
�w�w�Z�T�EY�EY�Z�Z�[���rc���gd�}	|j|jtj|��}|d}tj|jd|dd��|_
d	|vrt|d	d�|_d
|vrt|d
d�|_d|vrt|dd�|_d|vre|dD]\}t!||j#d
��}	t|	j$�}
|
|j&vs�B|j&j)|
��^yy#tj$r0}|j
\}}t
d|j�d|�d���d}~wwxYw)z�Given a Transport object with an prior initialization
        for the object's DN, search for the DN and load attributes
        from the samdb.
        )r9r�r�bridgeheadServerListBL�transportAddressAttributer;zUnable to find Transport for (r?r1Nrr9r�r(rr'r)r@rrArBrCrDrrrErFr:r�r�r3r rrr	r�r!r�)r+rGr>rH�e18rJrKrLr�rrs           r�load_transportzTransport.load_transportise��
.��
	/��,�,�D�J�J�c�n�n�%*��,�C��!�f���I�I�e�7�7��!�,�/��2�4�5��	�����s�9�~�a�0�1�D�L�&�#�-� #�C�(C�$D�Q�$G� H�D���S�=��C��K��N�+�D�I�#�s�*��5�6�
7���u�e�l�l�6�&:�;���D�G�G����� 4� 4�4��(�(�/�/��6�	
7�+��%�|�|�	/��8�8�L�T�4�� �J�J��.�/�
/��	/�s�,D�E"�2+E�E"N)r
rrr\r,r7r*rrrrrQs���"�
�%7rrc�6�eZdZdZd	d�Zd�Zd�Zd�Zd�Zd�Z	y)
r�z�Class encapsulation of the NDR repsFromToBlob.

    Removes the necessity of external code having to
    understand about other_info or manipulation of
    update flags.
    Nc�8�d|jd<||jd<d|jd<|��tj�|jd<d|jd_d|jd<d|jd	<tj�x|jdj
_|jd
<y||jd<|j
j|jd
<|jdk(r=|j
jj|jd<d|jd	<y|j
jj|jd<|j
jj|jd	<y)NFr�r&r�update_flagsr���	dns_name1�	dns_name2�
other_info)
�__dict__rr�r��repsFromTo1OtherInfor�r1�dns_namer/r0)r+r&r�s   rr,zRepsFromTo.__init__�sJ��).��
�
�o�&�$,��
�
�j�!�(+��
�
�n�%�8��(0�(?�(?�(A�D�M�M�*�%�03�D�M�M�*�%�-�)-�D�M�M�+�&�)-�D�M�M�+�&�/7�.K�.K�.M�
N�D�M�M�*�%�)�)�4��
�
�l�+�)1�D�M�M�*�%�*2�,�,�*A�*A�D�M�M�,�'����3�&�-5�\�\�-D�-D�-M�-M��
�
�k�*�-1��
�
�k�*�-5�\�\�-D�-D�-N�-N��
�
�k�*�-5�\�\�-D�-D�-N�-N��
�
�k�*rc�
�d|jjzd|jzzd|jzzd|jzzd|j
zzd|jzzd|jzzd|jzzd	|jzzd
|jzzd|jzzd|jzzd
|jzzdzdjd�|jD��zdz}|S)r.rnz

	dnstr=%sz
	update_flags=0x%Xz
	version=%dz
	source_dsa_obj_guid=%sz
	source_dsa_invocation_id=%srHz
	replica_flags=0x%Xz
	consecutive_sync_failures=%dz
	last_success=%sz
	last_attempt=%sz
	dns_name1=%sz
	dns_name2=%sz
	schedule[ rrc3�&K�|]	}d|z���y�wrPrrQs  rr"z%RepsFromTo.__str__.<locals>.<genexpr>�s����@�$�w��~�@�rxrT)r2r
r&r-r��source_dsa_obj_guidr�r;�
replica_flags�consecutive_sync_failures�last_success�last_attemptr/r0r|r<r5s  rr7zRepsFromTo.__str__�sH���t�~�~�.�.�.���
�
�-�.�&��):�):�:�;� �$�,�,�.�/�,�d�.F�.F�F�	G�
2��.�.�/�0�'��)<�)<�<�=�(�$�*<�*<�<�=�3��/�/�0�
1�%�t�'8�'8�8�9�%�t�'8�'8�8�9�"�D�N�N�2�
3�"�D�N�N�2�3� � � �w�w�@�$�-�-�@�@�!A�"�#��&�rc���|dvry|dvr&|jdxxtjzcc<n)|dvr%|jdxxtjzcc<t	|jdj
||��nS|dvr�||jd<|jdjdk(r6|jd|jdj
j_n�|jd|jdj
j_	n�|d	vrl||jd
<|jdjdk(rt|��|jd
|jdj
j_nH|dvr||jd<n4|d
vr||jd<n |dvrtd|z��td|z��|jdxxtjzcc<y)z�Set an attribute and chyange update flag.

        Be aware that setting any RepsFromTo attribute will set the
        drsuapi.DRSUAPI_DRS_UPDATE_ADDRESS update flag.
        �r<r8r;r7r�r9r:r;)r8r-)r<r��r/r/r.�r0r0�r&r&�r�r��r�z$Attempt to set readonly attribute %s�Unknown attribute %sN)
r2r�DRSUAPI_DRS_UPDATE_FLAGS�DRSUAPI_DRS_UPDATE_SCHEDULE�setattrr�r�r1r4r/r�r0�DRSUAPI_DRS_UPDATE_ADDRESS)r+�itemr�s   r�__setattr__zRepsFromTo.__setattr__�s����$�$�
�(�(��
�
�n�-��1Q�1Q�Q�-���%��
�
�n�-��1T�1T�T�-��D�M�M�*�-�1�1�4��?�
�]�
"�).�D�M�M�+�&��}�}�Z�(�0�0�C�7��M�M�+�.��
�
�j�)�-�-�8�8�A��M�M�+�.��
�
�j�)�-�-�8�8�B��]�
"�).�D�M�M�+�&��}�}�Z�(�0�0�C�7�$�T�*�*��M�M�+�.��
�
�j�)�-�-�8�8�B��\�
!�(-�D�M�M�*�%�
�&�
&�-2�D�M�M�/�*�
�[�
 � �!G�$�!N�O�O� �!7�$�!>�?�?��
�
�n�%��)K�)K�K�%rc��|dvr#t|jdj|�S|dvr|jdjS|dvrv|jdjdk(r-|jdjjj
S|jdjjjS|dvrT|jdjdk(rt|��|jdjjjS|dvr|jdS|d	vr|jd
S|dvr|jdStd
|z��)zzOverload of RepsFromTo attribute retrieval.

        Allows external code to ignore substructures within the blob
        r=r�rBr>r.r?rAr�r@r&�r-r-rC)	�getattrr2r�r�r1r4r/r�r0)r+rHs  r�__getattr__zRepsFromTo.__getattr__sP��
�$�$��4�=�=��4�8�8�$�?�?�
�[�
 ��=�=��,�4�4�4�
�]�
"��}�}�Z�(�0�0�C�7��}�}�Z�0�4�4�?�?�H�H�H��}�}�Z�0�4�4�?�?�I�I�I�
�]�
"��}�}�Z�(�0�0�C�7�$�T�*�*��}�}�Z�0�4�4�?�?�I�I�I�
�&�
&��=�=��1�1�
�\�
!��=�=��,�,�
�%�
%��=�=��0�0��3�d�:�;�;rc� �|jdk7Sr�rKrOs rr�zRepsFromTo.is_modified;s���!�!�S�(�)rc�"�d|jd<y)Nrr-)r2rOs rr�zRepsFromTo.set_unmodified>s��(+��
�
�n�%r)NN)
r
rrr\r,r7rIrMr�r�rrrr�r��s*���2O�h�00L�d#<�J*�,rr�c�"�eZdZdZd�Zd�Zd�Zy)�SiteLinkz0Class defines a site link found under sites
    c�f�||_d|_d|_d|_d|_d|_g|_yr�)rr�r8�costr<�interval�	site_listrDs  rr,zSiteLink.__init__Fs4����
���������	���
���
���rc���|jj�d|j��d|jzzd|jzzd|j
zzd|jzz}|j��|d|jjzd|jjzzd|jjzzz
}t|jj�D]n\}}|d	||jfzd
||jfzzd|zzdjd
�|jj |j"D��zdzz
}�p|j$D]\}}|d|�d|�d�z}�|S)r#rFr$z
	system_flags=%dz	
	cost=%dz
	interval=%srIrJrKrLrMrNrrc3�&K�|]	}d|z���y�wrPrrQs  rr"z#SiteLink.__str__.<locals>.<genexpr>drSrxrTz
	site_list=r0r1)r2r
rr�r8rSrTr<rUrVrWrXrYrZr[r|r\r]rU)r+r6r^r_r:r�s      rr7zSiteLink.__str__Os���"&���!8�!8�$�*�*�E��$�,�,�.�/�$�t�'8�'8�8�9��t�y�y�(�)�!�4�=�=�0�	1���=�=�$��*�T�]�]�-?�-?�?�/�$�-�-�2I�2I�I�J�8��]�]�4�4�5�6�
6�D�
'�t�}�}�'@�'@�A�
�	��6��?��V�[�[�)�*�A��V�]�]�+�,�-�=�q�@�	A�
���\�4�=�=�;R�;R�ST�;U�;[�;[�\�\�]��
���
����	?�H�D�"��T�2�>�>�D�	?��rc�j�gd�}	|j|jtj|dg��}|d}d	|vrt|d	d�|_d
|vrt|d
d�|_	d|vrt|dd�|_
d|vrt|dd�|_d
|vr�|d
D]�}t||jd��}	tj|	j j#d��}
t%|	j �}|
|f|j&vs�r|j&j)|
|f���d|vr t+t,j.�|_yt1�|_y#tj$r0}|j
\}}t
d|j�d|�d���d}~wwxYw)z�Given a siteLink object with an prior initialization
        for the object's DN, search for the DN and load attributes
        from the samdb.
        )r�rdrSr<�replInterval�siteListz
extended_dn:0)r<r=r>�controlszUnable to find SiteLink for (r?r1Nrr�rdrSrYrZrrEr<)r@rrArBrCrDrr�r�r8rSrTrr	rrEr��get_extended_componentr3rUr�rrr<r=)r+rGr>rH�e19rJrKrLr�rr:rs            r�
load_sitelinkzSiteLink.load_sitelinkks���
��	/��,�,�D�J�J�c�n�n�%*�o�5F��H�C��!�f������s�9�~�a�0�1�D�L��C�� #�C�
�$6�q�$9� :�D���S�=��C��K��N�+�D�I��S� ���N� 3�A� 6�7�D�M�����Z��
9���u�e�l�l�6�&:�;���y�y����!?�!?��!G�H���D�G�G����%�=����6��N�N�)�)�4��-�8�
9����&�x�'8�'8�%�@�D�M�3�5�D�M��=�|�|�	/��8�8�L�T�4�� �J�J��.�/�
/��	/�s�.E/�/F2�+F-�-F2N)r
rrr\r,r7r^rrrrQrQBs�����8-6rrQc��eZdZd�Zy)�KCCFailedObjectc�J�||_||_||_||_||_yr�)r5�
failure_count�time_first_failure�last_resultr4)r+r5rbrcrdr4s      rr,zKCCFailedObject.__init__�s(����	�*���"4���&��� ��
rN)r
rrr,rrrr`r`�s��!rr`c��|jj�D]}|j�s�|cStd|jz��)Nz)Unable to find config NC replica for (%s))r�r'rPrr`)rlr�s  rr�r��sM���&�&�-�-�/����?�?���L���>��=�=�!�"�"rc��tj�}d|_d|_d|_tj
�}d|_d|_|g|_tj�}dgdz|_
|g|_|S)z�Create a default schedule for an NTDSConnection or Sitelink. This
    is packed differently from the repltimes schedule used elsewhere
    in KCC (where the 168 nibbles are packed into 84 bytes).
    �rr.��)rr<rUrVrW�scheduleHeaderrZr[rY�
scheduleSlotsr]r\)r<r_�datas   rr=r=�sy��� � �"�H��H�M��H��!"�H��
�
$�
$�
&�F��F�K��F�M�"�8�H���!�!�#�D���#��D�J���H���Orc
��g}|j|j�tjd��}|j|j�tjd��}t	�}d}|D]z}|j
j
�j
�}||j�xxdz
cc<|j�j�|j�k(s�v|dz
}�|t|�t|�k7�rQg}	|D]0}|j
j�|vs� |	j|��2djtj|�tjt|j����}
|	D�]�}tjt|j
��}|j|j�tjdgdj|�d	g�
�}
|j|j�tjddgdj|
|�d	g�
�}t|
�dkDs��t|�dkDs��t|
ddd�}t|ddd�}||k7r��d
}|ddD]{}tj |t|��}|j�}|j�j�}|||kDrd}n"|||k(s�e||j�ks�yd}n|s���|j
j�}|j|j�����|S)a
    Discover which sites have no DCs and whose lowest single-hop cost
    distance for any link attached to that site is linked to the site supplied.

    We compare the lowest cost of your single-hop link to this site to all of
    those available (if it exists). This means that a lower ranked siteLink
    with only the uncovered site can trump any available links (but this can
    only be done with specific, poorly enacted user configuration).

    If the site is connected to more than one other site with the same
    siteLink, only the largest site (failing that sorted alphabetically)
    creates the DNS records.

    :param samdb database
    :param site_name origin site (with a DC)

    :return a list of sites this site should be covering (for DNS)
    z*(&(objectClass=server)(serverReference=*))rz(objectClass=site)rr.zCN={},CN=Sites,{}rSz&(&(objectClass=siteLink)(siteList={}))zserver_sort:1:0:cost)r<r=r>rr[rZz3(&(objectClass=siteLink)(siteList={})(siteList={}))TF)r@rSrArr
r��parent�
canonical_str�
get_rdn_value�lowerrr��format�
binary_encoder3r�r�)rG�	site_name�sites_to_cover�
server_res�site_res�sites_in_use�dc_countrL�site_dn�sites_uncovered�own_site_dn�site�
encoded_dn�	link_res1�	link_res2�cost1�cost2�to_cover�site_val�site_dn_str�site_rdn�site_cover_rdns                      r�uncovered_sites_to_coverr��s?��&�N����5�#:�#:�#<�$'�$5�$5�*5��6�J�
�|�|��!8�!8�!:�"%�"3�"3�';��=�H��9�L��H�����&�&�-�-�/�(�(�*���W�*�*�,�-��2�-�� � �"�(�(�*�i�o�o�.?�?���M�H���<��C��M�)����	,�C��v�v�#�#�%�\�9��&�&�s�+�	,�*�0�0����i�(����c�%�"9�"9�";�<�=�
��
$�0	B�D��*�*�3�t�w�w�<�8�J����%�*A�*A�*C�+.�+<�+<�V�H�16�6<�f�Z�6H�/E�.F�	%�H�I����%�*A�*A�*C�+.�+<�+<�,2�J�+?�1C�CI�6�)4�)3�D5�0F�.F�%�H�I��9�~��!�c�)�n�q�&8��I�a�L��0��3�4���I�a�L��0��3�4���E�>��
 �� )�!��Z� 8�
�H�!�f�f�U�C��M�:�G�")�"7�"7�"9�K�&�4�4�6�<�<�>�H�#�K�0�8�;�#(���&�{�3�x�?�"�Y�_�_�%6�6�#(���
��%)�W�W�%:�%:�%<�N�"�)�)�.�*>�*>�*@�A�a0	B�d�r)&r�rAr5�sambar�samba.dcerpcrrr�samba.samdbr�	samba.ndrrr	�collectionsr
�	Exceptionr�objectr�dictr2rr4r$r^r�rr�r�rrr�rQr`r�r=r�rrr�<module>r�s��,�
�����
 �*��	�y�	�A�V�A�
�N�V�_�_�%:�%:�%<�N�
N�
�n+�F�n+�b|2�
�|2�~[�F�[�|
_�V�_�D
Q�
�Q�hp�6�p�f	f��f�R=7��=7�@n,��n,�bV6�v�V6�r!�f�!�"��Bhr

Zerion Mini Shell 1.0