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: //usr/lib/python3/dist-packages/samba/__pycache__/sites.cpython-310.pyc
o

�/a��@spdZddlZddlmZmZGdd�de�ZGdd�de�ZGdd	�d	e�ZGd
d�de�Zdd
�Z	dd�Z
dS)zManipulating sites.�N)�FLAG_MOD_ADD�LdbErrorc@s eZdZdZdd�Zdd�ZdS)�
SiteExceptionzBase element for Sites errorscCs
||_dS)N)�value)�selfr�r�-/usr/lib/python3/dist-packages/samba/sites.py�__init__s
zSiteException.__init__cCsd|jj|jfS)Nz%s: %s)�	__class__�__name__r)rrrr�__str__szSiteException.__str__N)r�
__module__�__qualname__�__doc__r	rrrrrrsrc@�eZdZdZdS)�SiteNotFoundExceptionz>Raised when the site is not found and it's expected to exists.N�rr
rrrrrrr"�rc@r)�SiteAlreadyExistsExceptionzBRaised when the site is not found and it's expected not to exists.Nrrrrrr&rrc@r)�SiteServerNotEmptyExceptionz0Raised when the site still has servers attached.Nrrrrrr*rrcCs�|j|tjd|d�}t|�dkrtd|��t��}t�|d|t|�f�|_t�	dt
d�|d<|�|�t��}t�|dt|j��|_t�	d	t
d�|d<|�|�t��}t�|d
t|j��|_t�	dt
d�|d<|�|�dS)
a
    Create a site

    :param samdb: A samdb connection
    :param configDn: The DN of the configuration partition
    :param siteName: Name of the site to create
    :return: True upon success
    :raise SiteAlreadyExists: if the site to be created already exists.
    z(&(objectclass=Site)(cn=%s))��base�scope�
expressionrz&A site with the name %s already existszCn=%s,CN=Sites,%s�site�objectclasszCn=NTDS Site Settings,%s�nTDSSiteSettingsz
Cn=Servers,%s�serversContainerT)�search�ldb�
SCOPE_SUBTREE�lenr�Message�Dn�str�dn�MessageElementr�add)�samdb�configDn�siteName�ret�m�m2�m3rrr�create_site.s$
�


r/c	
Cst�|d�}|�|�dkrtd��|�d�dkrtd��|�dd|�t�|d�}|�|�z|j|tjd	d
�}t|�dkrDt	d|��Wn"t
yg}z|j\}}|tjkr]t	d|��WYd
}~nd
}~ww|j|tj
dd
�}t|�dkr}td|��|�|dg�dS)aV
    Delete a site

    :param samdb: A samdb connection
    :param configDn: The DN of the configuration partition
    :param siteName: Name of the site to delete
    :return: True upon success
    :raise SiteNotFoundException: if the site to be deleted do not exists.
    :raise SiteServerNotEmpty: if the site has still servers in it.
    zCN=SitesFzdnsites.add_base() failedzCN=Xzdnsites.add_child() failedr�CNz
CN=ServerszobjectClass=siter�zSite %s does not existNz(objectclass=server)z9Site %s still has servers in it, move them before removalz
tree_delete:0T)rr#�add_baser�	add_child�
set_componentr�
SCOPE_BASEr!rr�args�ERR_NO_SUCH_OBJECT�SCOPE_ONELEVELr�delete)	r(r)r*�dnsite�	dnserversr+�e�enum�estrrrr�delete_siteSs:

��

���
�r?)rrrr�	Exceptionrrrrr/r?rrrr�<module>s
%