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/krb5/__pycache__/test_ldap.cpython-310.pyc
o

eF�cu�@s�ddlZddlZej�dd�dejd<ddlZddlmZmZmZm	Z	ddl
mZddlm
Z
ddlmZdd	lmZdd
lmZdZdZGdd
�d
e�Zedkr`dZdZddlZe��dSdS)�Nz
bin/python�1�PYTHONUNBUFFERED)�LdbError�ERR_OPERATIONS_ERROR�
SCOPE_BASE�
SCOPE_SUBTREE)�security)�
ndr_unpack)�SamDB)�credentials)�KDCBaseTestFc@s>eZdZdZdd�Zdd�Zdd�Z			dd
d�Zdd
�ZdS)�	LdapTestszgTest for LDAP authentication using Kerberos credentials stored in a
       credentials cache file.
    cCs|��dS)N��_run_ldap_test��self�r�</usr/lib/python3/dist-packages/samba/tests/krb5/test_ldap.py�	test_ldap-szLdapTests.test_ldapcCs|jdd�dS)NT)�renamerrrrr�test_ldap_rename0szLdapTests.test_ldap_renamecCs|jdddd�dS)NFT)�include_pac�expect_anon�allow_errorrrrrr�test_ldap_no_pac3s
�zLdapTests.test_ldap_no_pacFTc
Cs|��}|��}d}|j|jjdd�}|��}	|��}
|j||
|||d�\}}|�t	j
|j�|jt
d|	dgd�}
|�dt|
��ttj|
d	dd	�}|rj|��}t�|���}t�|tjd
�|d
<|�|�z
td|||��d�}Wn*ty�}z|s�|��|j\}}|�t|�|� d
|�WYd}~dSd}~ww|jdt!dgd�}
|�dt|
��|
d	d}ttj|d	�}|r�|�tj"t#|��ttj|d�}|�tj$t#|��t|�dkr�ttj|d�}|�tj%t#|��dSdS|�||�dS)N�ldapF)�account_type�	use_cache)�pacz(sAMAccountName=%s)�	objectSid)�scope�
expression�attrs�r�sAMAccountName�	ldap://%s��urlr�lp� NT_STATUS_NO_IMPERSONATION_TOKEN��tokenGroups�r r"��)&�	get_samdb�
host_dns_name�get_cached_creds�AccountType�USER�get_username�get_dc_creds�create_ccache_with_user�
addCleanup�os�remove�name�searchr�assertEqual�lenr	r�dom_sid�get_new_username�ldb�Message�get_dn�MessageElement�FLAG_MOD_REPLACE�modifyr
�get_lpr�fail�argsr�assertInr�SID_NT_ANONYMOUS�str�SID_NT_NETWORK�SID_NT_THIS_ORGANISATION)rrrrr�samdb�	mach_name�service�user_credentials�	user_name�mach_credentials�creds�	cachefile�ldb_res�sid�new_name�msg�ldb_as_user�e�enum�estr�token_groups�	token_sidrrrr7s|�
���

�
��	���zLdapTests._run_ldap_testcCs�|��}|��}t��}|��td|||��d�}|jdtdgd�}|�	dt
|��ttj
|ddd�}|�	tjt|��|�	t
|dd�d�dS)Nr%r&r*r+r,r#r)r/r0r�Credentials�
set_anonymousr
rFr;rr<r=r	rr>rJrK)rrNrO�
anon_credsrZrVr_rrr�test_ldap_anonymous�s ��zLdapTests.test_ldap_anonymousN)FTFF)	�__name__�
__module__�__qualname__�__doc__rrrrrcrrrrr
(s
�Wr
�__main__)�sysr8�path�insert�environr@rrrr�samba.dcerpcr�	samba.ndrr	�samba.samdbr
�sambar�samba.tests.krb5.kdc_base_testr�global_asn1_print�global_hexdumpr
rd�unittest�mainrrrr�<module>s(
|�