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/netcmd/__pycache__/rodc.cpython-310.pyc
o

�/a��@s�ddlmZmZmZmZddlmZddlm	Z	ddl
mZddlZddl
mZmZddlmZddlZGdd�de�ZGd	d
�d
e�ZGdd�de�ZGd
d�de�ZGdd�de�ZdS)�)�Command�CommandError�Option�SuperCommandN)�SamDB)�system_session)�misc�drsuapi)�
drs_Replicatec@seZdZdd�Zdd�ZdS)�
RODCExceptioncCs
||_dS)N)�value)�selfr�r�3/usr/lib/python3/dist-packages/samba/netcmd/rodc.py�__init__s
zRODCException.__init__cCsd|jj|jfS)Nz%s: %s)�	__class__�__name__r)r
rrr�__str__!szRODCException.__str__N)r�
__module__�__qualname__rrrrrrrsrc@�eZdZdS)�NamingErrorN�rrrrrrrr%�rc@r)�ReplicationErrorNrrrrrr)rrc@sdeZdZdZdZejejejd�Z	e
dded�e
dded�e
d	d
dd�gZd
gZ
dd�Zdd�ZdS)�cmd_rodc_preloadzBPreload accounts for an RODC.  Multiple accounts may be requested.z/%prog (<SID>|<DN>|<accountname>)+ ... [options])�	sambaopts�versionopts�credoptsz--serverz	DC to use)�help�typez--filez<Read account list from a file, or - for stdin (one per line)z--ignore-errorsz<When preloading multiple accounts, skip any failing accounts�
store_true)r�actionzaccount*cCs�|dd�dkr|jd|dtjgd�}n |�d�dkr'|j|dtjgd�}n|jdt�|�tjgd	�}t|�d
krAtd|��t|dd�S)
zwork out what DN they meantr�zS-z<SID=%s>zobjectclass=user)�base�
expression�scope�attrs�=z((&(samAccountName=%s)(objectclass=user)))r%r&r'�zFailed to find account '%s'�dn)	�search�ldb�
SCOPE_BASE�find�
binary_encode�
SCOPE_SUBTREE�lenr�str)r
�samdb�account�resrrr�get_dn@s 
���zcmd_rodc_preload.get_dncOsj|�d�}|�d�}|�d�}|�d�}|�d�}|dur!td��|durHg}|dkr9tjD]	}|�|���q.nt|d�D]	}|�|���q>|��}	|j|	d	d
�}
t	d|t
�|
|	d�}t	dt
�|
|	d�}t�|�
��}
d
}|	��dkrz|d7}td||f|	|
||
�}g}|D]�}|��}|j|tjdgd�}t�|�d|ddd��}z|�||�}Wnty�}z|s�tt|���|�|�WYd}~q�d}~ww|j�d|�|��z
|j|||
tjd	d�Wn(t�y}z|��|s�td|��|�t d|��WYd}~q�d}~ww|�!�q�t"|�dk�r1|�#d�|D]}|�#d|��q&dSdS)Nrr�server�file�
ignore_errorszYou must supply a server�-�rT)�fallback_machinez	ldap://%s)�url�session_info�credentials�lp�seal�	z,printzncacn_ip_tcp:%s[%s]�invocationId)r$r&r'�
objectGUIDrzReplicating DN %s
)�exop�rodczError replicating DN %sz'
Preload encountered problematic users:z    %s)$�get�	Exception�sys�stdin�append�strip�open�get_loadparm�get_credentialsrrr�GUID�
get_ntds_GUID�	log_levelr
�get_dsServiceNamer+r,r-�schema_format_valuer6rrr2�outf�write�transaction_start�	replicater	�DRSUAPI_EXOP_REPL_SECRET�transaction_cancelr�transaction_commitr1�message)r
�accounts�kwargsrrr7�
accounts_filer9�liner@�credsr3�local_samdb�destination_dsa_guid�binding_options�repl�errorsr4�
dc_ntds_dnr5�source_dsa_invocation_idr*�e�errorrrr�runSs�





����
��

���

�zcmd_rodc_preload.runN)rrr�__doc__�synopsis�options�SambaOptions�VersionOptions�CredentialsOptions�takes_optiongroupsrr2�
takes_options�
takes_argsr6rkrrrrr-s��rc@seZdZdZiZe�ed<dS)�cmd_rodcz.Read-Only Domain Controller (RODC) management.�preloadN)rrrrl�subcommandsrrrrrru�sru)�samba.netcmdrrrr�samba.getopt�getoptrn�samba.samdbr�
samba.authrr,�samba.dcerpcrr	�samba.drs_utilsr
rIrHrrrrrurrrr�<module>sr