%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /lib/python3/dist-packages/samba/netcmd/__pycache__/
Upload File :
Create Path :
Current File : //lib/python3/dist-packages/samba/netcmd/__pycache__/ou.cpython-312.pyc

�

�I�d79����ddlmZddlZddlmZddlmZmZm	Z	m
Z
ddlmZddl
mZGd�de�ZGd�d	e�ZGd
�de�ZGd�d
e�ZGd�de�ZGd�de�ZGd�de
�Zy)�N)�system_session)�Command�CommandError�Option�SuperCommand)�SamDB)�
attrgetterc��eZdZdZdZedddedd��gZd	d
gZe	je	je	jd�Z
		dd
�Zy)�
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��|j�}|j|d��}t|t�||��}		|	j	|�}
	|	j	|�}	|	j|
dtjg��}
t|
�d	k(r|jjd
|z�y|	j|
|�|jjd|
�d
|�d��y#t
$r}t
d|�d|����d}~wwxYw#t
$r}t
d|�d|����d}~wwxYw#t
$r}t
d|
z|��d}~wwxYw)NT��fallback_machine��url�session_info�credentials�lp�Invalid old_ou_dn "�": zInvalid new_ou_dn "� (objectclass=organizationalUnit)��base�
expression�scope�attrsr�Unable to find ou "%s"
zFailed to rename ou "%s"zRenamed ou "z" to "�"
)�get_loadparm�get_credentialsrr�normalize_dn_in_domain�	Exceptionr�search�ldb�
SCOPE_BASE�len�outf�write�rename)�selfrrrrrrr#�creds�samdb�full_old_ou_dn�e�full_new_ou_dn�ress              �1/usr/lib/python3/dist-packages/samba/netcmd/ou.py�runzcmd_rename.run?sU��
�
#�
#�
%���(�(��d�(�C���!�.�*:�"'�B�0��	/�"�9�9�)�D�N�	/�"�9�9�)�D�N�

	O��,�,�N�*L�%(�^�^�2��?�C��3�x�1�}��	�	��� :�Y� F�G���L�L���8�	
�	�	���~�7E�G�	H��)�	/�� )�1� .�/�
/��	/��
�	/�� )�1� .�/�
/��	/���	O��9�N�J�A�N�N��	O�sN�C%�D� AD)�0D)�%	D�.C?�?D�	D&�D!�!D&�)	E�2E�E�NNNN��__name__�
__module__�__qualname__�__doc__�synopsisr�str�
takes_options�
takes_args�options�SambaOptions�CredentialsOptions�VersionOptions�takes_optiongroupsrA��r@rr!sl��
�9�H�	�t�W�#J���S�	2��M�
�{�+�J��)�)��.�.��-�-���BF� $�HrRrc��eZdZdZdZedddedd��gZd	d
gZe	je	je	jd�Z
		dd
�Zy)�cmd_moveaiMove 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 move 'OU=OrgUnit,DC=samdom,DC=example,DC=com' \
        'OU=NewParentOfOrgUnit,DC=samdom,DC=example,DC=com'
    samba-tool ou rename 'OU=OrgUnit' 'OU=NewParentOfOrgUnit'

    The examples show how an administrator would move an ou 'OrgUnit'
    into the ou 'NewParentOfOrgUnit'. The ou 'OrgUnit' would become
    a child of the 'NewParentOfOrgUnit' ou. The new DN would be
    'OU=OrgUnit,OU=NewParentOfOrgUnit,DC=samdom,DC=example,DC=com'
    z+%prog <old_ou_dn> <new_parent_dn> [options]rr
rrrrr�
new_parent_dnrNc�,�|j�}|j|d��}t|t�||��}		|	j	|�}
	|	j	|�}tj|	t|
��}
|
jt|
�dz
�|
j|�	|	j|
dtjg�	�}t|�d
k(r|jj!d|
z�y|	j#|
|
�|jj!d
|
�d|�d��y#t
$r}t
d|�d|����d}~wwxYw#t
$r}t
d|�d|����d}~wwxYw#t
$r}t
d|
z|��d}~wwxYw)NTrrr$r%zInvalid new_parent_dn "�r&r'rr,zFailed to move ou "%s"z
Moved ou "z" into "r-)r.r/rrr0r1rr3�DnrI�remove_base_componentsr5�add_baser2r4r6r7r8)r9rrUrrrrr#r:r;r<r=�full_new_parent_dnr>r?s               r@rAzcmd_move.runs���
�
#�
#�
%���(�(��d�(�C���!�.�*:�"'�B�0��	/�"�9�9�)�D�N�	3�!&�!=�!=�m�!L��
����s�>�':�;���-�-�c�.�.A�A�.E�F���� 2�3�		M��,�,�N�*L�%(�^�^�2��?�C��3�x�1�}��	�	��� :�^� K�L���L�L���8�	
�	�	���'�);�=�	>��/�	/�� )�1� .�/�
/��	/��
�	3�� -�q� 2�3�
3��	3�� �	M��7�.�H�!�L�L��	M�sN�D2�E�-AE6�=E6�2	E�;E�E�	E3�E.�.E3�6	F�?F�FrBrCrQrRr@rTrT`sk��� =�H�	�t�W�#J���S�	2��M�
��/�J��)�)��.�.��-�-���FJ� $�!>rRrTc��eZdZdZdZedddedd��ed	d
ed��gZd
gZe	je	je	jd�Z
		dd�Zy)�cmd_adda�Add a new organizational unit.

    The name of the new ou can be specified as a full DN or without the
    domainDN component.

    Examples:
    samba-tool ou add 'OU=OrgUnit'
    samba-tool ou add 'OU=SubOU,OU=OrgUnit,DC=samdom,DC=example,DC=com'

    The examples show how an administrator would add a new ou 'OrgUnit'
    and a new ou 'SubOU' as a child of the ou 'OrgUnit'.
    �%prog <ou_dn> [options]rr
rrrrz
--descriptionzOU's description�description)rrr�ou_dnrNc��|j�}|j|d��}t|t�||��}		|	j	|�}
	|	j|
|��|jjd|
z�y#t
$r}t
d|�d|����d}~wwxYw#t
$r}t
d|
z|��d}~wwxYw)	NTrr�Invalid ou_dn "r%)r_zFailed to add ou "%s"zAdded ou "%s"
)
r.r/rrr0r1r�	create_our6r7)r9r`rrrrr_r#r:r;�
full_ou_dnr=s            r@rAzcmd_add.run�s���
�
#�
#�
%���(�(��d�(�C���!�.�*:�"'�B�0��	F��5�5�e�<�J�	H��O�O�J�K�O�@�	
�	�	���)�J�6�7���	F��5�!�D�E�E��	F��
�	H��6��C�Q�G�G��	H�s/�B�B"�	B�	B�B�"	B?�+B:�:B?)NNNNNrCrQrRr@r]r]�sz���)�H�	�t�W�#J���S�	2���%7��m�	-��M���J��)�)��.�.��-�-���EI� $�8rRr]c
��eZdZdZdZedddedd��ed	d
ddd
��edddddd��gZdgZe	je	je	jd�Z
		dd�Zy)�cmd_listobjectsa�List all objects in an organizational unit.

    The name of the organizational unit can be specified as a full DN
    or without the domainDN component.

    Examples:
    samba-tool ou listobjects 'OU=OrgUnit,DC=samdom,DC=example,DC=com'
    samba-tool ou listobjects 'OU=OrgUnit'

    The examples show how an administrator would list all child objects
    of the ou 'OrgUnit'.
    r^rr
rrrr�	--full-dn�full_dnF�
store_true�"Display DNs including the base DN.�r�default�actionrz-rz--recursive�	recursivezList objects recursively.r`rNc�,�|j�}|j|d��}	t|t�|	|��}
t	j
|
|
j
��}	|
j|�}d}tj}|rd}tj}	|
j|d|g�	�}t|�|kr|jjd
|z�yt!|t#d���D]`}|j$|k(r�|s$|j$j't|��|jjd
|j$z��by#t$r}
td|�d|
����d}
~
wwxYw#t$r}
td|z|
��d}
~
wwxYw)NTrrrbr%rrWz(objectclass=*)r'zou "%s" is empty
�dn��key�%s
z"Failed to list contents of ou "%s")r.r/rrr3rX�	domain_dnr0r1r�SCOPE_ONELEVEL�
SCOPE_SUBTREEr2r5r6r7�sortedr	rprY)r9r`rrrrrhrnr#r:r;rtrdr=�minchildrenr*�children�childs                  r@rAzcmd_listobjects.run�s���
�
#�
#�
%���(�(��d�(�C���!�.�*:�"'�B�0���F�F�5�%�/�/�"3�4�	�	F��5�5�e�<�J����"�"����K��%�%�E�	.��|�|��/@�*/�r�$�;�H��8�}��+��	�	��� 4�u� <�=����j��.>�?�
3���8�8�z�)����H�H�3�3�C�	�N�C��	�	������� 1�2�
3��#�	F��5�!�D�E�E��	F��0�	.��C�)� *�+,�.�
.��	.�s8� E�AE6�A9E6�	E3�E.�.E3�6	F�?F�F)NNNNFFrCrQrRr@rfrf�s����)�H�	�t�W�#J���S�	2��{��E�,�8�	:��t�]��e�"�)D�	F��M���J��)�)��.�.��-�-���EI�-2�$.rRrfc	��eZdZdZdZedddedd��ed	d
de��ed
dddd��gZejejejd�Z						dd�Z
y)�cmd_listz�List all organizational units.

    Example:
    samba-tool ou listobjects

    The example shows how an administrator would list all organizational
    units.
    z%prog [options]rr
rrrrz-bz	--base-dnzSpecify base DN to use.)rrrgrhFrirjrkrNc�v�|j�}|j|d��}t|t�||��}	t	j
|	|	j
��}
|r|	j|�}
|	j|
tjdg��}t|�dk(ryt|td���D]}}|sHt	j
|	|	j
��}
|jjt|
��|jj!d	t#|j�z��y)
NTrrz (objectClass=organizationalUnit))r*r)r+rrprqrs)r.r/rrr3rXrtr0r2rvr5rwr	rprYr6r7rI)r9rrrr�base_dnrhr#r:r;�	search_dnr?�msgrts              r@rAzcmd_list.run7s���
#�
#�
%���(�(��d�(�C���!�.�*:�"'�B�0���F�F�5�%�/�/�"3�4�	���4�4�W�=�I��l�l�9�!$�!2�!2�&H�!#��%��
��H��M���#�:�d�#3�4�	2�C���F�F�5�%�/�/�*;�<�	����-�-�c�)�n�=��I�I�O�O�F�S����[�0�1�		2rR)NNNNNF)rDrErFrGrHrrIrJrLrMrNrOrPrArQrRr@r|r|s����!�H�	�t�W�#J���S�	2��t�[�-��	�	�{��E�,�8�	:�
�M��)�)��.�.��-�-���������
2rRr|c��eZdZdZdZedddedd��ed	d
ddd
��gZdgZe	je	je	jd�Z
		dd�Zy)�
cmd_deleteaSDelete an organizational unit.

    The name of the organizational unit can be specified as a full DN
    or without the domainDN component.

    Examples:
    samba-tool ou delete 'OU=OrgUnit,DC=samdom,DC=example,DC=com'
    samba-tool ou delete 'OU=OrgUnit'

    The examples show how an administrator would delete the ou 'OrgUnit'.
    r^rr
rrrrz--force-subtree-delete�force_subtree_deleteFriz7Delete organizational unit and all children recursivelyrkr`rNc�0�|j�}|j|d��}t|t�||��}		|	j	|�}
g}|rdg}	|	j|
dtjg��}
t|
�d	k(r|jjd
|z�y|	j|
|�|jjd|
z�y#t
$r}t
d|�d|����d}~wwxYw#t
$r}t
d|
z|��d}~wwxYw)
NTrrrbr%z
tree_delete:1r&r'rr,zFailed to delete ou "%s"zDeleted ou "%s"
)r.r/rrr0r1rr2r3r4r5r6r7�delete)r9r`rrrrr�r#r:r;rdr=�controlsr?s              r@rAzcmd_delete.runss ��
�
#�
#�
%���(�(��d�(�C���!�.�*:�"'�B�0��	F��5�5�e�<�J����'�(�H�		K��,�,�J�*L�%(�^�^�2��?�C��3�x�1�}��	�	��� :�U� B�C���L�L��X�.�	
�	�	���+�j�8�9��%�	F��5�!�D�E�E��	F���	K��9�J�F��J�J��	K�s6�C�AC8�%C8�	C5�C0�0C5�8	D�D�D)NNNNFrCrQrRr@r�r�Us��
�)�H�	�t�W�#J���S�	2��'�.D��\�M�	O��M���J��)�)��.�.��-�-���EI�).�:rRr�c��eZdZdZiZe�ed<e�ed<e�ed<e�ed<e�ed<e	�ed<e
�ed<y	)
�cmd_ouz%Organizational Units (OU) management.�add�creater��mover8�list�listobjectsN)rDrErFrG�subcommandsr]r�rTrr|rfrQrRr@r�r��s_��/��K� ��K���#�I�K���&�L�K���"�*�K���&�L�K���"�*�K���!0�!2�K�
�rRr�)�samba.getopt�getoptrLr3�
samba.authr�samba.netcmdrrrr�samba.samdbr�operatorr	rrTr]rfr|r�r�rQrRr@�<module>r�s���&�
�%�����<H��<H�~@>�w�@>�F/8�g�/8�dC.�g�C.�L72�w�72�t9:��9:�x
3�\�
3rR

Zerion Mini Shell 1.0