File: //lib/python3/dist-packages/samba/tests/__pycache__/pso.cpython-310.pyc
o
�/a�, � @ sL d dl Z d dl mZmZmZ d dlmZmZ G dd� d�ZG dd� d�ZdS )� N)�FLAG_MOD_DELETE�FLAG_MOD_ADD�FLAG_MOD_REPLACE)�DOMAIN_PASSWORD_COMPLEX�DOMAIN_PASSWORD_STORE_CLEARTEXTc @ sV e Zd Zddd�Zdd� Zdd� Zdd � Zd
d� Zdd
� Zdd� Z dd� Z
dd� ZdS )�TestUserNc C sf d}|| _ || _d||p
d| j�� f | _|g| _|g| _| jj|||d� | j�d| � d | _d S )Nz
Initial12#zCN=%s,%s,%szCN=Users)�userouz(sAMAccountName=%s)) �name�ldb� domain_dn�dn�all_old_passwords�pwd_history�newuser�enable_account�last_pso)�self�username�samdbr �initial_password� r �1/usr/lib/python3/dist-packages/samba/tests/pso.py�__init__ s
�
zTestUser.__init__c C s |dkrg S | j | d� S )z0Returns the expected password history for the DCr N)r �r �hist_lenr r r �old_invalid_passwords- s zTestUser.old_invalid_passwordsc C s6 |dkr| j dd� S tt| j�|�}| j d| � S )zAReturns old passwords that fall outside the DC's expected historyr N)r
�min�lenr r r r r �old_valid_passwords5 s zTestUser.old_valid_passwordsc C sH || j v r| j �|� | j �|� || jv r| j�|� | j�|� dS )z@Updates the user's password history to reflect a password changeN)r
�remove�appendr )r �new_passwordr r r �update_pwd_historyC s
zTestUser.update_pwd_historyc C s8 | j j| jdgd�}d|d v rt|d d d �S dS )z=Returns the DN of the applicable PSO, or None if none applieszmsDS-ResultantPSO)�attrsr N)r
�searchr �str)r �resr r r �get_resultant_PSOR s zTestUser.get_resultant_PSOc C s
| j d S )z#Returns the user's current password���)r
)r r r r �get_password[ s
zTestUser.get_passwordc C s. d| j | �� |f }| j�|� | �|� dS )z$Attempts to change a user's passwordzd
dn: %s
changetype: modify
delete: userPassword
userPassword: %s
add: userPassword
userPassword: %s
N)r r) r
�modify_ldifr"