+
    4Ssi8                     x    ^ RI Ht ^ RIHt ^ RIHt ^ RIHt ^ RI	H
t
 ^ RIHtHtHt ^ RIHt  ! R R	]4      tR# )
    N)ldb)system_session)security)
ndr_unpack)CommandCommandErrorOption)SamDBc            	          a  ] tR t^t o RtRtR]P                  R]P                  R]P                  /t
]! RRR]R	R
R7      .tRR.tRR ltRtV tR# )cmd_user_setprimarygroupaI  Set the primary group a user account.

This command sets the primary group a user account. The username specified on
the command is the sAMAccountName. The primarygroupname is the sAMAccountName
of the new primary group. The user must be a member of the group.

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 setprimarygroup TestUser1 newPrimaryGroup --URL=ldap://samba.samdom.example.com -Uadministrator%passw1rd

Example1 shows how to set the primary group for TestUser1 on a remote LDAP
server. The --URL parameter is used to specify the remote target server.  The
-U option is used to pass the username and password of a user that exists on
the remote server and is authorized to update the server.
z-%prog <username> <primarygroupname> [options]	sambaoptsversionoptscredoptsz-Hz--URLz%LDB URL for database or target serverURLH)helptypemetavardestusernameprimarygroupnameNc           	        VP                  4       pVP                  V4      p\        V\        4       WR 7      p	R\        P
                  ! V4      ,          p
 V	P                  V	P                  4       V
\        P                  R.. ROR7      pV^ ,          P                  R^ R7      p\        \        P                  V4      pVP                  4       w  rRV,          p\        V^ ,          P                  R^ R7      4      pV^ ,          P                  R4      pVf   . p. pT F_  p\        P"                  ! T	\%        T4      4      pTP'                  R4      p\        \        P                  T4      pTP)                  T4       Ka  	  R\        P
                  ! T4      ,          p
 T	P                  T	P                  4       T
\        P                  R.R7      pT^ ,          P                  R^ R7      p\        \        P                  T4      pTP                  4       w  ppTT8w  d   \!        RT,          4      hTT8w  d   TT9  d   \!        RT: RT: R24      hRTTT3,          p T	P+                  T4       T P.                  P1                  RT,          4       R	#   \         d    \!        R
T,          4      hi ; i  \         d    \!        RT,          4      hi ; i  \,         d   p\!        RT: RT: RT: 24      hR	p?ii ; i))urlsession_infocredentialslpz((&(sAMAccountName=%s)(objectClass=user))zextended_dn:1:1	objectSidmemberOfprimaryGroupID)base
expressionscopecontrolsattrs)idxz<SID=%s>NzUnable to find user '%s'SIDz)(&(sAMAccountName=%s)(objectClass=group)))r    r!   r"   r$   zUnable to find group '%s'z/Group '%s' does not belong to the user's domainzUser 'z' is not member of group ''zl
dn: %s
changetype: modify
delete: primaryGroupID
primaryGroupID: %u
add: primaryGroupID
primaryGroupID: %u
zFailed to set primary group 'z' for user 'z': zChanged primary group to '%s'
)r   r   r   )get_loadparmget_credentialsr
   r   r   binary_encodesearch	domain_dnSCOPE_SUBTREEgetr   r   dom_sidsplitint
IndexErrorr   Dnstrget_extended_componentappendmodify_ldif	Exceptionoutfwrite)selfr   r   r   r   r   r   r   credssamdbfilterresuser_sid_binaryuser_siduser_dom_siduser_riduser_sid_dn	user_pgiduser_groupsuser_group_sids
user_groupuser_group_dnuser_group_binary_siduser_group_sidgroup_sid_binaryprimarygroup_sidprimarygroup_dom_sidprimarygroup_ridsetprimarygroup_ldifmsgs   &&&&&&&                       C/usr/lib/python3/dist-packages/samba/netcmd/user/setprimarygroup.pyruncmd_user_setprimarygroup.run@   s    ##%((,!.*:"'0 =##H-.	H,,EOO$5*0%(%6%6):(;&8	  9C "!fjj!j<O!("2"2ODH'/~~'7$\$x/KCFJJ'7QJ?@Ia&**Z0K"  %JFF5#j/:M$1$H$H$O!'(8(8:OPN"">2	 & >##$456	Q,,EOO$5*0%(%6%6&1]  4C  #1vzz+1z= &h&6&68HI3C3I3I3K0	///  (*: ; < < y(-=_-T (*: < = =  I/0 1	B23
 			9<LLM_  	H9XFGG	H$  	Q:>NOPP	Q2  	B 0(C A B B	Bs2   CJ  AJ7 !K J47KK?#K::K? )NNNN)__name__
__module____qualname____firstlineno____doc__synopsisoptionsSambaOptionsVersionOptionsCredentialsOptionstakes_optiongroupsr	   r4   takes_options
takes_argsrS   __static_attributes____classdictcell__)__classdict__s   @rR   r   r      sw     " ?H 	W))w--G.. 	tW#JQT3	(
M
 01JJN JN    r   )samba.getoptgetoptr\   sambar   
samba.authr   samba.dcerpcr   	samba.ndrr   samba.netcmdr   r   r	   samba.samdbr
   r   rU   rf   rR   <module>ro      s/   ,   % !   6 6 kNw kNrf   