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/tests/__pycache__/group_audit.cpython-310.pyc
o

�/aB�@s�dZddlZddlmZmZddlmZmZddl	m
Z
ddlmZddl
Z
ddlmZddlmZddlZdd	lmZd
Ze�dd�ZdZe�dd�Zd
ZdZGdd�de�ZdS)z1Tests for the SamDb logging of password changes.
�N)�
MSG_GROUP_LOG�DSDB_GROUP_EVENT_NAME)�%EVT_ID_USER_ADDED_TO_GLOBAL_SEC_GROUP�)EVT_ID_USER_REMOVED_FROM_GLOBAL_SEC_GROUP)�SamDB)�system_session)�AuditLogTestBase)�delete_force)�FLAG_MOD_REPLACE�grpadttstuser01� �grpadttstuser02zgroup-audit-01zgroup-audit-02cs8eZdZ�fdd�Z�fdd�Zdd�Zdd�Z�ZS)	�GroupAuditTestscst|_t|_tt|���tjd|_	dtjd}t
|t�|��|�
�d�|_tjd|_|j��|_|j��}|j�d�|�|jj|�|j��}|j�d�|j��|_|�|jj|�|j�dtd|jd	ttd
��|j�t�|j�t�dS)N�	SERVER_IPz	ldap://%s�SERVER)�url�session_info�credentials�lp�	000000001�0�cn=�
,cn=users,�user)�dn�objectclass�sAMAccountName�userPassword)r�message_typer�
event_type�superr�setUp�os�environ�	server_iprr�get_credentials�get_loadparm�ldb�server�	domain_dn�base_dn�get_dsheuristics�set_dsheuristics�
addCleanup�
get_minPwdAge�
set_minPwdAge�add�	USER_NAME�	USER_PASS�newgroup�
GROUP_NAME_01�
GROUP_NAME_02)�self�host�dsheuristics�	minPwdAge��	__class__��9/usr/lib/python3/dist-packages/samba/tests/group_audit.pyr!.s6�

�zGroupAuditTests.setUpcsDtt|���t|jdtd|j�|j�t�|j�t	�dS)Nrr)
r r�tearDownr	r'r1r*�deletegroupr4r5)r6r:r<r=r>]szGroupAuditTests.tearDowncCs�|�d�}tdt|��|�dt|�d�|dd}|�d|d�dtd	|j}d
|j}|�|��|d���|�|��|d���|�|d
|j	�|�|�
|d��|��}|�||d�|��}|�|d�|dd}|�d|d�dtd	|j}d
|j}|�|��|d���|�|��|d���|�|d
|j	�|�|�
|d��|��}|�||d�|�t
|d�|��|j�ttg�|�d�}tdt|��|�dt|�d�|dd}|�d|d�dtd	|j}dtd	|j}|�|��|d���|�|��|d���|�|d
|j	�|�|�
|d��|��}|�||d�|��}|�|d�|��|j�ttg�|�d�}tdt|��|�dt|�d�|dd}|�d|d�dtd	|j}dtd	|j}|�|��|d���|�|��|d���|�|d
|j	�|�|�
|d��|��}|�||d�|��}|�|d�|��|jjttgdd�|�d�}tdt|��|�dt|�d�|dd}|�d|d�dtd	|j}dtd	|j}|�|��|d���|�|��|d���|�|d
|j	�|�|�
|d��|��}|�||d�|��}|�|d�|��|j�ttg�|�d�}tdt|��|�dt|�d�|dd}|�d|d�dtd	|j}dtd	|j}|�|��|d���|�|��|d���|�|d
|j	�|�|�
|d��|��}|�||d�|��}|�|d�dS)N��Received %d messages�/Did not receive the expected number of messagesr�groupChange�PrimaryGroup�actionrr�cn=domain users,cn=users,r�group�
remoteAddress�	sessionId�LDAP��Added�eventIdF)�add_members_operation�Removed)�waitForMessages�print�len�assertEqualr1r*�
assertTrue�lower�assertRegexpMatchesrH�is_guid�get_session�get_service_descriptionr�discardMessagesr'�add_remove_group_membersr4r5)r6�messages�audit�user_dn�group_dn�
session_id�service_descriptionr<r<r=�$test_add_and_remove_users_from_groupcs�
�

�

��
�
�
�
��
�
�
�
�z4GroupAuditTests.test_add_and_remove_users_from_groupc
Cs�|�d�}tdt|��|�dt|�d�|dd}|�d|d�dtd	|j}d
|j}|�|��|d���|�|��|d���|�|d
|j	�|�|�
|d��|��}|�||d�|��}|�|d�|dd}|�d|d�dtd	|j}d
|j}|�|��|d���|�|��|d���|�|d
|j	�|�|�
|d��|��}|�||d�|�t
|d�|��|j�ttg�|�d�}tdt|��|�dt|�d�|dd}|�d|d�dtd	|j}dtd	|j}|�|��|d���|�|��|d���|�|d
|j	�|�|�
|d��|��}|�||d�|��}|�|d�|�t
|d�dtd	|j}dtd	|j}|jj|dgtjd�}|dd}t��}	t�|j|�|	_t�|td�|	d<|��|j�|	�|�d�}tdt|��|�dt|�d�|dd}|�d|d�dtd	|j}dtd	|j}|�|��|d���|�|��|d���|�|d
|j	�|�|�
|d��|��}|�||d�|��}|�|d�|�t|d�|dd}|�d|d�dtd	|j}d
|j}|�|��|d���|�|��|d���|�|d
|j	�|�|�
|d��|��}|�||d�|��}|�|d�|�t
|d�|dd}|�d|d�dtd	|j}dtd	|j}|�|��|d���|�|��|d���|�|d
|j	�|�|�
|d��|��}|�||d�|��}|�|d�dS)Nr@rArBrrCrDrErrrFrrGrHrIrJrKrLrM�primaryGroupToken)�base�attrs�scope�primaryGroupID�rO)rPrQrRrSr1r*rTrUrVrHrWrXrYrrZr'r[r4�search�
SCOPE_BASE�Message�Dnr�MessageElementr
�modifyr)
r6r\r]r^r_r`ra�res�group_id�mr<r<r=�test_change_primary_group�s
�

�

��
�
����
�
��

��
�z)GroupAuditTests.test_change_primary_group)�__name__�
__module__�__qualname__r!r>rbrr�
__classcell__r<r<r:r=r,s/r)�__doc__�samba.tests�samba�samba.dcerpc.messagingrr�samba.dcerpc.windows_event_idsrr�samba.samdbr�
samba.authrr"�samba.tests.audit_log_baserr	r'r
r1�generate_random_passwordr2�SECOND_USER_NAME�SECOND_USER_PASSr4r5rr<r<r<r=�<module>s$