File: //lib/python3/dist-packages/samba/kcc/__pycache__/ldif_import_export.cpython-310.pyc
o
�/a�6 � @ sf d dl Z d dlmZmZmZ d dlmZ d dlmZm Z G dd� de
�Zdd� Zd
d d
�Z
dd� ZdS )� N)�Ldb�ldb�read_and_sub_file)�system_session)�SamDB�dsdb_Dnc @ s e Zd ZdS )� LdifErrorN)�__name__�
__module__�__qualname__� r r �>/usr/lib/python3/dist-packages/samba/kcc/ldif_import_export.pyr s r c C s* |D ]}| � |tj�}|�d| � qd S )Nz%s)�
write_ldifr �CHANGETYPE_NONE�write)�samdb�f�res�msg�lstrr r r
�write_search_result! s �r c
C s� t j�| �rtd| ��t| t� |dgd�}|�� zt|d�}|�|d� |r/|� d| � |�d� W n t
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)r r r )�os�path�existsr r r �transaction_startr �add_ldif�modify_ldif� Exception�transaction_cancel�transaction_commitr )�dburlr � ldif_file�forced_local_dsa�tmpdb�data�estrr r r r
�
ldif_to_samdb'