File: //proc/1233/root/usr/lib/python3/dist-packages/samba/netcmd/__pycache__/ou.cpython-310.pyc
o
�/a�9 � @ s� d dl mZ d dlZd dlmZ d dlmZmZm Z m
Z
d dlmZ d dl
mZ d dlmZ G dd� de�ZG d d
� d
e�ZG dd� de�ZG d
d� de�ZG dd� de�ZG dd� de�ZG dd� de
�ZdS )� N)�system_session)�Command�CommandError�Option�SuperCommand)�SamDB)�dsdb)�
attrgetterc @ �R e Zd ZdZdZedddeddd�gZd d
gZe j
e je jd�Z
dd
d�ZdS )�
cmd_renamea Rename an organizational unit.
The name of the organizational units can be specified as a full DN
or without the domainDN component.
Examples:
samba-tool ou rename 'OU=OrgUnit,DC=samdom,DC=example,DC=com' \
'OU=NewNameOfOrgUnit,DC=samdom,DC=example,DC=com'
samba-tool ou rename 'OU=OrgUnit' 'OU=NewNameOfOrgUnit'
The examples show how an administrator would rename an ou 'OrgUnit'
to 'NewNameOfOrgUnit'. The new DN would be
'OU=NewNameOfOrgUnit,DC=samdom,DC=example,DC=com'
z'%prog <old_ou_dn> <new_ou_dn> [options]�-H�--URL�%LDB URL for database or target server�URL�H��help�type�metavar�dest� old_ou_dn� new_ou_dn�� sambaopts�credopts�versionoptsNc
C s. |� � }|j|dd�}t|t� ||d�} t�| | �� �}
z| �|�}W n ty7 } zt d||f ��d }~ww z| �|�}
W n tyS } zt d||f ��d }~ww z#| j
|dtjg d�}t|�dkrp| j
�d | � W d S | �||
� W n ty� } zt d
| |��d }~ww | j
�d||
f � d S )NT��fallback_machine��url�session_info�credentials�lp�Invalid old_ou_dn "%s": %szInvalid new_ou_dn "%s": %s� (objectclass=organizationalUnit)��base�
expression�scope�attrsr �Unable to find ou "%s"
zFailed to rename ou "%s"zRenamed ou "%s" to "%s"
)�get_loadparm�get_credentialsr r �ldb�Dn� domain_dn�normalize_dn_in_domain� Exceptionr �search�
SCOPE_BASE�len�outf�write�rename)�selfr r r r r r r"