
    g#                         S SK r S SKJrJr  S SKJr  S SKJrJ	r	  S SK
Jr  S SKJr  S SKJrJrJrJr  S SKJr   " S S	\5      rg)
    N)CalledProcessError
check_call)dsdbldb)system_session)	get_bytes)CommandCommandErrorOptioncommon)SamDBc            	           \ rS rSrSrSr\" SSS\SSS	9\" S
S\S9/rS/r	\
R                  \
R                  \
R                  S.r  SS jrSrg)cmd_user_edit!   a  Modify User AD object.

This command will allow editing of a user account in the Active Directory
domain. You will then be able to add or change attributes and their values.

The username specified on the command is the sAMAccountName.

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 edit User1 -H ldap://samba.samdom.example.com \
    -U administrator --password=passw1rd

Example1 shows how to edit a users attributes in the domain against a remote
LDAP server.

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

Example2:
samba-tool user edit User2

Example2 shows how to edit a users attributes in the domain against a local
LDAP server.

Example3:
samba-tool user edit User3 --editor=nano

Example3 shows how to edit a users attributes in the domain against a local
LDAP server using the 'nano' editor.

z%prog <username> [options]z-Hz--URLz%LDB URL for database or target serverURLH)helptypemetavardestz--editorzQEditor to use instead of the system default, or 'vi' if no system default is set.)r   r   username)	sambaoptscredoptsversionoptsNc                    UR                  5       nUR                  USS9n[        U[        5       XS9n	S[        R
                  [        R                  " U5      4-  n
U	R                  5       n U	R                  UU
[        R                  S9nUS   R                  nSS KnU H  n[        R                   " X5      nUc$  ["        R$                  R'                  S5      nUc  S	nUR)                  S
S9 nUR+                  [-        U5      5        UR/                  5          [1        UUR2                  /5        [7        UR2                  5       nUR9                  5       nS S S 5        S S S 5        M     U	R;                  W5      n[=        U5      S   nU	R?                  WU5      n[A        U5      S:X  a  U RB                  R+                  S5        g  U	RE                  U5        U RB                  R+                  SU-  5        g ! [         a    [        SU-  5      ef = f! [4         a  n[5        SU5      eS nAff = f! , (       d  f       N= f! , (       d  f       GM  = 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"EDITORviz.tmp)suffixzERROR:    zNothing to do
zFailed to modify user '%s': z Modified User '%s' successfully
)$get_loadparmget_credentialsr   r   r   ATYPE_NORMAL_ACCOUNTr   binary_encode	domain_dnsearchSCOPE_SUBTREEdn
IndexErrorr
   tempfiler   get_ldif_for_editorosenvirongetNamedTemporaryFilewriter   flushr   namer   openread
parse_ldifnextmsg_difflenoutfmodify	Exception)selfr   r   r   r   r   editorr    credssamdbfilterdomaindnresuser_dnr1   msgresult_ldift_fileeedited_fileedited_messagemsgs_edited
msg_editedres_msg_diffs                           8/usr/lib/python3/dist-packages/samba/netcmd/user/edit.pyruncmd_user_edit.runT   sF   ##%((d(C!.*:"'0 >,,c.?.?.IJK ??$	H,,H*0%(%6%6  8C !fiiG 	C 44U@K~1>!F,,F,;vY{34;45 &++&+%0%5%5%7N ' <; $ &&~6+&q)
~~c:6|!IIOO-.	MLL& 			;hFGG  	H9XFGG	H" * ;,Y::;&& <;(  	M=H!LL	Msl   ..G; 1+IH4I	H5II ;H
H2!H--H22I5
I?I
I	
I7#I22I7 )NNNNN)__name__
__module____qualname____firstlineno____doc__synopsisr   strtakes_options
takes_argsoptionsSambaOptionsCredentialsOptionsVersionOptionstakes_optiongroupsrU   __static_attributes__rW       rT   r   r   !   s}    !D ,H 	tW#JS	2z !7=@	BM J))..-- HL4Hrg   r   )r3   
subprocessr   r   samba.getoptgetoptra   sambar   r   
samba.authr   samba.commonr   samba.netcmdr	   r
   r   r   samba.samdbr   r   rW   rg   rT   <module>rp      s2   , 
 5   % " > > gHG gHrg   