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: //lib/python3/dist-packages/samba/kcc/__pycache__/ldif_import_export.cpython-310.pyc
o

�/a�6�@sfddlZddlmZmZmZddlmZddlmZm	Z	Gdd�de
�Zdd�Zd
d	d
�Z
dd�ZdS)�N)�Ldb�ldb�read_and_sub_file)�system_session)�SamDB�dsdb_Dnc@seZdZdS)�	LdifErrorN)�__name__�
__module__�__qualname__�rr�>/usr/lib/python3/dist-packages/samba/kcc/ldif_import_export.pyrsrcCs*|D]}|�|tj�}|�d|�qdS)Nz%s)�
write_ldifr�CHANGETYPE_NONE�write)�samdb�f�res�msg�lstrrrr
�write_search_result!s�rc
Cs�tj�|�rtd|��t|t�|dgd�}|��zt|d�}|�|d�|r/|�	d|�|�d�Wnt
yM}z|��td||f��d}~ww|��t
|t�|d�}|S)	a�Routine to import all objects and attributes that are relevent
    to the KCC algorithms from a previously exported LDIF file.

    The point of this function is to allow a programmer/debugger to
    import an LDIF file with non-security relevent information that
    was previously extracted from a DC database.  The LDIF file is used
    to create a temporary abbreviated database.  The KCC algorithm can
    then run against this abbreviated database for debug or test
    verification that the topology generated is computationally the
    same between different OSes and algorithms.

    :param dburl: path to the temporary abbreviated db to create
    :param ldif_file: path to the ldif file to import
    z3Specify a database (%s) that doesn't already exist.zmodules:)�url�session_info�lp�optionsNzfdn: @ROOTDSE
changetype: modify
replace: dsServiceName
dsServiceName: CN=NTDS Settings,%s
            zLdn: @MODULES
@LIST: rootdse,extended_dn_in,extended_dn_out_ldb,objectguid
-
zFailed to import %s: %s)rrr)�os�path�existsrrr�transaction_startr�add_ldif�modify_ldif�	Exception�transaction_cancel�transaction_commitr)�dburlr�	ldif_file�forced_local_dsa�tmpdb�data�estrrrrr
�
ldif_to_samdb's0��
���r*c
Cs&zt|t�||d�}Wntjy%}z
|j\}}td||f��d}~wwtj�|�r2td|��zt	|d�}Wnt
yO}	z
td|t|	�f��d}	~	ww�z�gd�}
d|��}|j
|tj|
d	d
�}t|||�gd�}
d|��}|j
|tj|
dd
�}t|||�gd
�}
d|��}|j
|tj|
dd
�}
t|||
�|
D]}t|j�}gd�}
d|}|j
|tj|
d�}t|||�q�g}|
D]P}t|j�}gd�}gd�}
|j
|tj|
|dd
�}|D],}|��D]%}||v�r
||D]}t||�d��}t|j�}||v�r|�|�q�q�q�t|||�q�|
D]}t|j�}gd�}
|j
|tj|
dd
�}t|||��qgd�}
d|��}|j
|tj|
dd�}t|||�gd�}
d|��}|j
|tj|
ddgd �}t|||�gd!�}
d|��}|j
|tj|
d"d�}t|||�gd
�}
d|��}|j
|tj|
d#d�}t|||�gd$�}
d|��}|j
|tj|
d%d�}t|||�gd&�}
|D]}|j
|tj|
d'�}t|||��q�gd(�}
d)}|j
|tj|
d'�}t�|d*�|d+_t|||�Wntj�y}z
|j\}}td,||f��d}~ww|��dS)-a�Routine to extract all objects and attributes that are relevent
    to the KCC algorithms from a DC database.

    The point of this function is to allow a programmer/debugger to
    extract an LDIF file with non-security relevent information from
    a DC database.  The LDIF file can then be used to "import" via
    the import_ldif() function this file into a temporary abbreviated
    database.  The KCC algorithm can then run against this abbreviated
    database for debug or test verification that the topology generated
    is computationally the same between different OSes and algorithms.

    :param dburl: LDAP database URL to extract info from
    :param ldif_file: output LDIF file name to create
    )rr�credentialsrz%Unable to open sam database (%s) : %sNz/Specify a file (%s) that doesn't already exist.�wzUnable to open (%s) : %s)�objectClass�
objectGUID�cn�whenChanged�	objectSid�Enabled�systemFlags�dnsRoot�nCNamezmsDS-NC-Replica-LocationszmsDS-NC-RO-Replica-LocationszCN=Partitions,%sz(objectClass=crossRef))�base�scope�attrs�
expression)r-r.r/r0�
fSMORoleOwnerr3�msDS-Behavior-VersionzmsDS-EnabledFeaturez(objectClass=crossRefContainer))r-r.r/r0r3zCN=Sites,%sz(objectClass=site))r-r.r/r0�interSiteTopologyGenerator�interSiteTopologyFailover�schedulerzCN=NTDS Site Settings,%s)r6r7r8)�hasMasterNCszmsDS-hasMasterNCs�hasPartialReplicaNCszmsDS-HasDomainNCszmsDS-hasFullReplicaNCszmsDS-HasInstantiatedNCs)r-r.r/r0�invocationIDrzmsDS-isRODCr;z(objectClass=nTDSDSA)�utf8)r-r.r/r0r�whenCreated�enabledConnectionr>�
transportType�
fromServerr3z(objectClass=nTDSConnection))r-r.r/r0r�name�bridgeheadServerListBL�transportAddressAttributez$CN=Inter-Site Transports,CN=Sites,%sz (objectClass=interSiteTransport))r7r8r9)
r-r.r/r0r3rr>�replInterval�siteList�costz(objectClass=siteLink)z
extended_dn:0)r7r8r9�controls)r-r.r/r0�siteLinkListz(objectClass=siteLinkBridge)z(objectClass=serversContainer))r-r.r/r0r3�dNSHostName�mailAddressz(objectClass=server))	r-r.r/r0r1r:r;�repsFrom�repsTo)r7r8)	r-r.r/r0�rootDomainNamingContext�configurationNamingContext�schemaNamingContext�defaultNamingContext�
dsServiceName�z@ROOTDSErzError processing (%s) : %s)rrr�LdbError�argsrrrr�open�IOError�str�get_config_basedn�search�
SCOPE_SUBTREEr�dn�
SCOPE_BASE�keysr�decode�append�Dn�close)rr$r�credsr%�e�enumr)r�ioerrr8�sstrr�sitesr�sitestr�nclist�ncattrs�k�value�dsdn�dnstr�e1rrr
�samdb_to_ldif_file\s
�
������
�	
�
�
	
�

	�



��

�	�
��
�
�
�
�

�

�
��rv)N)r�sambarrr�
samba.authr�samba.samdbrrr!rrr*rvrrrr
�<module>s
5