HEX
Server: Apache/2.4.52 (Ubuntu)
System: Linux spn-python 5.15.0-89-generic #99-Ubuntu SMP Mon Oct 30 20:42:41 UTC 2023 x86_64
User: arjun (1000)
PHP: 8.1.2-1ubuntu2.20
Disabled: NONE
Upload Files
File: //usr/lib/python3/dist-packages/samba/__pycache__/uptodateness.cpython-310.pyc
o

�/a0�@s�ddlZddlZddlmZmZddlmZmZddlm	Z	ddl
mZddlm
Z
dd�Zd	d
�Zdd�Zd
d�Zdd�Zdd�Zdd�Zdd�Zddd�ZdS)�N)�
SCOPE_BASE�LdbError)�nttime2unix�dsdb)�CommandError)�SamDB)�KCCcCs\tt���}t|dd�}|�|||�|��}t|�}t|�t|�kr*tdtj	d�||fS)z>Get a readonly KCC object and the list of DSAs it knows about.T)�readonlyzThere seem to be duplicate dsas��file)
�int�timer�
load_samdb�	list_dsas�set�len�print�sys�stderr)�url�lp�creds�unix_now�kcc�dsa_list�dsas�r�4/usr/lib/python3/dist-packages/samba/uptodateness.py�get_kcc_and_dsassrcCsV|��}|t|���d|��d|d|d�}i}|��D]\}}|||<q||fS)zOGenerate dictionaries mapping short partition names to the
    appropriate DNs.zCN=Schema,%szDC=DomainDnsZones,%szDC=ForestDnsZones,%s)�DOMAIN�
CONFIGURATION�SCHEMA�	DNSDOMAIN�	DNSFOREST)�	domain_dn�str�get_config_basedn�items)�samdb�base_dn�
short_to_long�
long_to_short�s�lrrr�get_partition_maps-s

�
r.cCs<|durt|�\}}|�|��|�}||vrtd|��|S)Nzunknown partition %s)r.�get�upperr)r(�part�short_partitions�long_partitionsrrr�
get_partition@sr4cCs�g}|��}t�||�D]S}t|j�}|j|d|ddgd�}zt|ddd�}|�dd�\}}	WntyE}
zWYd}
~
qd}
~
ww|d	krPtd
|��|�	|	|t
|j�t|j
�f�q|S)z3This finds the uptodateness vector in the database.z)(&(invocationId=%s)(objectClass=nTDSDSA))�distinguishedName�invocationId)�base�
expression�attrsr�,�NzCN=NTDS Settingsz!Expected NTDS Settings DN, got %s)r&r�_dsdb_load_udv_v2r%�source_dsa_invocation_id�search�split�
IndexErrorr�appendr�highest_usnr�last_sync_success)r(�dn�cursors�	config_dn�c�inv_id�res�settings_dn�prefix�dsa_dn�errr�get_utdvKs6
������rNcCs:|jdtdgd�}t|ddd�}tt���}||fS)N��highestCommittedUSN)r7�scoper9r)r>rrr
)r(rI�usn�nowrrr�get_own_cursores�rTcCs�i}|D]]}|jj|tdgd�}d|ddd}z%t|||d�}	t|	|�}
t|	�\}}||i}
|
D]
\}}}}||
|<q3Wnty\}ztd||ftj	d�WYd}~qd}~ww|
||<q|S)N�dNSHostName)rQr9z	ldap://%sr)r�credentialsrzCould not contact %s (%s)r
)
r(r>rrrNrTrrrr)�	local_kccr�part_dnrr�
utdv_edgesrLrI�ldap_urlr(rE�own_usn�own_time�remotesrD�guidrR�trMrrr�get_utdv_edgesns0�

����
r`c	Cs�i}|D]T}z|||}Wnty"}zd}WYd}~nd}~wwi}|||<|D],}||vrN|||vrD||||}|||<q+td|tjd�q+td|tjd�q+q|S)NrzMissing dn %s from UTD vectorr
z"missing dn %s from UTD vector list)�KeyErrorrrr)	rYr�	distances�dn1�peakrM�d�dn2�distrrr�get_utdv_distances�s.��
���rhcCs.d}|��D]}|��D]}t||�}qq|S)Nr)�values�max)rb�max_distance�vector�distancerrr�get_utdv_max_distance�s�rnc
s�d}}d}g}|��D]\}}|��D]
\}}	||kr!|�|	�qq|rk|��|d}t|�}
|
ddkrO|
dd}||||dd}t|d�}n|
dd}||}t|�}t|�t|�d}||
}|||d��|r|�fdd	�|D�S�S)
Nrg����r;g@)�maximum�median�failurecsi|]}|�|�qSrr)�.0�key��summaryrr�
<dictcomp>�sz$get_utdv_summary.<locals>.<dictcomp>)r'rA�sortr�round�float)
rb�filtersrqrsrrri�dn_outerrl�dn_innerrm�length�index�expected_lengthrrvr�get_utdv_summary�s:
���r�)N)rr
�ldbrr�sambarr�samba.netcmdr�samba.samdbr�	samba.kccrrr.r4rNrTr`rhrnr�rrrr�<module>s