
    g                     b    S SK Jr  S SKJrJr  S SKJr  S SKJ	r	J
r
Jr  S SKJr   " S S\	5      rg)    N)dsdbldb)system_session)CommandCommandErrorOption)SamDBc            	           \ rS rSrSrSr\" SSS\SSS	9/rS
S/r	\
R                  \
R                  \
R                  S.r  SS jrSrg)cmd_user_move   a  Move a user to an organizational unit/container.

This command moves a user account into the specified organizational unit
or container.
The username specified on the command is the sAMAccountName.
The name of the organizational unit or container can be specified as a
full DN or without the domainDN component.

The command may be run from the root userid or another authorized userid.

The -H or --URL= option can be used to execute the command against a remote
server.

Example1:
samba-tool user move User1 'OU=OrgUnit,DC=samdom,DC=example,DC=com' \
    -H ldap://samba.samdom.example.com -U administrator

Example1 shows how to move a user User1 into the 'OrgUnit' organizational
unit on a remote LDAP server.

The -H parameter is used to specify the remote target server.

Example2:
samba-tool user move User1 CN=Users

Example2 shows how to move a user User1 back into the CN=Users container
on the local server.
z*%prog <username> <new_parent_dn> [options]z-Hz--URLz%LDB URL for database or target serverURLH)helptypemetavardestusernamenew_parent_dn)	sambaoptscredoptsversionoptsNc                 T   UR                  5       nUR                  USS9n[        U[        5       XS9n	[        R
                  " XR                  5       5      n
S[        R                  [        R                  " U5      4-  n U	R                  U
U[        R                  S9nUS   R                  n U	R                  U5      n[        R
                  " U	[#        U5      5      nUR%                  ['        U5      S
-
  5        UR)                  U5         U	R+                  UU5        U R,                  R/                  SU< SU< S35        g ! [         a    [        SU-  5      ef = f! [          a  n[        SU< S	U< 35      eS nAff = f! [          a  n[        SU-  U5      eS nAff = f)NT)fallback_machine)urlsession_infocredentialslpz)(&(sAMAccountType=%d)(sAMAccountName=%s)))base
expressionscoper   zUnable to find user "%s"zInvalid new_parent_dn "z":    zFailed to move user "%s"zMoved user "z" into "z"
)get_loadparmget_credentialsr	   r   r   Dn	domain_dnr   ATYPE_NORMAL_ACCOUNTbinary_encodesearchSCOPE_SUBTREEdn
IndexErrorr   normalize_dn_in_domain	Exceptionstrremove_base_componentslenadd_baserenameoutfwrite)selfr   r   r   r   r   r   r   credssamdbr%   filterresuser_dnfull_new_parent_dnefull_new_user_dns                    8/usr/lib/python3/dist-packages/samba/netcmd/user/move.pyruncmd_user_move.runI   s   ##%((d(C!.*:"'0FF5//"34	=,,c.?.?.IJK	H,,I*0%(%6%6  8C !fiiG	3!&!=!=m!L
 66%W6//Gq0@A!!"45	ILL"23 			!#57 	8#  	H9XFGG	H
  	3 -q 2 3 3	3  	I9HDaHH	Is<   .E 1E$ F	 E!$
F.FF	
F'F""F' )NNNN)__name__
__module____qualname____firstlineno____doc__synopsisr   r.   takes_options
takes_argsoptionsSambaOptionsCredentialsOptionsVersionOptionstakes_optiongroupsr?   __static_attributes__rA       r>   r   r      sk    : <H 	tW#JS	2M
 o.J))..-- EI $!8rP   r   )samba.getoptgetoptrJ   sambar   r   
samba.authr   samba.netcmdr   r   r   samba.samdbr	   r   rA   rP   r>   <module>rW      s'   ,   % 6 6 M8G M8rP   