Ë
    þI¶d¯I ã                   ó  — d dl Z d dlmZ d dlZd dlZd dlZd dlZd dlZd dl	Z	d dl
Z
d dlZd dlZd dlZd dlmZmZmZmZmZ d dlmZ d dlmZ d dlmZmZ d dlmZ d dlmZ d dlmZ d d	lmZ d d
l m!Z!m"Z"m#Z#m$Z$m%Z%m&Z& d dl'm(Z( d dl)m*Z*m+Z+m,Z,m-Z- d dl.m/Z/ d dl.m0Z0 ddl1m2Z2 d„ Z3d„ Z4dZ5e5s	 d dl6Z6e3Z5e5s	 d dl8Z8e4Z5e5rdZ9ndZ9i Z:dejv                  idejv                  idejv                  idœZ<dQd„Z=	 d dl>Z> e>j~                  «        i e<d<   dD ]  \  ZBZC	 d dlDZD e=eBd«       i e<eC<   Œ  eFdd «      D ]
  ZGi e<d!eGz  <   Œ i e<d"<   d#ZHeHd$d%j“                   eJe<j—                  «       «      «      z  z  ZH eLe:«      d k7  r+eHd&d%j“                   eJe:j—                  «       «      «      z  z  ZH G d'„ d(e*«      ZM G d)„ d*e*«      ZN G d+„ d,e*«      ZO G d-„ d.e*«      ZP G d/„ d0e*«      ZQ G d1„ d2e*«      ZR G d3„ d4e*«      ZS G d5„ d6e*«      ZT G d7„ d8e*«      ZU G d9„ d:e*«      ZV G d;„ d<e*«      ZW G d=„ d>eW«      ZX G d?„ d@eW«      ZY G dA„ dBe*«      ZZ G dC„ dDeW«      Z[ G dE„ dFe*«      Z\ G dG„ dHe*«      Z] G dI„ dJe*«      Z^ G dK„ dLe*«      Z_ G dM„ dNe*«      Z` G dO„ dPe,«      Zay# e7$ r Y �Œæw xY w# e7$ r Y �Œéw xY w# e7$ rZ@dZAeAdz  ZAdeAie:d<   Y dZ@[@�Œ´dZ@[@ww xY w# e7$ rZ@dZAeAdz  ZAdeAie:eC<   Y dZ@[@�ŒÓdZ@[@weE$ rZ@deBz  ZAdeAie:eC<   Y dZ@[@�ŒídZ@[@ww xY w)Ré    N)ÚPopenÚPIPEÚSTDOUTÚ
check_callÚCalledProcessError)Úgetpass)Úsystem_session)ÚSamDBÚ
SamDBError)Úmisc)Úsecurity)Údrsblobs)Ú
ndr_unpack)ÚcredentialsÚdsdbÚgensecÚgenerate_random_passwordÚLdbÚnttime2float)ÚNet)ÚCommandÚCommandErrorÚSuperCommandÚOption)Ú	get_bytes)Ú
get_stringé   )Úcommonc                 óÊ   — t        j                  «       }d|_        t        j                  «       }|j                  t        j                  | «      |«       |j                  «       S )z-
    Use python[3]-gpgme to decrypt GPG.
    T)ÚgpgmeÚContextÚarmorÚioÚBytesIOÚdecryptÚgetvalue)Úencrypted_bytesÚctxÚouts      ú3/usr/lib/python3/dist-packages/samba/netcmd/user.pyÚ_gpgme_decryptr+   @   sD   € ô �-‰-‹/€CØ€C„IÜ
�*‰*‹,€CØ‡K�K”—
‘
˜?Ó+¨SÔ1Ø�<‰<‹>Ðó    c                 óˆ   — t        j                  | ¬«      }t        j                  d¬«      }|j                  |«      \  }}}|S )z+
    Use python[3]-gpg to decrypt GPG.
    )ÚstringT)r"   )ÚgpgÚDatar!   r%   )r'   Ú
ciphertextr(   Ú	plaintextÚ_s        r*   Ú_gpg_decryptr4   K   s:   € ô —‘ Ô1€JÜ
�+‰+˜DÔ
!€Cà—k‘k *Ó-�O€Iˆq�!ØÐr,   z1Decrypt the SambaGPG password as cleartext sourcezVDecrypt the SambaGPG password not supported, python[3]-gpgme or python[3]-gpg requiredÚflags)ÚvirtualClearTextUTF8ÚvirtualClearTextUTF16ÚvirtualSambaGPGc                 óº  — ddiddidœ}| |v sJ ‚t        j                  d«      }t        j                  |«      dd j	                  dd«      j                  d	«      }d
}|dk7  rd| ›d|›d|›d�}n	d| ›d|›d�}t        j                  ||«      }|€t        d|z  «      ‚t        |«      ||    d   z   }t        |«      |k7  rt        d|t        |«      |fz  «      ‚|S )NÚlengthé+   éV   )Ú5Ú6é   r   ó   +ó   .Úutf8Ú ú$z$rounds=zcrypt.crypt(%s) returned NonezFcrypt.crypt(%s) returned a value with length %d, expected length is %d)	ÚosÚurandomÚbase64Ú	b64encodeÚreplaceÚdecodeÚcryptÚNotImplementedErrorÚlen)	ÚalgÚutf8pwÚroundsÚalgsÚsaltÚb64saltÚ
crypt_saltÚcrypt_valueÚexpected_lens	            r*   Úget_crypt_valuerW   ~   s  € à˜ˆ^Ø˜ˆ^ñ€Dð �$‰;Ðˆ;Ü�:‰:�b‹>€Dô ×Ñ˜tÓ$ Q rÐ*×2Ñ2°4¸Ó>×EÑEÀfÓM€GØ€JØ�ƒ{Ú,/²ºÐA‰
ð ò #&¢wÐ/ˆ
ä—+‘+˜f jÓ1€KØÐÜ!Ð"AÀZÑ"PÓQÐQÜ�z“? T¨#¡Y¨xÑ%8Ñ8€LÜ
ˆ;Ó˜<Ò'Ü!Ð"jØœ˜KÓ(¨,ðn8ñ #8ó 9ð 	9àÐr,   ÚvirtualSSHAzhashlib.sha1()z	 requiredÚreason))r=   ÚvirtualCryptSHA256)r>   ÚvirtualCryptSHA512rC   rK   z'modern '$%s$' salt in crypt(3) requiredé   zvirtualWDigest%02dÚvirtualKerberosSaltz-The attributes to display (comma separated). z)Possible supported virtual attributes: %sz, z"Unsupported virtual attributes: %sc            !       óÐ  — e Zd ZdZdZ edddedd¬«       ed	d
d¬«       eddd¬«       eddd¬«       eddd¬«       edde¬«       edde¬«       edde¬«       edde¬«       edde¬«       edde¬«       ed d!e¬«       ed"d#e¬«       ed$d%e¬«       ed&d'e¬«       ed(d)e¬«       ed*d+e¬«       ed,d-e¬«       ed.d/e¬«       ed0d1e¬«       ed2d3e¬«       ed4d5d¬«       ed6d7e¬«       ed8d9e¬«       ed:d;e¬«       ed<d=e¬«       ed>d?e¬«       ed@dAe¬«       edBdCe¬«      gZdDdEgZ	e
j                  e
j                  e
j                  dFœZ	 	 	 	 	 	 	 	 	 	 	 dIdH„ZyG)JÚcmd_user_addaÄ	  Add a new user.

This command adds a new user account to the Active Directory domain.  The username specified on the command is the sAMaccountName.

User accounts may represent physical entities, such as people or may be used as service accounts for applications.  User accounts are also referred to as security principals and are assigned a security identifier (SID).

A user account enables a user to logon to a computer and domain with an identity that can be authenticated.  To maximize security, each user should have their own unique user account and password.  A user's access to domain resources is based on permissions assigned to the user account.

Unix (RFC2307) attributes may be added to the user account. Attributes taken from NSS are obtained on the local machine. Explicitly given values override values obtained from NSS. Configure 'idmap_ldb:use rfc2307 = Yes' to use these attributes for UID/GID mapping.

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 add User1 passw0rd --given-name=John --surname=Smith --must-change-at-next-login -H ldap://samba.samdom.example.com -Uadministrator%passw1rd

Example1 shows how to add a new user to the domain against a remote LDAP server.  The -H parameter is used to specify the remote target server.  The -U option is used to pass the userid and password authorized to issue the command remotely.

Example2:
sudo samba-tool user add User2 passw2rd --given-name=Jane --surname=Doe --must-change-at-next-login

Example2 shows how to add a new user to the domain against the local server.   sudo is used so a user may run the command as root.  In this example, after User2 is created, he/she will be forced to change their password when they logon.

Example3:
samba-tool user add User3 passw3rd --userou='OU=OrgUnit'

Example3 shows how to add a new user in the OrgUnit organizational unit.

Example4:
samba-tool user add User4 passw4rd --rfc2307-from-nss --gecos 'some text'

Example4 shows how to add a new user with Unix UID, GID and login-shell set from the local NSS and GECOS set to 'some text'.

Example5:
samba-tool user add User5 passw5rd --nis-domain=samdom --unix-home=/home/User5 \
    --uid-number=10005 --login-shell=/bin/false --gid-number=10000

Example5 shows how to add a new RFC2307/NIS domain enabled user account. If
--nis-domain is set, then the other four parameters are mandatory.

z'%prog <username> [<password>] [options]ú-Hú--URLú%LDB URL for database or target serverÚURLÚH©ÚhelpÚtypeÚmetavarÚdestú--must-change-at-next-loginú*Force password to be changed on next loginÚ
store_true©rf   Úactionú--random-passwordúGenerate random passwordú--smartcard-requiredú*Require a smartcard for interactive logonsz--use-username-as-cnz"Force use of username as user's CNz--userouzŒDN of alternative location (without domainDN counterpart) to default CN=Users in which new user object will be created. E. g. 'OU=<OU name>'©rf   rg   ú	--surnamezUser's surnameú--given-namezUser's given nameú
--initialszUser's initialsz--profile-pathzUser's profile pathz--script-pathzUser's logon script pathz--home-drivezUser's home drive letterz--home-directoryzUser's home directory pathz--job-titlezUser's job titlez--departmentzUser's departmentz	--companyzUser's companyz--descriptionzUser's descriptionú--mail-addresszUser's email addressz--internet-addresszUser's home pagez--telephone-numberzUser's phone numberz--physical-delivery-officezUser's office locationz--rfc2307-from-nsszWCopy Unix user attributes from NSS (will be overridden by explicit UID/GID/GECOS/shell)z--nis-domainzUser's Unix/RFC2307 NIS domainú--unix-homeú"User's Unix/RFC2307 home directoryú--uidúUser's Unix/RFC2307 usernamez--uid-numberzUser's Unix/RFC2307 numeric UIDú--gid-numberz&User's Unix/RFC2307 primary GID numberú--gecosúUser's Unix/RFC2307 GECOS fieldú--login-shellúUser's Unix/RFC2307 login shellÚusernamez	password?©Ú	sambaoptsÚcredoptsÚversionoptsNc#                 ó0  — |"r|�|dk7  rt        d«      ‚|rt        d«      ‚|r|"st        dd«      }	 |"rnA|�|dk7  rn9t        d«      }t        d«      }#||#k(  sd }| j                  j	                  d«       ŒD|r5t        j                  |«      }$|€|}|€|$d	   }|€|$d
   }| €|$d   } |!€|$d   }!|j                  «       }%|j                  |%«      }&|s|r,|%j                  d«      s| j                  j	                  d«       |�d ||!||fv rt        d«      ‚	 t        |t        «       |&|%¬«      }'|'j                  ||||	|
||||||||||||||||||||| |!|"¬«       | j                  j	                  d|z  «       y # t        $ r}(t        d|z  |(«      ‚d }(~(ww xY w)NrC   úNIt is not allowed to specify --newpassword together with --smartcard-required.ú\It is not allowed to specify --must-change-at-next-login together with --smartcard-required.é€   éÿ   úNew Password: úRetype Password: úSorry, passwords do not match.
é   é   é   é   úidmap_ldb:use rfc2307zŠYou are setting a Unix/RFC2307 UID or GID. You may want to set 'idmap_ldb:use rfc2307 = Yes' to use those attributes for XID/SID-mapping.
z±Missing parameters. To enable NIS features, the following options have to be given: --nis-domain=, --uidNumber=, --login-shell=, --unix-home=, --gid-number= Operation cancelled.©ÚurlÚsession_infor   Úlp)Ú'force_password_change_at_next_login_reqÚuseusernameascnÚuserouÚsurnameÚ	givennameÚinitialsÚprofilepathÚ	homedriveÚ
scriptpathÚhomedirectoryÚjobtitleÚ
departmentÚcompanyÚdescriptionÚmailaddressÚinternetaddressÚtelephonenumberÚphysicaldeliveryofficeÚ	nisdomainÚunixhomeÚuidÚ	uidnumberÚ	gidnumberÚgecosÚ
loginshellÚsmartcard_requiredzFailed to add user '%s': zUser '%s' added successfully
)r   r   r   ÚoutfÚwriteÚpwdÚgetpwnamÚget_loadparmÚget_credentialsÚgetr
   r	   ÚnewuserÚ	Exception))Úselfr�   Úpasswordr„   rƒ   r…   rd   Úmust_change_at_next_loginÚrandom_passwordÚuse_username_as_cnr™   rš   Ú
given_namerœ   Úprofile_pathÚscript_pathÚ
home_driveÚhome_directoryÚ	job_titler¢   r£   r¤   Úmail_addressÚinternet_addressÚtelephone_numberÚphysical_delivery_officeÚrfc2307_from_nssÚ
nis_domainÚ	unix_homer«   Ú
uid_numberÚ
gid_numberr®   Úlogin_shellr°   ÚpasswordverifyÚpwentr–   ÚcredsÚsamdbÚes)                                            r*   Úrunzcmd_user_add.run'  s*  € ñ ØÐ#¨°BªÜ"ð $Ió Jð Jñ )Ü"ð $Ió Jð Jñ Ñ#5Ü/°°SÓ9ˆHàÙ!ØØÐ#¨°BªØÜÐ/Ó0ˆHÜ$Ð%8Ó9ˆNØ˜~Ò-Ø�Ø—	‘	—‘Ð BÔCð ñ ÜŸ™ XÓ.�Ø�;Ø"�CØÐ%Ø!& q¡�JØÐ%Ø!& q¡�JØ�=Ø! !™H�EØÐ&Ø"'¨¡(�Kà×#Ñ#Ó%ˆØ×(Ñ(¨Ó,ˆá™Ø—6‘6Ð1Ô2Ø—	‘	—‘ð  !nô  oàÐ!Ø˜
 K°¸JÐGÑGÜ"ð $0ó 1ð 1ð	JÜ˜a¬nÓ.>Ø&+°ô4ˆEà�M‰M˜( HÐVoØ*<ÀVÐU\Ðhrð  ~FØ&2¸jÐU`Ðp~Ø#,¸ÈWÐbmØ&2ÐDTØ*:ÐSkØ$.¸ÈØ$.¸*Ø %°+Ø-?ð ô 	Að 	�	‰	�‰Ð8¸8ÑCÕDøô ò 	JÜÐ:¸XÑEÀqÓIÐIûð	Jús   ÄAE8 Å8	FÆFÆF)!NNNNNFFFNNNNNNNNNNNNNNNNFNNNNNNNF)Ú__name__Ú
__module__Ú__qualname__Ú__doc__Úsynopsisr   ÚstrÚintÚtakes_optionsÚ
takes_argsÚoptionsÚSambaOptionsÚCredentialsOptionsÚVersionOptionsÚtakes_optiongroupsrÔ   © r,   r*   r_   r_   Æ   s+  „ ñ'ðP 9€Hñ 	ˆt�WÐ#JÐQTØ 3ô	(áÐ,Ø@Ø"ô	$ñ 	Ð"Ø.Ø"ô	$ñ 	Ð%Ø@Ø"ô	$ñ 	Ð%Ø8Ø"ô	$ñ 	ˆzð cØô	ñ 	ˆ{Ð!1¸Ô<Ùˆ~Ð$7¸cÔBÙˆ|Ð"3¸#Ô>ÙÐÐ&;À#ÔFÙˆÐ%?ÀcÔJÙˆ~Ð$>ÀSÔIÙÐ!Ð(DÈ3ÔOÙˆ}Ð#5¸CÔ@Ùˆ~Ð$7¸cÔBÙˆ{Ð!1¸Ô<ÙˆÐ%9ÀÔDÙÐÐ&<À3ÔGÙÐ#Ð*<À3ÔGÙÐ#Ð*?ÀcÔJÙÐ+Ð2JÐQTÔUÙÐ#ØmØ"ô	$ñ 	ˆ~Ð$DÈ3ÔOÙˆ}Ð#GØô	áˆwÐ;À#ÔFÙˆ~Ð$EÈCÔPÙˆ~Ð$LÐSVÔWÙˆyÐ@ÀsÔKÙˆÐ%FÈSÔQðW,€Mð\ ˜kÐ*€Jð ×)Ñ)Ø×.Ñ.Ø×-Ñ-ñÐð EIØ@EØDHØGKØ>BØGKØGKØ<AØBFØ59Ø$ôPEr,   r_   c                   óŒ   — e Zd ZdZdZ edddedd¬«      gZd	gZe	j                  e	j                  e	j                  d
œZ	 	 dd„Zy)Úcmd_user_deletea  Delete a user.

This command deletes a user account from the Active Directory domain.  The username specified on the command is the sAMAccountName.

Once the account is deleted, all permissions and memberships associated with that account are deleted.  If a new user account is added with the same name as a previously deleted account name, the new user does not have the previous permissions.  The new account user will be assigned a new security identifier (SID) and permissions and memberships will have to be added.

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

Example1 shows how to delete a user in the domain against a remote LDAP server.  The -H parameter is used to specify the remote target server.  The --username= and --password= options are used to pass the username and password of a user that exists on the remote server and is authorized to issue the command on that server.

Example2:
sudo samba-tool user delete User2

Example2 shows how to delete a user in the domain against the local server.   sudo is used so a user may run the command as root.

ú%prog <username> [options]r`   ra   rb   rc   rd   re   r�   r‚   Nc                 ó  — |j                  «       }|j                  |d¬«      }t        |t        «       ||¬«      }dt	        j
                  |«      z  }		 |j                  |j                  «       t        j                  |	dg¬«      }
|
d   j                  }	 |j                  |«       | j                  j                  d
|z  «       y # t        $ r t        d|z  «      ‚w xY w# t        $ r}t        d	|z  |«      ‚d }~ww xY w)NT©Úfallback_machiner“   z0(&(sAMAccountName=%s)(sAMAccountType=805306368))Údn©ÚbaseÚscopeÚ
expressionÚattrsr   úUnable to find user "%s"zFailed to remove user "%s"zDeleted user %s
)rµ   r¶   r
   r	   ÚldbÚbinary_encodeÚsearchÚ	domain_dnÚSCOPE_SUBTREErê   Ú
IndexErrorr   Údeleter¹   r±   r²   )rº   r�   r„   rƒ   r…   rd   r–   rÑ   rÒ   ÚfilterÚresÚuser_dnrÓ   s                r*   rÔ   zcmd_user_delete.run›  s  € à×#Ñ#Ó%ˆØ×(Ñ(¨¸dÐ(ÓCˆä˜!¬.Ó*:Ø"'¨Bô0ˆð EÜ×#Ñ# HÓ-ñ.ˆð	HØ—,‘, E§O¡OÓ$5Ü%(×%6Ñ%6Ø*0Ø&* Vð ó -ˆCð ˜!‘f—i‘iˆGð	KØ�L‰L˜Ô!ð 	�	‰	�‰Ð+¨hÑ6Õ7øô ò 	HÜÐ9¸XÑFÓGÐGð	Hûô
 ò 	KÜÐ;¸hÑFÈÓJÐJûð	Kús%   ÁAC ÂC! ÃCÃ!	C>Ã*C9Ã9C>©NNNN©rÕ   rÖ   r×   rØ   rÙ   r   rÚ   rÜ   rÝ   rÞ   rß   rà   rá   râ   rÔ   rã   r,   r*   rå   rå   y  si   „ ñð& ,€Hñ 	ˆt�WÐ#JÐQTØ 3ô	(ð€Mð
 �€Jà×)Ñ)Ø×.Ñ.Ø×-Ñ-ñÐð HLØô8r,   rå   c                   óì   — e Zd ZdZdZ edddedd¬«       ed	d
dd¬«       edddd¬«       eddde¬«       eddddd¬«      gZej                  ej                  ej                  dœZ	 	 	 	 	 	 	 	 dd„Zy)Úcmd_user_listzList all users.ú%prog [options]r`   ra   rb   rc   rd   re   z--hide-expiredz!Do not list expired user accountsFrl   )rf   Údefaultrn   z--hide-disabledz"Do not list disabled user accounts)r   rn   rf   z-bz	--base-dnzSpecify base DN to users   ú	--full-dnÚfull_dnú)Display DN instead of the sAMAccountName.©ri   r   rn   rf   r‚   Nc	                 óÂ  — |j                  «       }	|j                  |	d¬«      }
t        |t        «       |
|	¬«      }|j	                  «       }|r|j                  |«      }d}|du r|j                  «       }d|z  }d}|du r#dt        j                  t        j                  fz  }dt        j                  t        j                  ||fz  }|j                  |t        j                  |dg¬	«      }t        |«      d
k(  ry |D ]a  }|r.| j                  j!                  d|j#                  d«      z  «       Œ3| j                  j!                  d|j#                  dd
¬«      z  «       Œc y )NTrè   r“   rC   z)(|(accountExpires=0)(accountExpires>=%u))z(!(userAccountControl:%s:=%u))z4(&(objectClass=user)(userAccountControl:%s:=%u)%s%s)Úsamaccountname©rí   rî   rï   r   ú%s
rê   ©Úidx)rµ   r¶   r
   r	   rô   Únormalize_dn_in_domainÚ
get_nttimerñ   ÚOID_COMPARATOR_ANDr   ÚUF_ACCOUNTDISABLEÚUF_NORMAL_ACCOUNTró   rõ   rM   r±   r²   r·   )rº   rƒ   r„   r…   rd   Úhide_expiredÚhide_disabledÚbase_dnr  r–   rÑ   rÒ   Ú	search_dnÚfilter_expiresÚcurrent_nttimeÚfilter_disabledrø   rù   Úmsgs                      r*   rÔ   zcmd_user_list.runÕ  ss  € ð ×#Ñ#Ó%ˆØ×(Ñ(¨¸dÐ(ÓCˆä˜!¬.Ó*:Ø"'¨Bô0ˆð —O‘OÓ%ˆ	ÙØ×4Ñ4°WÓ=ˆIàˆØ˜4ÑØ"×-Ñ-Ó/ˆNØHØñ ˆNð ˆØ˜DÑ Ø>Ü×&Ñ&¬×(>Ñ(>ðB@ñ @ˆOð HÜ×"Ñ"Ü×"Ñ"ØØð	Kñ ˆð �l‰l˜9Ü!$×!2Ñ!2Ø&,Ø"2Ð!3ð ó 5ˆô �‹H˜ŠMØàò 	GˆCÙØ—	‘	—‘ ¨¯©°«Ñ 6Ô7Øà�I‰I�O‰O˜F S§W¡WÐ-=À1 WÓ%EÑEÕFñ	Gr,   )NNNNFFNF©rÕ   rÖ   r×   rØ   rÙ   r   rÚ   rÜ   rÞ   rß   rà   rá   râ   rÔ   rã   r,   r*   rþ   rþ   ¶  sÅ   „ Ùà €Hñ 	ˆt�WÐ#JÐQTØ 3ô	(áÐØ7ØØ"ô	$ñ 	Ð ØØ"Ø8ô	:ñ 	ˆt�[Ø,Øô	ñ 	ˆ{ ØØ"Ø?ô	Að€Mð* ×)Ñ)Ø×.Ñ.Ø×-Ñ-ñÐð ØØØØØØØô0Gr,   rþ   c                   ó    — e Zd ZdZdZej                  ej                  ej                  dœZ	 e
dddedd¬	«       e
d
de¬«      gZdgZ	 	 dd„Zy)Úcmd_user_enablea©  Enable a user.

This command enables a user account for logon to an Active Directory domain.  The username specified on the command is the sAMAccountName.  The username may also be specified using the --filter option.

There are many reasons why an account may become disabled.  These include:
- If a user exceeds the account policy for logon attempts
- If an administrator disables the account
- If the account expires

The samba-tool user enable command allows an administrator to enable an account which has become disabled.

Additionally, the enable function allows an administrator to have a set of created user accounts defined and setup with default permissions that can be easily enabled for use.

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 enable Testuser1 --URL=ldap://samba.samdom.example.com --username=administrator --password=passw1rd

Example1 shows how to enable a user in the domain against a remote LDAP server.  The --URL parameter is used to specify the remote target server.  The --username= and --password= options are used to pass the username and password of a user that exists on the remote server and is authorized to update that server.

Example2:
su samba-tool user enable Testuser2

Example2 shows how to enable user Testuser2 for use in the domain on the local server. sudo is used so a user may run the command as root.

Example3:
samba-tool user enable --filter=samaccountname=Testuser3

Example3 shows how to enable a user in the domain against a local LDAP server.  It uses the --filter=samaccountname to specify the username.

ú.%prog (<username>|--filter <filter>) [options]©rƒ   r…   r„   r`   ra   rb   rc   rd   re   ú--filterúLDAP Filter to set password onrs   ú	username?Nc                 ó~  — |€|€t        d«      ‚|€dt        j                  |«      z  }|j                  «       }|j	                  |d¬«      }t        |t        «       ||¬«      }		 |	j                  |«       | j                  j                  d|xs |z  «       y # t        $ r}
t        d|xs |›d|
›�«      ‚d }
~
ww xY w)	Nú4Either the username or '--filter' must be specified!ú((&(objectClass=user)(sAMAccountName=%s))Trè   r“   zFailed to enable user 'ú': zEnabled user '%s'
)r   rñ   rò   rµ   r¶   r
   r	   Úenable_accountr¹   r±   r²   ©rº   r�   rƒ   r„   r…   rø   rd   r–   rÑ   rÒ   r  s              r*   rÔ   zcmd_user_enable.run8  sÊ   € àÐ  ÜÐUÓVÐVàˆ>Ø?Ä3×CTÑCTÐU]ÓC^Ñ_ˆFà×#Ñ#Ó%ˆØ×(Ñ(¨¸dÐ(ÓCˆä˜!¬.Ó*:Ø"'¨Bô0ˆð	]Ø× Ñ  Ô(ð 	�	‰	�‰Ð-°Ò1C¸VÑDÕEøô ò 	]ÝÀ8ÒCUÈvÑCUÑWZÐ[Ó\Ð\ûð	]ús   Á%B Â	B<Â"B7Â7B<©NNNNNN©rÕ   rÖ   r×   rØ   rÙ   rÞ   rß   rá   rà   râ   r   rÚ   rÜ   rÝ   rÔ   rã   r,   r*   r  r    sv   „ ñð> @€Hð ×)Ñ)Ø×-Ñ-Ø×.Ñ.ñÐñ 	ˆt�WÐ#JÐQTØ 3ô	(áˆzÐ @ÀsÔKð€Mð �€Jà:>Ø-1ôFr,   r  c                   ó    — e Zd ZdZdZ edddedd¬«       ed	d
e¬«      gZdgZe	j                  e	j                  e	j                  dœZ	 	 dd„Zy)Úcmd_user_disablezDisable a user.r  r`   ra   rb   rc   rd   re   r  r  rs   r  r‚   Nc                 ó:  — |€|€t        d«      ‚|€dt        j                  |«      z  }|j                  «       }|j	                  |d¬«      }t        |t        «       ||¬«      }		 |	j                  |«       y # t        $ r}
t        d|xs |›d|
›�«      ‚d }
~
ww xY w)Nr!  r"  Trè   r“   zFailed to disable user 'r#  )	r   rñ   rò   rµ   r¶   r
   r	   Údisable_accountr¹   r%  s              r*   rÔ   zcmd_user_disable.run_  s¬   € àÐ  ÜÐUÓVÐVàˆ>Ø?Ä3×CTÑCTÐU]ÓC^Ñ_ˆFà×#Ñ#Ó%ˆØ×(Ñ(¨¸dÐ(ÓCˆä˜!¬.Ó*:Ø"'¨Bô0ˆð	^Ø×!Ñ! &Õ)øÜò 	^ÝÀHÒDVÐPVÑDVÑX[Ð\Ó]Ð]ûð	^ús   Á%A7 Á7	BÂ BÂBr&  rü   rã   r,   r*   r)  r)  L  ss   „ Ùà?€Hñ 	ˆt�WÐ#JÐQTØ 3ô	(áˆzÐ @ÀsÔKð€Mð �€Jð ×)Ñ)Ø×.Ñ.Ø×-Ñ-ñÐð ;?Ø-1ô^r,   r)  c            	       óÌ   — e Zd ZdZdZej                  ej                  ej                  dœZ	 e
dddedd¬	«       e
d
de¬«       e
dded¬«       e
dddd¬«      gZdgZ	 	 dd„Zy)Úcmd_user_setexpiryaà  Set the expiration of a user account.

The user can either be specified by their sAMAccountName or using the --filter option.

When a user account expires, it becomes disabled and the user is unable to logon.  The administrator may issue the samba-tool user enable command to enable the account for logon.  The permissions and memberships associated with the account are retained when the account is enabled.

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 on a remote server.

Example1:
samba-tool user setexpiry User1 --days=20 --URL=ldap://samba.samdom.example.com --username=administrator --password=passw1rd

Example1 shows how to set the expiration of an account in a remote LDAP server.  The --URL parameter is used to specify the remote target server.  The --username= and --password= options are used to pass the username and password of a user that exists on the remote server and is authorized to update that server.

Example2:
sudo samba-tool user setexpiry User2 --noexpiry

Example2 shows how to set the account expiration of user User2 so it will never expire.  The user in this example resides on the  local server.   sudo is used so a user may run the command as root.

Example3:
samba-tool user setexpiry --days=20 --filter=samaccountname=User3

Example3 shows how to set the account expiration date to end of day 20 days from the current day.  The username or sAMAccountName is specified using the --filter= parameter and the username in this example is User3.

Example4:
samba-tool user setexpiry --noexpiry User4
Example4 shows how to set the account expiration so that it will never expire.  The username and sAMAccountName in this example is User4.

r  r  r`   ra   rb   rc   rd   re   r  r  rs   z--dayszDays to expiryr   )rf   rg   r   z
--noexpiryzPassword does never expirerl   F)rf   rn   r   r  Nc	                 óÚ  — |€|€t        d«      ‚|€dt        j                  |«      z  }|j                  «       }	|j	                  |	«      }
t        |t        «       |
|	¬«      }	 |j                  ||dz  dz  |¬«       |r#| j                  j                  d	|xs |z  «       y | j                  j                  d
|xs ||fz  «       y # t        $ r}t        d|xs |›d|›�«      ‚d }~ww xY w)Nr!  r"  r“   é   i  )Úno_expiry_reqzFailed to set expiry for user 'r#  zExpiry for user '%s' disabled.
z%Expiry for user '%s' set to %u days.
)r   rñ   rò   rµ   r¶   r
   r	   Ú	setexpiryr¹   r±   r²   )rº   r�   rƒ   r„   r…   rd   rø   ÚdaysÚnoexpiryr–   rÑ   rÒ   r  s                r*   rÔ   zcmd_user_setexpiry.run¡  s  € àÐ  ÜÐUÓVÐVàˆ>Ø?Ä3×CTÑCTÐU]ÓC^Ñ_ˆFà×#Ñ#Ó%ˆØ×(Ñ(¨Ó,ˆä˜!¬.Ó*:Ø"'¨Bô0ˆð	*Ø�O‰O˜F D¨2¡I°Ñ$4ÀHˆOÔMñ
 Ø�I‰I�O‰OÐ>ØÒ"˜Fñ$õ %ð �I‰I�O‰OÐDØÒ"˜F DðH*ñ *õ +øô ò 	*åØÒ"˜FÑ"¡Cð )ó *ð *ûð	*ús   Á#C Ã	C*ÃC%Ã%C*)NNNNNNNN)rÕ   rÖ   r×   rØ   rÙ   rÞ   rß   rá   rà   râ   r   rÚ   rÛ   rÜ   rÝ   rÔ   rã   r,   r*   r-  r-  r  s”   „ ñð8 @€Hð ×)Ñ)Ø×-Ñ-Ø×.Ñ.ñÐñ 	ˆt�WÐ#JÐQTØ 3ô	(áˆzÐ @ÀsÔKÙˆxÐ.°SÀ!ÔDÙˆ|Ð">À|Ð]bÔcð€Mð �€Jà:>ØGKô+r,   r-  c                   ó€   — e Zd ZdZdZ edde¬«      gZej                  ej                  ej                  dœZ	 	 d	d„Zy)
Úcmd_user_passwordzIChange password for a user account (the one provided in authentication).
rÿ   ú--newpasswordzNew passwordrs   r‚   Nc                 óø  — |j                  «       }|j                  |«      }|j                  «       }t        |||j                  ¬«      }|}		 |	�|	dk7  rn9t        d«      }	t        d«      }
|	|
k(  sd }	| j                  j                  d«       ŒA	 t        |	t        «      s|	j                  d«      }	|j                  |	«       | j                  j                  d«       y # t        $ r}t        d|z  «      ‚d }~ww xY w)	N)ÚserverrC   r‹   rŒ   r�   rB   zFailed to change password : %súChanged password OK
)rµ   r¶   Úget_passwordr   Ú	ipaddressr   r±   r²   Ú
isinstancerÚ   rJ   Úchange_passwordr¹   r   )rº   r„   rƒ   r…   Únewpasswordr–   rÑ   Úold_passwordÚnetr»   rÏ   r  s               r*   rÔ   zcmd_user_password.runÍ  sú   € ð ×#Ñ#Ó%ˆØ×(Ñ(¨Ó,ˆð ×)Ñ)Ó+ˆä�%˜ H×$6Ñ$6Ô7ˆàˆØØÐ#¨°BªØÜÐ/Ó0ˆHÜ$Ð%8Ó9ˆNØ˜~Ò-Ø�Ø—	‘	—‘Ð BÔCð ð	GÜ˜h¬Ô,Ø#Ÿ?™?¨6Ó2�Ø×Ñ Ô)ð 	�	‰	�‰Ð/Õ0øô ò 	GäÐ?À#ÑEÓFÐFûð	Gús   Â2C Ã	C9Ã&C4Ã4C9rû   r  rã   r,   r*   r5  r5  ½  sV   „ ñð !€Hñ 	ˆ ^¸#Ô>ð€Mð
 ×)Ñ)Ø×.Ñ.Ø×-Ñ-ñÐð >BØô1r,   r5  c                   óª   — e Zd ZdZdZej                  ej                  ej                  dœZ	 e
dddedd¬	«       e
d
dddd¬«      gZdgZ	 	 	 	 	 dd„Zy)Úcmd_user_getgroupszqGet the direct group memberships of a user account.

The username specified on the command is the sAMAccountName.ræ   r  r`   ra   rb   rc   rd   re   r  r  Frl   r  r  r�   Nc                 ó  — |j                  «       }|j                  |«      }t        |t        «       ||¬«      }	dt	        j
                  |«      z  }
	 |	j                  |	j                  «       |
t        j                  g d¢¬«      }|d   j                  dd¬«      }t        t        j                  |«      }|j                  «       \  }}d|z  }t        |d   j                  d	d¬«      «      }|d   j                  d
«      }|€g }d||fz  }d}
	 |	j                  ||
t        j"                  dg¬«      }t%        |d   j&                  «      }|d   j                  d«      }|rD| j(                  j+                  d|z  «       |D ]   }| j(                  j+                  d|z  «       Œ" y g }|D ]J  }	 |	j                  ||
t        j"                  dg¬«      }|j-                  |d   j                  d«      «       ŒL | j(                  j+                  d|z  «       |D ]   }| j(                  j+                  d|z  «       Œ" y # t        $ r t!        d|z  «      ‚w xY w# t        $ r t!        d|z  «      ‚w xY w# t        $ r t!        d|z  «      ‚w xY w)Nr“   ú((&(sAMAccountName=%s)(objectClass=user))©Ú	objectSidÚmemberOfÚprimaryGroupID©rì   rî   rí   rï   r   rF  r	  ú<SID=%s>rH  rG  úUnable to find user '%s'z<SID=%s-%u>z(objectClass=group)ÚsAMAccountNamez!Unable to find primary group '%s'r  úUnable to find group '%s')rµ   r¶   r
   r	   rñ   rò   ró   rô   rõ   r·   r   r   Údom_sidÚsplitrÛ   rö   r   Ú
SCOPE_BASErÚ   rê   r±   r²   Úextend)rº   r�   r„   rƒ   r…   rd   r  r–   rÑ   rÒ   rø   rù   Úuser_sid_binaryÚuser_sidÚuser_dom_sidÚuser_ridÚuser_sid_dnÚ	user_pgidÚuser_groupsÚprimarygroup_sid_dnÚprimary_group_dnÚprimary_group_nameÚgroup_dnÚgroup_namesÚgdnÚ
group_names                             r*   rÔ   zcmd_user_getgroups.run  s·  € ð ×#Ñ#Ó%ˆØ×(Ñ(¨Ó,ˆä˜!¬.Ó*:Ø"'¨Bô0ˆð =Ü×#Ñ# HÓ-ñ.ˆð	HØ—,‘, E§O¡OÓ$5Ø*0Ü%(×%6Ñ%6ò&8ð ó 9ˆCð " !™fŸj™j¨¸!˜jÓ<ˆOÜ!¤(×"2Ñ"2°OÓDˆHØ'/§~¡~Ó'7Ñ$ˆ\˜8Ø$ xÑ/ˆKÜ˜C ™FŸJ™JÐ'7¸Q˜JÓ?Ó@ˆIØ˜a™&Ÿ*™* ZÓ0ˆKØÐ"Ø �ð ,¨|¸YÐ.GÑGÐà&ˆð	\Ø—,‘,Ð$7Ø*0Ü%(§^¡^Ø&6Ð%7ð ó 9ˆCô  # 3 q¡6§9¡9›~ÐØ!$ Q¡§¡Ð,<Ó!=Ðñ Ø�I‰I�O‰O˜FÐ%5Ñ5Ô6Ø'ò 3�Ø—	‘	—‘ ¨Ñ 1Õ2ð3ààˆØò 	HˆCðHØ—l‘l¨Ø.4Ü),¯©Ø*:Ð);ð #ó =�ð ×"Ñ" 3 q¡6§:¡:Ð.>Ó#?Õ@ð	Hð 	�	‰	�‰˜Ð!3Ñ3Ô4Ø%ò 	1ˆJØ�I‰I�O‰O˜F ZÑ/Õ0ñ	1øôE ò 	HÜÐ9¸XÑFÓGÐGð	Hûô ò 	\ÜÐBÐFYÑZÓ[Ð[ð	\ûô" ò HÜ"Ð#>À#Ñ#FÓGÐGðHús'   ÁB2H9 ÄAI Æ,AI/È9IÉI,É/J)NNNNFr'  rã   r,   r*   rB  rB  ì  s‰   „ ñ@ð ,€Hð ×)Ñ)Ø×-Ñ-Ø×.Ñ.ñÐñ 	ˆt�WÐ#JØ ¨Sô	2áˆ{ ØØ"Ø?ô	Að
€Mð �€Jð ØØØØôB1r,   rB  c                   óŽ   — e Zd ZdZdZej                  ej                  ej                  dœZ	 e
dddedd¬	«      gZd
dgZ	 	 dd„Zy)Ú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]r  r`   ra   rb   rc   rd   re   r�   ÚprimarygroupnameNc           	      ót  — |j                  «       }|j                  |«      }t        |t        «       ||¬«      }	dt	        j
                  |«      z  }
	 |	j                  |	j                  «       |
t        j                  dgg d¢¬«      }|d   j                  dd¬«      }t        t        j                  |«      }|j                  «       \  }}d	|z  }t        |d   j                  d
d¬«      «      }|d   j                  d«      }|€g }g }|D ]]  }t	        j"                  |	t%        |«      «      }|j'                  d«      }t        t        j                  |«      }|j)                  |«       Œ_ dt	        j
                  |«      z  }
	 |	j                  |	j                  «       |
t        j                  dg¬«      }|d   j                  dd¬«      }t        t        j                  |«      }|j                  «       \  }}||k7  rt!        d|z  «      ‚||k7  r||vrt!        d|›d|›d�«      ‚d|||fz  }	 |	j+                  |«       | j.                  j1                  d|z  «       y # t        $ r t!        d|z  «      ‚w xY w# t        $ r t!        d|z  «      ‚w xY w# t,        $ r}t!        d|›d|›d|›�«      ‚d }~ww xY w)Nr“   rD  zextended_dn:1:1rE  )rì   rî   rí   Úcontrolsrï   r   rF  r	  rJ  rH  rG  rK  ÚSIDz)(&(sAMAccountName=%s)(objectClass=group))rI  rM  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 'r#  zChanged primary group to '%s'
)rµ   r¶   r
   r	   rñ   rò   ró   rô   rõ   r·   r   r   rN  rO  rÛ   rö   r   ÚDnrÚ   Úget_extended_componentÚappendÚmodify_ldifr¹   r±   r²   )rº   r�   rb  r„   rƒ   r…   rd   r–   rÑ   rÒ   rø   rù   rR  rS  rT  rU  rV  rW  rX  Ú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_ldifr  s                                 r*   rÔ   zcmd_user_setprimarygroup.runi  s  € ð ×#Ñ#Ó%ˆØ×(Ñ(¨Ó,ˆä˜!¬.Ó*:Ø"'¨Bô0ˆð =Ü×#Ñ# HÓ-ñ.ˆð	HØ—,‘, E§O¡OÓ$5Ø*0Ü%(×%6Ñ%6Ø):Ð(;ò&8ð	 ó 9ˆCð " !™fŸj™j¨¸!˜jÓ<ˆOÜ!¤(×"2Ñ"2°OÓDˆHØ'/§~¡~Ó'7Ñ$ˆ\˜8Ø$ xÑ/ˆKÜ˜C ™FŸJ™JÐ'7¸Q˜JÓ?Ó@ˆIØ˜a™&Ÿ*™* ZÓ0ˆKØÐ"Ø �ð ˆØ%ò 	3ˆJÜŸF™F 5¬#¨j«/Ó:ˆMØ$1×$HÑ$HÈÓ$OÐ!Ü'¬×(8Ñ(8Ð:OÓPˆNØ×"Ñ" >Õ2ð		3ð >Ü×#Ñ#Ð$4Ó5ñ6ˆð	QØ—,‘, E§O¡OÓ$5Ø*0Ü%(×%6Ñ%6Ø&1 ]ð ó 4ˆCð  # 1™vŸz™z¨+¸1˜zÓ=Ðô &¤h×&6Ñ&6Ð8HÓIÐØ3C×3IÑ3IÓ3KÑ0Ð	Ð/àÐ/Ò/Üð  (Ø*:ñ ;ó <ð <ð ˜yÒ(Ð-=À_Ñ-TÝÚ (Ò*:ð <ó =ð =ð ð �IÐ/Ð0ñ 1Ðð	BØ×ÑÐ2Ô3ð
 	�	‰	�‰Ð9Ð<LÑLÕMøô_ ò 	HÜÐ9¸XÑFÓGÐGð	Hûô$ ò 	QÜÐ:Ð>NÑOÓPÐPð	Qûô2 ò 	BÝâ 0²(¹Cð Aó Bð Bûð	Bús2   ÁB4I ÆAI: È/J ÉI7É:JÊ	J7ÊJ2Ê2J7rû   r'  rã   r,   r*   ra  ra  H  sm   „ ñð" ?€Hð ×)Ñ)Ø×-Ñ-Ø×.Ñ.ñÐñ 	ˆt�WÐ#JÐQTØ 3ô	(ð
€Mð
 Ð0Ð1€JàGKØ $ôJNr,   ra  c                   ó  — e Zd ZdZdZej                  ej                  ej                  dœZ	 e
dddedd¬	«       e
d
de¬«       e
dde¬«       e
ddd¬«       e
ddd¬«       e
ddd¬«       e
ddd¬«      gZdgZ	 	 	 	 dd„Zy)Úcmd_user_setpassworda$  Set or reset the password of a user account.

This command sets or resets the logon password for a user account.  The username specified on the command is the sAMAccountName.  The username may also be specified using the --filter option.

If the password is not specified on the command through the --newpassword parameter, the user is prompted for the password to be entered through the command line.

It is good security practice for the administrator to use the --must-change-at-next-login option which requires that when the user logs on to the account for the first time following the password change, he/she must change the password.

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

Example1 shows how to set the password of user 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.

Example2:
sudo samba-tool user setpassword TestUser2 --newpassword=passw0rd --must-change-at-next-login

Example2 shows how an administrator would reset the TestUser2 user's password to passw0rd.  The user is running under the root userid using the sudo command.  In this example the user TestUser2 must change their password the next time they logon to the account.

Example3:
samba-tool user setpassword --filter=samaccountname=TestUser3 --newpassword=passw0rd

Example3 shows how an administrator would reset TestUser3 user's password to passw0rd using the --filter= option to specify the username.

r  r  r`   ra   rb   rc   rd   re   r  r  rs   r6  zSet passwordrj   rk   rl   rm   ro   rp   rq   rr   z--clear-smartcard-requiredz0Don't require a smartcard for interactive logonsr  Nc                 óZ  — |€|€t        d«      ‚|}|
r,|�|dk7  rt        d«      ‚|rt        d«      ‚|rt        d«      ‚|	r|
st        dd«      }	 |
rnA|�|dk7  rn9t        d	«      }t        d
«      }||k(  sd }| j                  j	                  d«       ŒD|€dt        j                  |«      z  }|j                  «       }|j                  |«      }|j                  |j                  «       t        j                  z  «       t        |t        «       ||¬«      }|
rfd}	 d|xs |z  }t        j                   }|j#                  ||d¬«       d|xs |z  }|j%                  |«       | j                  j	                  d«       y d}	 |r-d|xs |z  }t        j                   }|j#                  ||d¬«       d|xs |z  }|j)                  ||||¬«       | j                  j	                  d«       y # t&        $ r}t        |›d|›�«      ‚d }~ww xY w# t&        $ r}t        |›d|›�«      ‚d }~ww xY w)Nr!  rC   r‡   rˆ   z[It is not allowed to specify --clear-smartcard-required together with --smartcard-required.r‰   rŠ   Tr‹   rŒ   r�   r"  r“   z1Failed to set UF_SMARTCARD_REQUIRED for user '%s')Úonz&Failed to enable account for user '%s'ú: zAdded UF_SMARTCARD_REQUIRED OK
z4Failed to remove UF_SMARTCARD_REQUIRED for user '%s'Fz$Failed to set password for user '%s')Úforce_change_at_next_loginr�   r9  )r   r   r   r±   r²   rñ   rò   rµ   r¶   Úset_gensec_featuresÚget_gensec_featuresr   ÚFEATURE_SEALr
   r	   r   ÚUF_SMARTCARD_REQUIREDÚtoggle_userAccountFlagsr$  r¹   Úsetpassword)rº   r�   rø   r„   rƒ   r…   rd   r>  r¼   r½   r°   Úclear_smartcard_requiredr»   rÏ   r–   rÑ   rÒ   Úcommandr5   r  s                       r*   rÔ   zcmd_user_setpassword.runî  s�  € ð ˆ>˜hÐ.ÜÐUÓVÐVàˆáØÐ#¨°BªÜ"ð $Ió Jð Jñ )Ü"ð $Ió Jð Jñ (Ü"ð $Ió Jð Jñ Ñ#5Ü/°°SÓ9ˆHàÙ!ØØÐ#¨°BªØÜÐ/Ó0ˆHÜ$Ð%8Ó9ˆNØ˜~Ò-Ø�Ø—	‘	—‘Ð BÔCð ð ˆ>Ø?Ä3×CTÑCTÐU]ÓC^Ñ_ˆFà×#Ñ#Ó%ˆØ×(Ñ(¨Ó,ˆà×!Ñ! %×";Ñ";Ó"=Ä×@SÑ@SÑ"SÔTä˜!¬.Ó*:Ø"'¨Bô0ˆñ ØˆGð>ØMÐQYÒQcÐ]cÑd�Ü×2Ñ2�Ø×-Ñ-¨f°eÀÐ-ÔEØBÀhÒFXÐRXÑY�Ø×$Ñ$ VÔ,ð �I‰I�O‰OÐ>Õ?àˆGð>Ù+ØTÐX`ÒXjÐdjÑk�GÜ ×6Ñ6�EØ×1Ñ1°&¸%ÀEÐ1ÔJØ@ÀHÒDVÐPVÑW�Ø×!Ñ! &¨(Ø=VØ+3ð "ô 5ð �I‰I�O‰OÐ3Õ4øô% ò >ä"ªw¹Ð#<Ó=Ð=ûð>ûô ò >ä"ªw¹Ð#<Ó=Ð=ûð>ús2   ÄAG+ ÆAH Ç+	H	Ç4HÈH	È	H*ÈH%È%H*)NNNNNNNFFFFr'  rã   r,   r*   rv  rv  ¶  sÒ   „ ñð4 @€Hð ×)Ñ)Ø×-Ñ-Ø×.Ñ.ñÐñ 	ˆt�WÐ#JÐQTØ 3ô	(áˆzÐ @ÀsÔKÙˆ ^¸#Ô>ÙÐ,Ø@Ø"ô	$ñ 	Ð"Ø.Ø"ô	$ñ 	Ð%Ø@Ø"ô	$ñ 	Ð+ØFØ"ô	$ð€Mð& �€JàGKØ26Ø=BØ?DôJ5r,   rv  c                   ó<   ‡ — e Zd Zˆ fd„Zd„ Zdd„Z	 dd„Zd„ Zˆ xZS )ÚGetPasswordCommandc                 ó8   •— t         t        | �  «        d | _        y ©N)Úsuperr„  Ú__init__r–   ©rº   Ú	__class__s    €r*   rˆ  zGetPasswordCommand.__init__=  s   ø€ ÜÔ  $Ñ0Ô2Øˆ�r,   c                 óÞ   — t        t        j                  «       «      D ]M  }t        j                  t        |   j                  dd«      z  }|j                  ||t        j                  «       ŒO y )Nr5   r   )ÚsortedÚvirtual_attributesÚkeysrñ   ÚATTR_FLAG_HIDDENr·   Úschema_attribute_addÚSYNTAX_OCTET_STRING)rº   rÒ   Úar5   s       r*   Úinject_virtual_attributesz,GetPasswordCommand.inject_virtual_attributesA  s_   € ô Ô*×/Ñ/Ó1Ó2ò 	JˆAÜ×(Ñ(Ô+=¸aÑ+@×+DÑ+DÀWÈaÓ+PÑPˆEØ×&Ñ& q¨%´×1HÑ1HÕIñ	Jr,   c                 ó€  — t        j                  «       }|j                  «        |€|rn�|j                  «       j	                  d«      rna|j                  «       j	                  d«      rt        d«      ‚|j                  «       j	                  d«      rt        d«      ‚|st        d«      ‚|r| j                  j                  d|z  «       t        |t        «       || j                  ¬«      }	 |j                  d	t        j                  d
g¬«      }t        |«      dk(  sJ ‚|d   j                  d
«      }t        |«      dk(  sJ ‚t!        t"        j$                  |d   «      }t'        |«      t"        j(                  k(  sJ ‚	 | j-                  |«       |S # t*        $ r!}	t        dt"        j(                  z  «      ‚d }	~	ww xY w)Núldapi://úldap://z/--url ldap:// is not supported for this commandúldaps://z0--url ldaps:// is not supported for this commandz/--url requires an ldapi:// url for this commandúConnecting to '%s'
r“   rC   ÚtokenGroups©rì   rí   rï   r   r   zEYou need to specify an URL that gives privileges as SID_NT_SYSTEM(%s))r   ÚCredentialsÚset_anonymousÚlowerÚ
startswithr   r±   r²   r
   r	   r–   ró   rñ   rP  rM   r·   r   r   rN  rÚ   ÚSID_NT_SYSTEMr¹   r“  )
rº   r”   Úallow_localÚverboserÑ   rÒ   rù   ÚsidsÚsidr  s
             r*   Úconnect_system_samdbz'GetPasswordCommand.connect_system_samdbH  s‡  € ô
 ×'Ñ'Ó)ˆØ×ÑÔàˆ;™;ØØ�Y‰Y‹[×#Ñ# JÔ/ØØ�Y‰Y‹[×#Ñ# IÔ.ÜÐPÓQÐQØ�Y‰Y‹[×#Ñ# JÔ/ÜÐQÓRÐRÙÜÐPÓQÐQáØ�I‰I�O‰OÐ2°SÑ8Ô9ä˜#¬NÓ,<Ø"'¨D¯G©Gô5ˆð	9ð —,‘, B¬c¯n©nÀ]ÀO�,ÓTˆCÜ�s“8˜q’=Ð �=Ø�q‘6—:‘:˜mÓ,ˆDÜ�t“9 ’>Ð!�>ÜœX×-Ñ-¨t°A©wÓ7ˆCÜ�s“8œx×5Ñ5Ò5Ð5Ñ5ð
 	×&Ñ& uÔ-àˆøô ò 	9ÜÐfÜ (× 6Ñ 6ñ 8ó 9ð 9ûð	9ús   Ã-BF Æ	F=ÆF8Æ8F=c	           	      ó  ‡ ‡D‡E‡F‡G‡H‡I‡J‡K‡L‡M‡N‡O‡P‡Q— d„ ŠHd„ ŠMg d¢ŠGˆGˆHfd„ŠNdFˆMˆNfd„	}	|d d  }
d|
v }d}g }g }|
D ]  } |	|«      }|j                  |«       Œ g }d}|D ]=  }|d   �d	}Œ|d
   �|j                  |«       Œ"|d   |v rŒ*|j                  |d   «       Œ? |s$ddg}|D ]  } |	|«      }|j                  |«       Œ |r(|r&ddg}|D ]  } |	|d	¬«      }|j                  |«       Œ |D ]  }|d   |v rŒ|j                  |d   «       Œ  |t        j                  k(  rddg}ng }	 |j                  |||||¬«      }t	        |«      dk(  rt        d|xs |z  «      ‚t	        |«      dkD  rt        dt	        |«      |fz  «      ‚	 |d   ŠOd ŠPd ŠQd‰Ov r"‰Od   d   }t        t        j                  |«      ŠPd‰Ov r‰Od   d   ŠQt        ‰Od   d   «      }d‰Ov rt        ‰Od   d   «      }n%|j                  «       }|›d|j                  «       ›�}i ŠFdGˆFˆPfd„	ŠIˆIfd„}d ŠEd } |«       \  }}|dv rO|j                  j                  }|j                  r-d„ }t!        t#        j$                  ||j                  «      d «      ŠE|r“ ‰Id d!¬"«      } | �‡	 t'        | «      }!t)        j*                  «       }"|"j-                  «        |"j/                  |!«       d }#d }$‰Q�|"j1                  «       }#‰Q}$n!‰E�|�|"j3                  |«      }#‰Ej4                  }$|$�
|$|#k(  r|!‰Fd#<   ˆ fd'„ŠLd(ŠDˆDfd)„}&ˆIˆKˆLfd*„}'ˆEˆQfd+„ŠKˆHfd,„}(t;        t<        j                  «       «      D �]  }d })|D ]0  }*|*d   €Œ	|*d   j                  «       |j                  «       k7  rŒ.|*}) n |)€Œ>|)d-   }+|d.k(  r  ‰Id#«      },|,€ŒS ‰L||,|xs |«      }-|-€Œd|-}.�n€|d/k(  r ‰Id#«      }.|.�€pŒy|d0k(  r¢ ‰Id#«      },|,€Œ‰ ‰L||,|xs |«      }-|-€Œšt?        j@                  d1«      }/tC        jD                  «       }0|0jG                  |-«       |0jG                  |/«       |0jI                  «       |/z   }1d2tK        jL                  |1«      jO                  d3«      z   }.nÈ|d4k(  r |(|+«      }2 |'|d5|2||«      }3|3€�Œ=|3}.n¨|d6k(  r |(|+«      }2 |'|d7|2||«      }3|3€�Œ]|3}.nˆ|d8k(  r ‰Id d!¬"«      }.|.€w�Œs|d9k(  r|}.|.€l�Œ~|jQ                  d:«      rW ‰Id;«      }4|4€�Œ›|t	        d:«      d  }3	 tS        |3«      }5|jW                  «       }6|j                  «       }7 |&|5|4|||6|7«      }.|.€�Œæ�Œèt        jX                  |.t        jZ                  |«      ‰O|<   �Œ ˆOfd<„}8ˆOfd=„ŠJˆJfd>„}9ˆJfd?„}:ˆJfd@„};i }<‰GD ]�  }=|D ]†  }*|*d
   €Œ	|*d
   |=k7  rŒ |8|*d   «      }>|>€Œ |>›dA|=›�}?|?|<v rŒ,|=|<|?<   d }.|=dBk(  r	 |9|>«      }.n|=dCk(  r	 |:|>«      }.n|=dDk(  r |;|>«      }.|.€Œ_t        jX                  |.t        jZ                  |?«      ‰O|?<   Œˆ Œ� ‰Oj                  «       D ]u  }@d}A|D ]*  }*@j                  «       |*d   j                  «       k7  rŒ(d	}A n ArŒ7d }B|D ]*  }C@j                  «       |Cd   j                  «       k7  rŒ(C}B n B€Œk|rBdE   sŒs‰O@= Œw ‰OS # t
        $ r}t        d|xs |›d|›�«      ‚d }~ww xY w# t
        $ r1}%‰ j6                  j9                  d$|xs |›d%|%›d&�«       Y d }%~%�Œàd }%~%ww xY w# tT        $ r Y �Œ¹w xY w)HNc                 óª   — | sy | D ]K  }|j                  «       j                  d|j                  «       z  «      sŒ4|j                  d«      \  }}}|c S  y )Nz%s=ú=)r�  rž  Ú	partition)ÚoptsÚnameÚoÚkeyr3   Úvals         r*   Ú
get_optionz=GetPasswordCommand.get_account_attributes.<locals>.get_optionv  sT   € ÙØØò �Ø—7‘7“9×'Ñ'¨°·
±
³Ñ(<Õ=Ø$%§K¡K°Ó$4‘M�S˜!˜SØ’Jðð r,   c                 ó    — t        t        j                  «       «      D ].  }|j                  «       | j                  «       k7  rŒ%t        |   c S  y r†  )rŒ  r�  rŽ  r�  )ÚattrÚvans     r*   Úget_virtual_attr_definitionzNGetPasswordCommand.get_account_attributes.<locals>.get_virtual_attr_definition  sG   € ÜÔ0×5Ñ5Ó7Ó8ò /�Ø—9‘9“; $§*¡*£,Ò.ØÜ)¨#Ñ.Ò.ð/ð r,   )ÚGeneralizedTimeÚUnixTimeÚTimeSpecc                 óv   •—  ‰| d«      }|€y ‰D ]'  }|j                  «       |j                  «       k7  rŒ%|c S  y )NÚformat)r�  )r©  Ú
formatnameÚfmÚformatsr®  s      €€r*   Úget_virtual_format_definitionzPGetPasswordCommand.get_account_attributes.<locals>.get_virtual_format_definitionŒ  sK   ø€ Ù# D¨(Ó3ˆJØÐ!ØØò �Ø—8‘8“: ×!1Ñ!1Ó!3Ò3ØØ’	ðð r,   Fc                 ó¶   •— | j                  d«      \  }}}|r|j                  d«      }ng }i }| |d<   ||d<   ||d<    ‰|«      |d<    ‰|«      |d<   ||d<   |S )Nú;Úraw_attrr°  r©  ÚvattrÚvformatÚ	is_hidden)r¨  rO  )	r¾  rÁ  r°  r3   Úfulloptsr©  r’  r²  r»  s	          €€r*   Úparse_raw_attrzAGetPasswordCommand.get_account_attributes.<locals>.parse_raw_attr–  sz   ø€ Ø"*×"4Ñ"4°SÓ"9ÑˆT�1�hÙØ—~‘~ cÓ*‘à�ØˆAØ$ˆAˆj‰MØˆAˆf‰IØˆAˆf‰IÙ4°TÓ:ˆAˆg‰JÙ8¸Ó>ˆAˆi‰LØ&ˆAˆk‰NØˆHr,   Ú*r¿  TrÀ  r¾  rL  ÚuserPrincipalNameÚsupplementalCredentialsÚ
unicodePwd)rÁ  r°  zshow_deleted:1úshow_recycled:1)rì   rî   rí   rï   rd  r   rð   r   z*Matched %u multiple users with filter "%s"z!Failed to get password for user 'r#  ú@c                 ó  •— | ‰v r‰|    S ‰€y |dk  r"t        ‰j                  j                  «      |z   }d}‰j                  j                  D ]=  }|dz  }||k  rŒ| |j                  k7  rŒt	        j
                  |j                  «      c S  y )Nr   r   )rM   ÚsubÚpackagesrª  ÚbinasciiÚa2b_hexÚdata)rª  Úmin_idxr
  ÚpÚ
calculatedÚscs       €€r*   Úget_packagez>GetPasswordCommand.get_account_attributes.<locals>.get_packageù  s“   ø€ Ø�zÑ!Ø! $Ñ'Ð'ØˆzØØ˜Š{Ü˜bŸf™fŸo™oÓ.°Ñ8�ØˆCØ—V‘V—_‘_ò 0�Ø�q‘�Ø˜'’>ØØ˜1Ÿ6™6’>Øä×'Ñ'¨¯©Ó/Ò/ð0ð r,   c                  ó’   •—  ‰d«      } | € ‰d«      } | €yt        t        j                  | «      }|j                  |j                  fS )NzPrimary:Kerberos-Newer-KeyszPrimary:Kerberos)r   N)r   r   Úpackage_PrimaryKerberosBlobÚversionÚctr)Úprimary_krb5Ú	krb5_blobrÔ  s     €r*   Úget_kerberos_ctrzCGetPasswordCommand.get_account_attributes.<locals>.get_kerberos_ctr  sR   ø€ Ù&Ð'DÓEˆLØÐ#Ù*Ð+=Ó>�ØÐ#Ø Ü"¤8×#GÑ#GØ#/ó1ˆIà×%Ñ% y§}¡}Ð5Ð5r,   )r�   r�   c                 ó    — | j                   dk(  S )Né   )Úkeytype)Úks    r*   Ú	is_aes256z<GetPasswordCommand.get_account_attributes.<locals>.is_aes256  s   € ØŸ9™9¨™?Ð*r,   zPrimary:SambaGPGéÿÿÿÿ)rÐ  úPrimary:CLEARTEXTú
WARNING: 'z/': SambaGPG can't be decrypted into CLEARTEXT: ú
c                 óÆ   •— 	 t        t        |«      d«      }|j                  d«      }|S # t        $ r,}‰j                  j	                  d|›d| ›d�«       Y d }~y d }~ww xY w)Nz	utf-16-lerã  z5': CLEARTEXT is invalid UTF-16-LE unable to generate rä  úutf-8)rÚ   r   ÚUnicodeDecodeErrorr±   r²   Úencode)r’  Úbr�   ÚurÓ   Úu8rº   s         €r*   Úget_utf8z;GetPasswordCommand.get_account_attributes.<locals>.get_utf8Q  s\   ø€ ðÜœ	 !› kÓ2�ð
 —‘˜'Ó"ˆBØˆIøô &ò Ø—	‘	—’Ú (ª!ð!-ô .äûðús   ƒ+ «	A ´"AÁA ÚDigestc                 ól  •— | dk(  r|}|}�n4| dk(  r"|j                  «       }|j                  «       }�n| dk(  r"|j                  «       }|j                  «       }�næ| dk(  r|}|j                  «       }�nÍ| dk(  r|}|j                  «       }�n´| dk(  r"|j                  «       }|j                  «       }�n�| dk(  r"|j                  «       }|j                  «       }�nf| dk(  r|}|j                  «       }�nM| d	k(  r"|j                  «       }|j                  «       }�n&| d
k(  r"|j                  «       }|j                  «       }�nÿ| dk(  r|}|j                  «       }�næ| dk(  r|}|j                  «       }�nÍ| dk(  r"|j                  «       }|j                  «       }�n¦| dk(  r"|j                  «       }|j                  «       }�n| dk(  r|}d}�nt| dk(  r|j                  «       }d}�n[| dk(  r|j                  «       }d}�nB| dk(  r|›d|›�}d}�n2| dk(  r'|j                  «       ›d|j                  «       ›�}d}�n| dk(  r&|j                  «       ›d|j                  «       ›�}d}nÛ| dk(  r|}‰
}nÑ| dk(  r|j                  «       }‰
}n¹| dk(  r|j                  «       }‰
}n¡| dk(  r|}‰
}n—| dk(  r|j                  «       }‰
}n| dk(  r|j                  «       }‰
}ng| dk(  r
|›d|›�}‰
}nX| dk(  r&|j                  «       ›d|j                  «       ›�}‰
}n-| dk(  r&|j                  «       ›d|j                  «       ›�}‰
}nd}t        t        j                  |«      }	 t        j                  t        |j                  | dz
     j                  «      «      }	|›d ›d t        |	«      ›�S # t        $ r Y y w xY w)!Nr   rŽ   r�   r�   é   r‘   é   é   é	   é
   é   é   é   é   é   rC   r?   é   rÝ  ú\é   é   é   é   é   r/  é   é   é   é   é   ú:)r�  Úupperr   r   Úpackage_PrimaryWDigestBlobrÍ  ÚhexlifyÚ	bytearrayÚhashesÚhashr   rö   )ÚiÚprimary_wdigestÚaccount_nameÚaccount_upnÚdomainÚ
dns_domainÚuserÚrealmÚdigestsÚdigestÚDIGESTs             €r*   Úget_wDigestz>GetPasswordCommand.get_account_attributes.<locals>.get_wDigest_  s–  ø€ à�AŠvØ$�Ø’Ø�a’Ø$×*Ñ*Ó,�ØŸ™›’Ø�a’Ø$×*Ñ*Ó,�ØŸ™›’Ø�a’Ø$�ØŸ™›’Ø�a’Ø$�ØŸ™›’Ø�a’Ø$×*Ñ*Ó,�ØŸ™›’Ø�a’Ø$×*Ñ*Ó,�ØŸ™›’Ø�a’Ø$�Ø"×(Ñ(Ó*’Ø�a’Ø$×*Ñ*Ó,�Ø"×(Ñ(Ó*’Ø�b’Ø$×*Ñ*Ó,�Ø"×(Ñ(Ó*’Ø�b’Ø$�Ø"×(Ñ(Ó*’Ø�b’Ø$�Ø"×(Ñ(Ó*’Ø�b’Ø$×*Ñ*Ó,�Ø"×(Ñ(Ó*’Ø�b’Ø$×*Ñ*Ó,�Ø"×(Ñ(Ó*’Ø�b’Ø#�Ø’Ø�b’Ø#×)Ñ)Ó+�Ø’Ø�b’Ø#×)Ñ)Ó+�Ø’Ø�b’Ú$*©LÐ9�Ø’Ø�b’Ø$*§L¡L¥N°L×4FÑ4FÔ4HÐI�Ø’Ø�b’Ø$*§L¡L¥N°L×4FÑ4FÔ4HÐI�Ø‘Ø�b’Ø$�Ø‘Ø�b’Ø$×*Ñ*Ó,�Ø‘Ø�b’Ø$×*Ñ*Ó,�Ø‘Ø�b’Ø#�Ø‘Ø�b’Ø#×)Ñ)Ó+�Ø‘Ø�b’Ø#×)Ñ)Ó+�Ø‘Ø�b’Ú$*©LÐ9�Ø‘Ø�b’à$*§L¡L¥N°L×4FÑ4FÔ4HÐI�Ø‘Ø�b’à$*§L¡L¥N°L×4FÑ4FÔ4HÐI�Ø‘à�ä ¤×!DÑ!DØ!0ó2ˆGðÜ!×)Ñ)¬)°G·N±NÀ1ÀqÁ5Ñ4I×4NÑ4NÓ*OÓP�Ú%)ª5´*¸VÔ2DÐEÐEøÜò Ùðús   ÍA
N' Î'	N3Î2N3c                 óÈ   •— d }d } ‰	d«      }|� ‰
|||«      \  }}|€= ‰	d«      }|�/ ‰| ||xs |«      }|�t        t        |«      t        |«      |«      }|€|}|€y d|z   S )NzPrimary:userPasswordrâ  ú{CRYPT})rW   rÚ   r   )r’  Ú	algorithmrP   r�   r  ÚsvÚfbré  rë  rÔ  Úget_userPassword_hashrì  s            €€€r*   Úget_virtual_crypt_valuezJGetPasswordCommand.get_account_attributes.<locals>.get_virtual_crypt_valueÊ  s”   ø€ ØˆBØˆBÙÐ2Ó3ˆAØˆ}Ù0°°I¸vÓF‘��RØˆzñ  Ð 3Ó4�Ø�=Ù! ! Q¨Ò(@°LÓA�BØ�~ô -¬S°«^¼ZÈ»^ÈVÓT˜Ø�:ð �BØˆzØØ˜r‘>Ð!r,   c                 óÆ  •— t        t        j                  | «      }d}‰�‰}n‰�‰j                  d d }ny|t	        |j
                  j                  «      k7  ryd|z  }|}|dkD  rd||fz  }d }|j                  D ]b  }	t        |	j                  «      }
|€"|	j                  |k(  r|
j                  |«      r|
}|	j                  |k(  sŒL|
j                  |«      sŒ^|
|fc S  d |fS )Nr  r?   )NNz$%d$r   z$%d$rounds=%d)r   r   Úpackage_PrimaryUserPasswordBlobÚvaluer	  Úcurrent_nt_hashr  r
  r   Úschemerž  )Úblobr  rP   ÚupÚSCHEMEÚcurrent_hashÚscheme_prefixÚprefixÚscheme_matchÚhÚh_valueÚ
aes256_keyrÇ  s              €€r*   r  zHGetPasswordCommand.get_account_attributes.<locals>.get_userPassword_hashã  s  ø€ ÜœH×DÑDÀdÓKˆBØˆFð Ð%Ø)‘ØÐ'Ø)×/Ñ/°°Ð4‘à!àœy¨×);Ñ);×)@Ñ)@ÓAÒAØ!à" YÑ.ˆMØ"ˆFØ˜ŠzØ(¨I°vÐ+>Ñ>�ØˆLà—Y‘Yò 	3�ô % Q§W¡WÓ-�Ø Ð(Ø—H‘H Ò&Ø×&Ñ& }Ô5Ø#*�LØ—8‘8˜vÓ%¨'×*<Ñ*<¸VÕ*DØ# \Ð2Ò2ð	3ð ˜,Ð'Ð'r,   c                 óR   •—  ‰| d«      }|€y	 t        |«      S # t        $ r Y yw xY w)NrP   r   )rÛ   Ú
ValueError)r©  r­  r®  s     €r*   Ú
get_roundsz=GetPasswordCommand.get_account_attributes.<locals>.get_rounds  s7   ø€ Ù˜T 8Ó,ˆCØˆ{ØðÜ˜3“x�øÜò Ùðús   �
 š	&¥&r©  r6   r7   rX   r�   z{SSHA}rB   rZ   rï  r[   r‘   r8   r]   ÚvirtualWDigestzPrimary:WDigestc                 ó†   •— | j                  «       }d }‰j                  «       D ]  }||j                  «       k7  rŒ|} |S  |S r†  )r�  rŽ  )ÚsrcattrgÚsrcattrlÚsrcattrrß  Úobjs       €r*   Úget_src_attrnamezCGetPasswordCommand.get_account_attributes.<locals>.get_src_attrnamei  sN   ø€ Ø—~‘~Ó'ˆHØˆGØ—X‘X“Zò �Ø˜qŸw™w›yÒ(ØØ�ØØˆNðð
 ˆNr,   c                 ó  •— | ‰vry t        ‰|    d   «      }|j                  d«      r"t        j                  |«      }t	        |«      }|S 	 t        |«      }|dk(  ry |dk\  ry t        |«      }|S # t        $ r
}Y d }~y d }~ww xY w)Nr   z.0Zl   ÿÿÿÿ )rÚ   Úendswithrñ   Ústring_to_timeÚfloatrÛ   r/  r   )r5  ÚvstrÚvutÚvflÚvntrÓ   r6  s         €r*   Úget_src_time_floatzEGetPasswordCommand.get_account_attributes.<locals>.get_src_time_floats  s”   ø€ Ø˜cÑ!ØÜ�s˜7‘| A‘Ó'ˆDØ�}‰}˜UÔ#Ü×(Ñ(¨Ó.�Ü˜C“j�Ø�
ðÜ˜$“i�ð �aŠxØØÐ(Ò(ØÜ˜sÓ#ˆCØˆJøô ò Üûðús   ÁA0 Á0	BÁ>Bc                 óÎ   •—  ‰| «      }|€y t        |«      }	 dt        j                  |«      z  }|S # t        $ r(}|j                  t        j
                  k(  rY d }~y ‚ d }~ww xY w)Nú%s)rÛ   rñ   Ú
timestringÚOSErrorÚerrnoÚ	EOVERFLOW)r5  r>  r=  ÚvrÓ   r@  s        €r*   Úget_generalizedtimezFGetPasswordCommand.get_account_attributes.<locals>.get_generalizedtimeˆ  se   ø€ Ù$ WÓ-ˆCØˆ{ØÜ�c“(ˆCðØœ3Ÿ>™>¨#Ó.Ñ.�ð
 ˆHøô	 ò Ø—7‘7œeŸo™oÒ-ÜØûðús   ™3 ³	A$¼AÁAÁA$c                 ó>   •—  ‰| «      }|€y t        |«      }d|z  }|S )Nz%d)rÛ   )r5  r>  r=  rG  r@  s       €r*   Úget_unixepochz@GetPasswordCommand.get_account_attributes.<locals>.get_unixepoch•  s,   ø€ Ù$ WÓ-ˆCØˆ{ØÜ�c“(ˆCØ�s‘
ˆAØˆHr,   c                 ó(   •—  ‰| «      }|€y d|z  }|S )Nz%.9frã   )r5  r>  rG  r@  s      €r*   Úget_timespecz?GetPasswordCommand.get_account_attributes.<locals>.get_timespec�  s#   ø€ Ù$ WÓ-ˆCØˆ{ØØ˜‘ˆAØˆHr,   z;format=r³  r´  rµ  rÁ  )F©r   ).ri  rñ   rP  ró   rM   r¹   r   r   r   ÚsupplementalCredentialsBlobrÚ   Údomain_dns_namer�  rR   r.   rŽ  ÚnextÚbuiltinsrø   Úgpg_decryptr   r›  rœ  Úset_utf16_passwordÚget_nt_hashÚget_aes256_keyr!  r±   r²   rŒ  r�  rE   rF   ÚhashlibÚsha1Úupdater  rG   rH   rJ   rž  rÛ   r/  Údomain_netbios_nameÚMessageElementÚFLAG_MOD_REPLACE)Rrº   rÒ   r�   Úbasednrø   rí   rï   r%   Úsupport_pw_attrsrÃ  Ú	raw_attrsÚhas_wildcard_attrÚhas_virtual_attrsÚrequested_attrsÚimplicit_attrsr¾  r’  Úsearch_attrsÚrequired_attrsÚrequired_attrÚsearch_controlsrù   r  Úsc_blobr  r  r  rÛ  Úkerberos_saltÚkrb5_vÚkrb5_ctrrà  ÚsgvÚcvÚtmpÚ	decryptedr'  rÓ   r  r  r0  r¿  ÚraÚ	attr_optsré  rë  rG  rR   r+  ÚbvrP   Úxr  r  r  r  r7  rH  rJ  rL  Úgenerated_formatsr¹  r5  ÚanÚdelnameÚkeepÚdattrÚiar  r-  rÒ  rº  r®  rÔ  r@  r  rì  r²  r»  r6  rÓ  rÇ  sR   `                                                                   @@@@@@@@@@@@@@r*   Úget_account_attributesz)GetPasswordCommand.get_account_attributess  sÏ  ÿþ€ ò	ò	ò
ˆõ	ö	ð ™!�Hˆ	Ø 9Ð,ÐØ!ÐØˆØˆà!ò 	&ˆHÙ˜xÓ(ˆAØ×"Ñ" 1Õ%ð	&ð ˆØ!ÐØ ò 	/ˆAØ�‰zÐ%Ø$(Ð!ØØ�‰|Ð'ð
 ×%Ñ% aÔ(ØØ�‰} Ñ,ØØ×Ñ  *¡Õ.ð	/ñ !à Ø#ðˆNð "0ò )�Ù" =Ó1�Ø×%Ñ% aÕ(ð)ñ Ùà-Ø ð"�ð &4ò -�MÙ& }ÀÔE�AØ"×)Ñ)¨!Õ,ð-ð  ò 	+ˆAØ�‰y˜LÑ(ØØ×Ñ  &¡	Õ*ð	+ð
 ”C—N‘NÒ"Ø/Ð1BÐC‰Oà ˆOð
	gØ—,‘, F°vØ%*°,Ø(7ð ó 9ˆCô �3‹x˜1Š}ÜÐ :¸hÒ>PÈ&Ñ QÓRÐRÜ�3‹x˜!Š|ÜÐ LÔPSÐTWÓPXÐZ`ÐOaÑ aÓbÐbð ð
 �!‰fˆàˆØˆ
Ø$¨Ñ+ØÐ3Ñ4°QÑ7ˆGÜœH×@Ñ@À'ÓJˆBØ˜3ÑØ˜\Ñ*¨1Ñ-ˆJÜ˜3Ð/Ñ0°Ñ3Ó4ˆØ #Ñ%Ü˜cÐ"5Ñ6°qÑ9Ó:‰Kà×)Ñ)Ó+ˆEÚ%1°5·;±;´=ÐAˆKàˆ
ö	ô$	6ð ˆ
Øˆá-Ó/Ñˆ�Ø�VÑØ$ŸM™M×0Ñ0ˆMà�}Š}ò+ä!¤(§/¡/°)¸X¿]¹]Ó"KØ"&ó(�
ñ ñ Ð0¸"Ô=ˆCØˆð:Ü$ SÓ)�Bô &×1Ñ1Ó3�CØ×%Ñ%Ô'Ø×*Ñ*¨2Ô.à $�IØ#'�Là!Ð-Ø$'§O¡OÓ$5˜	Ø'1™Ø#Ð/°MÐ4MØ$'×$6Ñ$6°}Ó$E˜	Ø'1×'7Ñ'7˜à#Ð/°LÀIÒ4MØ:<˜
Ð#6Ñ7ô	ð ˆôd	öV	"õ2%	(ôV	ô Ô*×/Ñ/Ó1Ó2ó O	DˆAØˆEØ%ò �Ø�g‘;Ð&ØØ�f‘:×#Ñ#Ó%¨¯©«Ò2ØØ�Ùðð ˆ}ØØ˜f™ˆIàÐ*Ò*ÙÐ 3Ó4�Ø�9ØÙ˜a  HÒ$<°Ó=�Ø�:ØØ’ØÐ-Ò-ÙÐ 3Ó4�Ø‘9ØØ�mÒ#ÙÐ 3Ó4�Ø�9ØÙ˜a  HÒ$<°Ó=�Ø�:ØÜ—z‘z !“}�Ü—L‘L“N�Ø—‘˜”Ø—‘˜”Ø—X‘X“Z $Ñ&�Øœv×/Ñ/°Ó3×:Ñ:¸6ÓBÑB‘ØÐ*Ò*Ù# IÓ.�Ù+¨A¨q°&¸(ÀLÓQ�Ø�9ÙØ‘ØÐ*Ò*Ù# IÓ.�Ù+¨A¨q°&¸(ÀLÓQ�Ø�9ÙØ‘ØÐ'Ò'ñ  Ð 2¸BÔ?�Ø�9ÙØÐ+Ò+Ø!�Ø�9ÙØ—‘Ð.Ô/Ù"-Ð.?Ó"@�Ø"Ð*ÙØ”cÐ*Ó+Ð,Ð-�ðÜ˜A›�Að ×2Ñ2Ó4�Ø"×2Ñ2Ó4�
Ù  ?°LÀ+ÈvÐWaÓb�Ø�9ÙáÜ×'Ñ'¨¬3×+?Ñ+?ÀÓCˆC�‹Fð_O	Dôb	ô	ô*	ô	ô	ð ÐØò 	JˆBØ%ò J�Ø�i‘=Ð(ØØ�i‘= BÒ&ØÙ*¨2¨f©:Ó6�Ø�?ØÚ'.±Ð3�ØÐ*Ñ*ØØ(*Ð! "Ñ%à�ØÐ*Ò*Ù+¨GÓ4‘AØ˜:Ò%Ù% gÓ.‘AØ˜:Ò%Ù$ WÓ-�AØ�9ØÜ×,Ñ,¨Q´×0DÑ0DÀbÓI��B’ñ-Jð	Jð4 —x‘x“zò 	ˆGØˆDØ%ò �Ø—=‘=“? b¨¡n×&:Ñ&:Ó&<Ò<ØØ�Ùð	ñ
 ØàˆEØ$ò �Ø—=‘=“? b¨¡j×&6Ñ&6Ó&8Ò8ØØ�Ùð	ð
 ˆ}Øá ¨¨{Ò);ØØ�G‘ð+	ð, ˆ
øôc ò 	gåÈXÒM_ÐY_ÑM_ÑadÐeÓfÐfûð	gûôL !ò :Ø—I‘I—O’Oð %Ò4¨Ñ4²að9÷:ò :ûð:ûôh "ò ÚðúsD   Ä*AZ ÊBZ> Ó8[;Ú	Z;Ú!Z6Ú6Z;Ú>	[8Û&[3Û3[8Û;	\Ü\c                 óÆ  — |€t        d«      ‚|j                  d«      }g }|D ]»  }|j                  «       j                  «       }t        j                  «       D ]@  }|j                  «       |j                  «       k(  sŒ%t        |   d   }t        d|›d|›�«      ‚ t        j                  «       D ]'  }|j                  «       |j                  «       k(  sŒ%|} n ||gz  }Œ½ |S )NúPlease specify --attributesú,rY   zVirtual attribute 'z' not supported: )r   rO  ÚlstripÚrstripÚdisabled_virtual_attributesrŽ  r�  r�  )rº   Ú
attributesrï   Úpassword_attrsÚpaÚdaÚrÚvas           r*   Úparse_attributesz#GetPasswordCommand.parse_attributes×  sê   € àÐÜÐ<Ó=Ð=Ø× Ñ  Ó%ˆØˆØò 	#ˆBØ—‘“×#Ñ#Ó%ˆBÜ1×6Ñ6Ó8ò /�Ø—8‘8“: §¡£Ó+Ü3°BÑ7¸ÑA�AÝ&Ú')©1ð(.ó /ð /ð/ô
 )×-Ñ-Ó/ò �Ø—8‘8“: §¡£Ó+à�BÙð	ð
 ˜r˜dÑ"‰Nð	#ð Ðr,   )FF)T)	rÕ   rÖ   r×   rˆ  r“  r¤  ry  r†  Ú__classcell__©rŠ  s   @r*   r„  r„  ;  s'   ø„ ôòJó)ðX AEób	öHr,   r„  c            
       óÎ   ‡ — e Zd ZdZˆ fd„ZdZej                  ej                  dœZ	 e
dddedd	¬
«       e
dde¬«       e
deedd¬«       e
deddd¬«      gZdgZ	 	 	 dd„Zˆ xZS )Úcmd_user_getpassworda  Get the password fields of a user/computer account.

This command gets the logon password for a user/computer account.

The username specified on the command is the sAMAccountName.
The username may also be specified using the --filter option.

The command must be run from the root user id or another authorized user id.
The '-H' or '--URL' option only supports ldapi:// or [tdb://] and can be
used to adjust the local path. By default tdb:// is used by default.

The '--attributes' parameter takes a comma separated list of attributes,
which will be printed or given to the script specified by '--script'. If a
specified attribute is not available on an object it's silently omitted.
All attributes defined in the schema (e.g. the unicodePwd attribute holds
the NTHASH) and the following virtual attributes are possible (see --help
for which virtual attributes are supported in your environment):

   virtualClearTextUTF16: The raw cleartext as stored in the
                          'Primary:CLEARTEXT' (or 'Primary:SambaGPG'
                          with '--decrypt-samba-gpg') buffer inside of the
                          supplementalCredentials attribute. This typically
                          contains valid UTF-16-LE, but may contain random
                          bytes, e.g. for computer accounts.

   virtualClearTextUTF8:  As virtualClearTextUTF16, but converted to UTF-8
                          (only from valid UTF-16-LE).

   virtualSSHA:           As virtualClearTextUTF8, but a salted SHA-1
                          checksum, useful for OpenLDAP's '{SSHA}' algorithm.

   virtualCryptSHA256:    As virtualClearTextUTF8, but a salted SHA256
                          checksum, useful for OpenLDAP's '{CRYPT}' algorithm,
                          with a $5$... salt, see crypt(3) on modern systems.
                          The number of rounds used to calculate the hash can
                          also be specified. By appending ";rounds=x" to the
                          attribute name i.e. virtualCryptSHA256;rounds=10000
                          will calculate a SHA256 hash with 10,000 rounds.
                          Non numeric values for rounds are silently ignored.
                          The value is calculated as follows:
                          1) If a value exists in 'Primary:userPassword' with
                             the specified number of rounds it is returned.
                          2) If 'Primary:CLEARTEXT', or 'Primary:SambaGPG'
                             with '--decrypt-samba-gpg'. Calculate a hash with
                             the specified number of rounds.
                          3) Return the first CryptSHA256 value in
                             'Primary:userPassword'.


   virtualCryptSHA512:    As virtualClearTextUTF8, but a salted SHA512
                          checksum, useful for OpenLDAP's '{CRYPT}' algorithm,
                          with a $6$... salt, see crypt(3) on modern systems.
                          The number of rounds used to calculate the hash can
                          also be specified. By appending ";rounds=x" to the
                          attribute name i.e. virtualCryptSHA512;rounds=10000
                          will calculate a SHA512 hash with 10,000 rounds.
                          Non numeric values for rounds are silently ignored.
                          The value is calculated as follows:
                          1) If a value exists in 'Primary:userPassword' with
                             the specified number of rounds it is returned.
                          2) If 'Primary:CLEARTEXT', or 'Primary:SambaGPG'
                             with '--decrypt-samba-gpg'. Calculate a hash with
                             the specified number of rounds.
                          3) Return the first CryptSHA512 value in
                             'Primary:userPassword'.

   virtualWDigestNN:      The individual hash values stored in
                          'Primary:WDigest' where NN is the hash number in
                          the range 01 to 29.
                          NOTE: As at 22-05-2017 the documentation:
                          3.1.1.8.11.3.1 WDIGEST_CREDENTIALS Construction
                        https://msdn.microsoft.com/en-us/library/cc245680.aspx
                          is incorrect.

   virtualKerberosSalt:   This results the salt string that is used to compute
                          Kerberos keys from a UTF-8 cleartext password.

   virtualSambaGPG:       The raw cleartext as stored in the
                          'Primary:SambaGPG' buffer inside of the
                          supplementalCredentials attribute.
                          See the 'password hash gpg key ids' option in
                          smb.conf.

The '--decrypt-samba-gpg' option triggers decryption of the
Primary:SambaGPG buffer. Check with '--help' if this feature is available
in your environment or not (the python-gpgme package is required).  Please
note that you might need to set the GNUPGHOME environment variable.  If the
decryption key has a passphrase you have to make sure that the GPG_AGENT_INFO
environment variable has been set correctly and the passphrase is already
known by the gpg-agent.

Attributes with time values can take an additional format specifier, which
converts the time value into the requested format. The format can be specified
by adding ";format=formatSpecifier" to the requested attribute name, whereby
"formatSpecifier" must be a valid specifier. The syntax looks like:

  --attributes=attributeName;format=formatSpecifier

The following format specifiers are available:
  - GeneralizedTime (e.g. 20210224113259.0Z)
  - UnixTime        (e.g. 1614166392)
  - TimeSpec        (e.g. 161416639.267546892)

Attributes with an original NTTIME value of 0 and 9223372036854775807 are
treated as non-existing value.

Example1:
samba-tool user getpassword TestUser1 --attributes=pwdLastSet,virtualClearTextUTF8

Example2:
samba-tool user getpassword --filter=samaccountname=TestUser3 --attributes=msDS-KeyVersionNumber,unicodePwd,virtualClearTextUTF16

c                 ó*   •— t         t        | �  «        y r†  )r‡  rŠ  rˆ  r‰  s    €r*   rˆ  zcmd_user_getpassword.__init__`  s   ø€ ÜÔ" DÑ2Õ4r,   r  ©rƒ   r…   r`   ra   z2LDB URL for sam.ldb database or local ldapi serverrc   rd   re   r  r  rs   ú--attributesÚATTRIBUTELISTr€  ©rg   rf   rh   ri   ú--decrypt-samba-gpgrl   FÚdecrypt_samba_gpg©rf   rn   r   ri   r  c           	      ó  — |j                  «       | _        |rt        st        t        «      ‚|€|€t        d«      ‚|€dt        j                  |«      z  }|€t        d«      ‚| j                  |«      }| j                  |d¬«      }	| j                  |	|d |t
        j                  ||¬«      }
|	j                  |
t
        j                  «      }| j                  j                  d|z  «       | j                  j                  d«       y )	Nr!  r"  r{  T)r”   r   )r\  rø   rí   rï   r%   rB  zGot password OK
)rµ   r–   rR  r   Údecrypt_samba_gpg_helprñ   rò   r†  r¤  ry  rõ   Ú
write_ldifÚCHANGETYPE_NONEr±   r²   )rº   r�   rd   rø   r€  r‘  rƒ   r…   r�  rÒ   r6  Úldifs               r*   rÔ   zcmd_user_getpassword.runx  sû   € ð ×(Ñ(Ó*ˆŒá¥[ÜÔ5Ó6Ð6àˆ>˜hÐ.ÜÐUÓVÐVàˆ>Ø?Ä3×CTÑCTÐU]ÓC^Ñ_ˆFàÐÜÐ<Ó=Ð=à×.Ñ.¨zÓ:ˆà×)Ñ)¨a¸TÐ)ÓBˆà×)Ñ)¨%°Ø15Ø17Ü03×0AÑ0AØ0>Ø2Cð *ó Eˆð ×Ñ ¤S×%8Ñ%8Ó9ˆØ�	‰	�‰˜˜t™Ô$Ø�	‰	�‰Ð+Õ,r,   )NNNNNNN)rÕ   rÖ   r×   rØ   rˆ  rÙ   rÞ   rß   rá   râ   r   rÚ   Úvirtual_attributes_helpr”  rÜ   rÝ   rÔ   r‡  rˆ  s   @r*   rŠ  rŠ  î  s¤   ø„ ñpôb5ð @€Hð ×)Ñ)Ø×-Ñ-ñÐñ 	ˆt�WÐ#WÐ^aØ 3ô	(áˆzÐ @ÀsÔKÙˆ~ CØ+Ø&¨\ô	;ñ 	Ð$Ø*Ø"¨EÐ8Kô	Mð
€Mð �€Jà04Ø/3Ø(,÷-r,   rŠ  c                   óv  ‡ — e Zd ZdZˆ fd„ZdZej                  ej                  dœZ	 e
dddd¬	«       e
d
dedd¬«       e
dddedd¬«       e
ddedd¬«       e
deedd¬«       e
deddd¬«       e
d d!ed"d#¬«       e
d$d%ddd&¬«       e
d'ed(d)d*¬«       e
d+d,ddd-¬«       e
d.d/ddd0¬«      gZ	 	 	 	 	 d2d1„Zˆ xZS )3Úcmd_user_syncpasswordsa$  Sync the password of user accounts.

This syncs logon passwords for user accounts.

Note that this command should run on a single domain controller only
(typically the PDC-emulator). However the "password hash gpg key ids"
option should to be configured on all domain controllers.

The command must be run from the root user id or another authorized user id.
The '-H' or '--URL' option only supports ldapi:// and can be used to adjust the
local path.  By default, ldapi:// is used with the default path to the
privileged ldapi socket.

This command has three modes: "Cache Initialization", "Sync Loop Run" and
"Sync Loop Terminate".


Cache Initialization
====================

The first time, this command needs to be called with
'--cache-ldb-initialize' in order to initialize its cache.

The cache initialization requires '--attributes' and allows the following
optional options: '--decrypt-samba-gpg', '--script', '--filter' or
'-H/--URL'.

The '--attributes' parameter takes a comma separated list of attributes,
which will be printed or given to the script specified by '--script'. If a
specified attribute is not available on an object it will be silently omitted.
All attributes defined in the schema (e.g. the unicodePwd attribute holds
the NTHASH) and the following virtual attributes are possible (see '--help'
for supported virtual attributes in your environment):

   virtualClearTextUTF16: The raw cleartext as stored in the
                          'Primary:CLEARTEXT' (or 'Primary:SambaGPG'
                          with '--decrypt-samba-gpg') buffer inside of the
                          supplementalCredentials attribute. This typically
                          contains valid UTF-16-LE, but may contain random
                          bytes, e.g. for computer accounts.

   virtualClearTextUTF8:  As virtualClearTextUTF16, but converted to UTF-8
                          (only from valid UTF-16-LE).

   virtualSSHA:           As virtualClearTextUTF8, but a salted SHA-1
                          checksum, useful for OpenLDAP's '{SSHA}' algorithm.

   virtualCryptSHA256:    As virtualClearTextUTF8, but a salted SHA256
                          checksum, useful for OpenLDAP's '{CRYPT}' algorithm,
                          with a $5$... salt, see crypt(3) on modern systems.
                          The number of rounds used to calculate the hash can
                          also be specified. By appending ";rounds=x" to the
                          attribute name i.e. virtualCryptSHA256;rounds=10000
                          will calculate a SHA256 hash with 10,000 rounds.
                          Non numeric values for rounds are silently ignored.
                          The value is calculated as follows:
                          1) If a value exists in 'Primary:userPassword' with
                             the specified number of rounds it is returned.
                          2) If 'Primary:CLEARTEXT', or 'Primary:SambaGPG' with
                             '--decrypt-samba-gpg'. Calculate a hash with
                             the specified number of rounds
                          3) Return the first CryptSHA256 value in
                             'Primary:userPassword'.

   virtualCryptSHA512:    As virtualClearTextUTF8, but a salted SHA512
                          checksum, useful for OpenLDAP's '{CRYPT}' algorithm,
                          with a $6$... salt, see crypt(3) on modern systems.
                          The number of rounds used to calculate the hash can
                          also be specified. By appending ";rounds=x" to the
                          attribute name i.e. virtualCryptSHA512;rounds=10000
                          will calculate a SHA512 hash with 10,000 rounds.
                          Non numeric values for rounds are silently ignored.
                          The value is calculated as follows:
                          1) If a value exists in 'Primary:userPassword' with
                             the specified number of rounds it is returned.
                          2) If 'Primary:CLEARTEXT', or 'Primary:SambaGPG' with
                             '--decrypt-samba-gpg'. Calculate a hash with
                             the specified number of rounds.
                          3) Return the first CryptSHA512 value in
                             'Primary:userPassword'.

   virtualWDigestNN:      The individual hash values stored in
                          'Primary:WDigest' where NN is the hash number in
                          the range 01 to 29.
                          NOTE: As at 22-05-2017 the documentation:
                          3.1.1.8.11.3.1 WDIGEST_CREDENTIALS Construction
                        https://msdn.microsoft.com/en-us/library/cc245680.aspx
                          is incorrect.

   virtualKerberosSalt:   This results the salt string that is used to compute
                          Kerberos keys from a UTF-8 cleartext password.

   virtualSambaGPG:       The raw cleartext as stored in the
                          'Primary:SambaGPG' buffer inside of the
                          supplementalCredentials attribute.
                          See the 'password hash gpg key ids' option in
                          smb.conf.

The '--decrypt-samba-gpg' option triggers decryption of the
Primary:SambaGPG buffer. Check with '--help' if this feature is available
in your environment or not (the python-gpgme package is required).  Please
note that you might need to set the GNUPGHOME environment variable.  If the
decryption key has a passphrase you have to make sure that the GPG_AGENT_INFO
environment variable has been set correctly and the passphrase is already
known by the gpg-agent.

The '--script' option specifies a custom script that is called whenever any
of the dirsyncAttributes (see below) was changed. The script is called
without any arguments. It gets the LDIF for exactly one object on STDIN.
If the script processed the object successfully it has to respond with a
single line starting with 'DONE-EXIT: ' followed by an optional message.

Note that the script might be called without any password change, e.g. if
the account was disabled (a userAccountControl change) or the
sAMAccountName was changed. The objectGUID,isDeleted,isRecycled attributes
are always returned as unique identifier of the account. It might be useful
to also ask for non-password attributes like: objectSid, sAMAccountName,
userPrincipalName, userAccountControl, pwdLastSet and msDS-KeyVersionNumber.
Depending on the object, some attributes may not be present/available,
but you always get the current state (and not a diff).

If no '--script' option is specified, the LDIF will be printed on STDOUT or
into the logfile.

The default filter for the LDAP_SERVER_DIRSYNC_OID search is:
(&(objectClass=user)(userAccountControl:1.2.840.113556.1.4.803:=512)\
    (!(sAMAccountName=krbtgt*)))
This means only normal (non-krbtgt) user
accounts are monitored.  The '--filter' can modify that, e.g. if it's
required to also sync computer accounts.


Sync Loop Run
=============

This (default) mode runs in an endless loop waiting for password related
changes in the active directory database. It makes use of the
LDAP_SERVER_DIRSYNC_OID and LDAP_SERVER_NOTIFICATION_OID controls in order
get changes in a reliable fashion. Objects are monitored for changes of the
following dirsyncAttributes:

  unicodePwd, dBCSPwd, supplementalCredentials, pwdLastSet, sAMAccountName,
  userPrincipalName and userAccountControl.

It recovers from LDAP disconnects and updates the cache in conservative way
(in single steps after each successfully processed change).  An error from
the script (specified by '--script') will result in fatal error and this
command will exit.  But the cache state should be still valid and can be
resumed in the next "Sync Loop Run".

The '--logfile' option specifies an optional (required if '--daemon' is
specified) logfile that takes all output of the command. The logfile is
automatically reopened if fstat returns st_nlink == 0.

The optional '--daemon' option will put the command into the background.

You can stop the command without the '--daemon' option, also by hitting
strg+c.

If you specify the '--no-wait' option the command skips the
LDAP_SERVER_NOTIFICATION_OID 'waiting' step and exit once
all LDAP_SERVER_DIRSYNC_OID changes are consumed.

Sync Loop Terminate
===================

In order to terminate an already running command (likely as daemon) the
'--terminate' option can be used. This also requires the '--logfile' option
to be specified.


Example1:
samba-tool user syncpasswords --cache-ldb-initialize \
    --attributes=virtualClearTextUTF8
samba-tool user syncpasswords

Example2:
samba-tool user syncpasswords --cache-ldb-initialize \
    --attributes=objectGUID,objectSID,sAMAccountName,\
    userPrincipalName,userAccountControl,pwdLastSet,\
    msDS-KeyVersionNumber,virtualCryptSHA512 \
    --script=/path/to/my-custom-syncpasswords-script.py
samba-tool user syncpasswords --daemon \
    --logfile=/var/log/samba/user-syncpasswords.log
samba-tool user syncpasswords --terminate \
    --logfile=/var/log/samba/user-syncpasswords.log

c                 ó*   •— t         t        | �  «        y r†  )r‡  rš  rˆ  r‰  s    €r*   rˆ  zcmd_user_syncpasswords.__init__V  s   ø€ ÜÔ$ dÑ4Õ6r,   z(%prog [--cache-ldb-initialize] [options]rŒ  z--cache-ldb-initializez'Initialize the cache for the first timeÚcache_ldb_initializerl   )rf   ri   rn   z--cache-ldbz-optional LDB URL user-syncpasswords-cache.ldbzCACHE-LDB-PATHÚ	cache_ldbre   r`   ra   z)optional LDB URL for a local ldapi serverrc   rd   r  z'optional LDAP filter to set password onzLDAP-SEARCH-FILTERrø   r�  rŽ  r€  r�  r�  Fr‘  r’  z--scriptz.Script that is called for each password changez/path/to/syncpasswords.scriptÚscriptz	--no-waitzDon't block waiting for changesÚnowaitz	--logfilez/The logfile to use (required in --daemon mode).z/path/to/syncpasswords.logÚlogfilez--daemonzdaemonize after initial setupÚdaemonz--terminatez5Send a SIGTERM to an already running (daemon) processÚ	terminatec           
      ó*  ‡ ‡‡‡‡‡"‡#‡$‡%‡&‡'‡(‡)‡*‡+‡,‡-‡.— |j                  «       ‰ _        d ‰ _        d ‰ _        d ‰ _        d ‰ _        ‰sA|�t        d«      ‚‰rt        d«      ‚|�t        d«      ‚|�t        d«      ‚‰�Et        d«      ‚|durt        d«      ‚|	�t        d«      ‚|
durt        d	«      ‚|durt        d
«      ‚|du r|
du rt        d«      ‚|durt        d«      ‚|du r|
du rt        d«      ‚|
du r|	€t        d«      ‚|du r|	€t        d«      ‚|�Pt        j                  j                  |«      st        d|z  «      ‚dt        j                  j                  |«      z  Š,nd Š,|Š$‰$€,ddt        j                  t        j                  fz  z   dz   dz   Š$g d¢Š&‰&g d¢z   Š#d Š*‰r¢‰€;dt        j                  j                  ‰ j                  j                  d«      «      z  Š‰rt         st        t"        «      ‚‰ j%                  |«      Š*‰*D �cg c]  }|j'                  «       ‘Œ }}dD ]  }|j'                  «       |vsŒ‰*|gz  Š*Œ ‰�Ù‰j'                  «       j)                  d«      rt        d«      ‚‰j'                  «       j)                  d«      rt        d«      ‚‰j'                  «       j)                  d «      rt        d!«      ‚‰j'                  «       j)                  d"«      rnVt        j                  j                  ‰«      s7‰ j                  j                  ‰«      Šn‰ j                  j                  d#«      Šd$‰z  ‰ _        ˆ)ˆ fd%„Š)ˆˆˆˆˆ#ˆ$ˆ)ˆ*ˆ ˆ,f
d&„Š(ˆ)ˆ fd'„Š+ˆ&ˆ)ˆ+ˆ fd(„Š'ˆ)ˆ fd)„}ˆ)ˆ fd*„}ˆ fd+„Š-ˆ fd,„Š"ˆ fd-„Š.ˆ"ˆ'ˆ)ˆ ˆ-ˆ.fd.„Š%ˆ%ˆ)ˆ fd/„}ˆ(ˆ)ˆ fd0„}‰r1‰‰ _        ‰ j-                  ‰ j                  d¬1«      ‰ _         ‰(«        y |	��.d2d l}|j1                  |j2                  «      d3   }||j4                  k(  rd4}t        j6                  |	t        j8                  t        j:                  z  t        j<                  z  d5«      }‰ j>                  jA                  d6|	z  «       tC        d2|«      D ]  }||k(  rŒ		 t        jD                  |«       Œ  t        jH                  |d2«       t        jH                  |d3«       t        jH                  |d7«       t        jD                  |«        ‰)d8|	z  «       |	‰ _         ‰(«         ||«      }|ry‰ jJ                  €	 ‰)d9«       y |s ‰)d:‰ jJ                  z  «        |d «       y  ‰)d;‰ jJ                  z  «       t        jL                  ‰ jJ                  tN        jP                  «       y |r,t        d<t        jR                  «       ‰ jJ                  fz  «      ‚|
du r |«         |t        jR                  «       «       d}|du ržd3}d=}|du rd}d2}n|}‰ j                  €u|d2k7  r  ‰)d>|z  «       tU        jV                  |«       |d7z  }||k\  r|} ‰)d?‰ j                  z  «       	 ‰ j-                  ‰ j                  ¬@«      ‰ _        ‰ j                  €Œu	  ||«       |du rŒž |d «       y c c}w # tF        $ r Y �Œ%w xY w# tX        $ r!}d ‰ _         ‰)dA|z  «       |dur‚ Y d }~Œ^d }~ww xY w# t        jZ                  $ r-}|j\                  \  } }!d ‰ _         ‰)dB| |!fz  «       Y d }~Œ‹d }~ww xY w)CNzA--attributes is only allowed together with --cache-ldb-initializezH--decrypt-samba-gpg is only allowed together with --cache-ldb-initializez=--script is only allowed together with --cache-ldb-initializez=--filter is only allowed together with --cache-ldb-initializez=-H/--URL is only allowed together with --cache-ldb-initializeFz=--no-wait is not allowed together with --cache-ldb-initializez=--logfile is not allowed together with --cache-ldb-initializez<--daemon is not allowed together with --cache-ldb-initializez?--terminate is not allowed together with --cache-ldb-initializeTz/--daemon is not allowed together with --no-waitz2--terminate is not allowed together with --no-waitz1--terminate is not allowed together with --daemonz0--daemon is only allowed together with --logfilez3--terminate is only allowed together with --logfilezscript[%s] does not exist!rB  z(&(objectClass=user)z(userAccountControl:%s:=%u)z(!(sAMAccountName=krbtgt*))ú))rÇ  ÚdBCSPwdrÆ  )Ú
pwdLastSetrL  rÅ  ÚuserAccountControlÚ	isDeletedÚ
isRecycledz
ldapi://%szldap_priv/ldapi)Ú
objectGUIDr¨  r©  r•  z%--cache_ldb ldapi:// is not supportedr–  z$--cache_ldb ldap:// is not supportedr—  z%--cache_ldb ldaps:// is not supportedztdb://zuser-syncpasswords-cache.ldbz%s.pidc                 ó�  •— ‰j                   �òt        j                  d«      }|j                  dk(  rÎ‰j                   }d ‰_          ‰d|z  «       t        j                  |t        j
                  t        j                  z  t        j                  z  d«      }t        j                  |d«       t        j                  |d«       t        j                  |d«       t        j                  |«        ‰d|z  «       |‰_         dt        j                  «       t        j                  «       | fz  } ‰j                  j                  | «       y )Nr   z$Closing logfile[%s] (st_nlink == 0)
é€  r   rŽ   zReopened logfile[%s]
z%s: pid[%d]: %s)r   rE   ÚfstatÚst_nlinkÚopenÚO_WRONLYÚO_APPENDÚO_CREATÚdup2ÚcloseÚtimeÚctimeÚgetpidr±   r²   )r  Úinfor   ÚlogfdÚlog_msgrº   s       €€r*   rº  z+cmd_user_syncpasswords.run.<locals>.log_msgï  sð   ø€ Ø�|‰|Ð'Ü—x‘x “{�Ø—=‘= AÒ%Ø"Ÿl™l�GØ#'�D”LÙÐCÀwÑOÔPÜŸG™G G¬R¯[©[¼2¿;¹;Ñ-FÌÏÉÑ-SÐUZÓ[�EÜ—G‘G˜E 1Ô%Ü—G‘G˜E 1Ô%Ü—G‘G˜E 1Ô%Ü—H‘H˜U”OÙÐ4¸Ñ@ÔAØ#*�D”LØ#Ü—J‘J“LÜ—I‘I“KØð'ñ ˆCð �I‰I�O‰O˜CÔ Ør,   c                  óÆ  •
— g d¢} t        ‰«      ‰_        t        j                  ‰j                  d«      ‰_        ‰j                  j                  ‰j                  t        j                  | ¬«      }t        |«      dk(  r	 t        |d   d   d   «      ‰_	        nd ‰_	        ‰j                  €‰st        d‰z  «      ‚‰j                  �‰rt        d‰z  «      ‚‰j                  �€1‰
‰_	        ‰‰_        ‰‰_        d	d
g‰_        ‰‰_        ‰‰_        ‰‰_        d‰j                  z  dz   dt%        j&                  t)        ‰j                  «      «      j+                  d«      z  z   dt%        j&                  t)        ‰j                  «      «      j+                  d«      z  z   dj-                  d„ ‰j                  D «       «      z   d‰j                  d   z  z   dj-                  d„ ‰j                  D «       «      z   }‰j                   r|dz  }n|dz  }‰j"                  �|d‰j"                  z  z  }|dt        j.                  t1        t3        j2                  «       «      «      z  z  }‰j                  j5                  |«       d ‰_        ‰j8                  j;                  d‰z  «       ‰j                  j=                  |«      }t?        |«      \  }}‰j                  jA                  |t        jB                  «      }‰j8                  j;                  d|z  «       y t        |d   d   d   «      ‰_        g ‰_        |d   d   D ]&  }‰j                  jE                  t        |«      «       Œ( t        |d   d   d   «      d
g‰_        g ‰_        |d   d   D ]&  }‰j                  jE                  t        |«      «       Œ( t        |d   d   d   «      }	|	dv sJ ‚|	d k(  rd!‰_        nd"‰_        d#|d   v rt        |d   d#   d   «      ‰_        nd ‰_        d$|d   v rt1        |d   d$   d   «      ‰_        nd ‰_         ‰d%‰z  «       y # t        $ r}d ‰_	        Y d }~�Œºd }~ww xY w)&N)ÚsamdbUrlÚdirsyncFilterÚdirsyncAttributeÚdirsyncControlÚpasswordAttributeÚdecryptSambaGPGÚsyncCommandÚ
currentPidzKEY=USERSYNCPASSWORDSrš  r   r   r¼  zHcache_ldb[%s] not initialized, use --cache-ldb-initialize the first timezEcache_ldb[%s] already initialized, --cache-ldb-initialize not allowedzdirsync:1:0:0úextended_dn:1:0údn: %s
zobjectClass: userSyncPasswords
zsamdbUrl:: %s
rB   zdirsyncFilter:: %s
rC   c              3   ó|   K  — | ]4  }d t        j                  t        |«      «      j                  d«      z  –— Œ6 y­w)zdirsyncAttribute:: %s
rB   N©rG   rH   r   rJ   ©Ú.0r’  s     r*   ú	<genexpr>zAcmd_user_syncpasswords.run.<locals>.load_cache.<locals>.<genexpr>-	  s;   è ø€ ò  #JÐqrÐ#<¼v×?OÑ?OÔPYÐZ[ÓP\Ó?]×?dÑ?dÐekÓ?lÕ#lñ  #Jùó   ‚:<údirsyncControl: %s
c              3   ó|   K  — | ]4  }d t        j                  t        |«      «      j                  d«      z  –— Œ6 y­w)zpasswordAttribute:: %s
rB   NrÇ  rÈ  s     r*   rÊ  zAcmd_user_syncpasswords.run.<locals>.load_cache.<locals>.<genexpr>/	  s;   è ø€ ò  #LÐrsÐ#=Ä×@PÑ@PÔQZÐ[\ÓQ]Ó@^×@eÑ@eÐflÓ@mÕ#mñ  #LùrË  zdecryptSambaGPG: TRUE
zdecryptSambaGPG: FALSE
úsyncCommand: %s
úcurrentTime: %s
zInitialized cache_ldb[%s]
rB  r½  r¾  r¿  rÀ  rÁ  )ÚTRUEÚFALSErÐ  TFrÂ  rÃ  zUsing cache_ldb[%s]
)#r   Úcacherñ   rg  Úcache_dnró   rP  rM   rÚ   Ú	samdb_urlÚKeyErrorr   Údirsync_filterÚdirsync_attrsÚdirsync_controlsr�  r‘  Úsync_commandrG   rH   r   rJ   ÚjoinrC  rÛ   rµ  Úadd_ldifÚcurrent_pidr±   r²   Ú
parse_ldifrP  r•  r–  ri  )Úcache_attrsrù   rÓ   rÛ  ÚmsgsÚ
changetyper  r—  r’  Údecrypt_stringrd   r�  rœ  r‘  r×  rÖ  rº  r�  rº   rÙ  s             €€€€€€€€€€r*   Ú
load_cachez.cmd_user_syncpasswords.run.<locals>.load_cache	  sx  ø€ ò	ˆKô ˜Y›ˆDŒJÜŸF™F 4§:¡:Ð/FÓGˆDŒMØ—*‘*×#Ñ#¨¯©¼c¿n¹nØ*5ð $ó 7ˆCä�3‹x˜1Š}ð*Ü%(¨¨Q©°
Ñ);¸AÑ)>Ó%?�D•Nð "&�”Ø�~‰~Ð%Ñ.BÜ"Ð#mØ#,ñ$.ó /ð /à�~‰~Ð)Ñ.BÜ"Ð#jØ#,ñ$.ó /ð /à�~‰~Ñ%Ø!"�”Ø&4�Ô#Ø%2�Ô"Ø)8Ð:KÐ(L�Ô%Ø&4�Ô#Ø):�Ô&Ø$0�Ô!Ø%¨¯©Ñ5Ø=ñ>à,¬v×/?Ñ/?Ä	È$Ï.É.Ó@YÓ/Z×/aÑ/aÐbhÓ/iÑiñjð 2´F×4DÑ4DÄYÈt×ObÑObÓEcÓ4d×4kÑ4kÐlrÓ4sÑsñtð Ÿ7™7ñ  #JÐvz÷  wIñ  wIô  #Jó  Jñ	Jð
 2°D×4IÑ4IÈ!Ñ4LÑLñMð Ÿ7™7ñ  #LÐw{÷  xKñ  xKô  #Ló  LñL�ð ×)Ò)ØÐ 9Ñ9‘HàÐ :Ñ:�HØ×$Ñ$Ð0ØÐ 3°d×6GÑ6GÑ GÑG�HØÐ/´#·.±.ÄÄTÇYÁYÃ[ÓAQÓ2RÑRÑR�Ø—
‘
×#Ñ# HÔ-Ø#'�Ô Ø—	‘	—‘Ð =ÀÑ KÔLØ—z‘z×,Ñ,¨XÓ6�Ü"& t£*‘�
˜CØ—z‘z×,Ñ,¨S´#×2EÑ2EÓF�Ø—	‘	—‘  t¡Ô,ð4 ô1 '*¨#¨a©&°Ñ*AÀ!Ñ*DÓ&E�Ô#Ø%'�Ô"Ø˜Q™Ð 2Ñ3ò 6�AØ×&Ñ&×-Ñ-¬c°!«fÕ5ð6ä),¨S°©VÐ4DÑ-EÀaÑ-HÓ)IÐK\Ð(]�Ô%Ø&(�Ô#Ø˜Q™Ð 3Ñ4ò 7�AØ×'Ñ'×.Ñ.¬s°1«vÕ6ð7ä!$ S¨¡VÐ,=Ñ%>¸qÑ%AÓ!B�Ø%Ð):Ñ:Ð;Ð:Ø! VÒ+Ø-1�DÕ*à-2�DÔ*Ø  C¨¡FÑ*Ü(+¨C°©F°=Ñ,AÀ!Ñ,DÓ(E�DÕ%à(,�DÔ%Ø 3 q¡6Ñ)Ü'*¨3¨q©6°,Ñ+?ÀÑ+BÓ'C�DÕ$à'+�DÔ$ÙÐ/°9Ñ=Ô>àøôA  ò *Ø%)�D—N’Nûð*ús   Â Q Ñ	Q ÑQÑQ c                 óî  •—  ‰d‰j                   ›d| ›d�«       t        ‰j                   t        t        t        ¬«      }|j	                  «       }|�J ‚d|z  }|j                  |j                  d«      «      d   j                  d«      } ‰d|z  «       |j	                  «       }|€|j                  «        |j                  «       }|j                  d	«      ry  ‰d
|z  «       t        d|›d|›d�«      ‚)NzCall Popen[z] for rä  )ÚstdinÚstdoutÚstderrrB  ræ  r   r  zDONE-EXIT: zRESULT: %s
úERROR: z - )rÙ  r   r   r   ÚpollÚcommunicaterè  rJ   r¢  Úwaitrž  r¹   )rê   r—  Úsync_command_prù   ÚinputÚreplyrº  rº   s         €€r*   Úrun_sync_commandz4cmd_user_syncpasswords.run.<locals>.run_sync_commandY	  sì   ø€ Ú°×1BÓ1BÂBÐGÔHÜ" 4×#4Ñ#4Ü)-Ü*.Ü*0ô2ˆNð
 !×%Ñ%Ó'ˆCØ�;Ð�;à˜D‘MˆEØ"×.Ñ.Ø—‘˜WÓ%ó'Ø'(ñ*ß*0©&°«/ð á�F˜eÑ$Ô%Ø ×%Ñ%Ó'ˆCØˆ{Ø×(Ñ(Ô*Ø ×%Ñ%Ó'ˆCà×Ñ Ô.Øá�N cÑ*Ô+Ý²#²uÐ=Ó>Ð>r,   c           	      ó@  •— |j                   j                  d«      }t        t        j                  |«      }|j                   j                  d«      }t        t
        j                  |«      }|j                  «       \  }}|t
        j                  k(  r ‰d| z  «       y t        |j                  «       «      D ]7  }‰D ]0  }	|j                  «       |	j                  «       k(  sŒ%||= dg|d|z  <   Œ2 Œ9 ‰j                  j                  |t        j                  «      }
 ‰d| |||
fz  «       ‰j!                  ‰j                  d|z  d|z  d	t        j"                  ‰j$                  ‰j&                  ¬
«      }‰j                  j                  |t        j                  «      } ‰d| ||fz  «       ‰j(                  €‰j*                  j-                  d|z  «       y ‰j*                  j-                  dt/        |j                  «       «      z  «        ‰|j                   |«       y )NÚGUIDre  z'# Dirsync[%d] SKIP: DOMAIN_RID_KRBTGT

zREDACTED SECRET ATTRIBUTEz# %s::z# Dirsync[%d] %s %s
%srB  z	<GUID=%s>z(objectClass=user))r�   r\  rø   rí   rï   r%   z# Passwords[%d] %s %s
z# attrs=%s
)rê   rh  r   r   rð  r   rN  rO  ÚDOMAIN_RID_KRBTGTÚlistrŽ  r�  rÒ   r•  rñ   r–  ry  rP  r�  r‘  rÙ  r±   r²   rŒ  )r
  Údirsync_objÚbinary_guidÚguidÚ
binary_sidr£  Ú
domain_sidÚridr’  r+  Údirsync_ldifr6  r—  Údirsync_secret_attrsrº  rî  rº   s                €€€€r*   Úhandle_objectz1cmd_user_syncpasswords.run.<locals>.handle_objectr	  s×  ø€ Ø%Ÿ.™.×?Ñ?ÀÓGˆKÜœdŸi™i¨Ó5ˆDØ$Ÿ™×>Ñ>¸uÓEˆJÜœX×-Ñ-¨zÓ:ˆCØ!Ÿi™i›k‰OˆJ˜Ø”h×0Ñ0Ò0ÙÐCÀsÑKÔLØÜ˜+×*Ñ*Ó,Ó-ò R�Ø-ò R�AØ—w‘w“y A§G¡G£IÓ-Ø'¨˜NØ5PÐ4Q˜ H¨q¡LÒ1ñRðRð
  Ÿ:™:×0Ñ0°¼c×>QÑ>QÓRˆLÙÐ-°°d¸CÀÐ0NÑNÔOØ×-Ñ-¨d¯j©jØ7;¸c±zØ5@À4Ñ5GØ5IÜ47·N±NØ48×4GÑ4GØ6:×6LÑ6Lð .ó NˆCð —:‘:×(Ñ(¨¬c×.AÑ.AÓBˆDÙÐ-°°d¸CÐ0@Ñ@ÔAØ× Ñ Ð(Ø—	‘	—‘ ¨¡Ô.ØØ�I‰I�O‰O˜N¬f°S·X±X³ZÓ.@ÑAÔBÙ˜SŸV™V TÕ*r,   c                 ó4  •— t         j                  }| s|t         j                  z  }	 t        j                  ‰j                  |d«      ‰_        d}	 t        j                  ‰j
                  t        j                  t        j                  z  «       d}|sEt        j                   ‰j
                  d«      }d ‰_        	 t%        |«      ‰_        ‰j"                  �y|rJ| rH	 t        j(                  ‰j
                  d«       t        j*                  ‰j
                  «       d	‰_        y	 t        j                  ‰j
                  t        j,                  «       y# t        $ rG}|j                  \  }}|t        j                  k(  r| rY d }~y ‰d‰j                  ||fz  «       ‚ d }~ww xY w# t        $ rY}|j                  \  }}|t        j                  k7  r,|t        j                  k7  r ‰d‰j                  ||fz  «       ‚ Y d }~�Œsd }~ww xY w# t&        $ r}Y d }~�ŒPd }~ww xY w# t        $ r-}	|	j                  \  }} ‰d‰j                  ||fz  «       ‚ d }	~	ww xY w# t        $ r1}
|
j                  \  }} ‰d
‰j                  ||fz  «       Y d }
~
yd }
~
ww xY w)Nr¬  Fz8check_current_pid_conflict: failed to open[%s] - %s (%d)TzFcheck_current_pid_conflict: failed to get exclusive lock[%s] - %s (%d)é@   r   z=check_current_pid_conflict: failed to truncate [%s] - %s (%d)rá  zCcheck_current_pid_conflict: failed to get shared lock[%s] - %s (%d))rE   ÚO_RDWRr²  r¯  ÚlockfileÚlockfdÚIOErrorÚargsrE  ÚENOENTÚfcntlÚlockfÚLOCK_EXÚLOCK_NBÚEACCESÚEAGAINÚreadrÜ  rÛ   r/  Ú	ftruncater´  ÚLOCK_SH)r¢  r5   Úe4Úerrr  Úgot_exclusiveÚe5ÚbufrÓ   Úe2Úe6rº  rº   s              €€r*   Úcheck_current_pid_conflictz>cmd_user_syncpasswords.run.<locals>.check_current_pid_conflict‘	  sH  ø€ Ü—I‘IˆEÙØœŸ™Ñ#�ð	Ü Ÿg™g d§m¡m°U¸EÓB�”ð "ˆMðÜ—‘˜DŸK™K¬¯©¼¿¹Ñ)FÔGØ $�ñ !Ü—g‘g˜dŸk™k¨2Ó.�Ø#'�Ô ðÜ'*¨3£x�DÔ$ð ×#Ñ#Ð/Øá¡ðÜ—L‘L §¡¨aÔ0ô —‘˜Ÿ™Ô%Ø �”Øð3Ü—‘˜DŸK™K¬¯©Ô7ð øôe ò ØŸW™W‘
��cØœ%Ÿ,™,Ò&Ù Ü$ÙÐRØŸ™¨¨SÐ1ñ2ô 3àûðûô ò ØŸW™W‘
��cØœ%Ÿ,™,Ò&¨3´%·,±,Ò+>ÙÐdØ!Ÿ]™]¨C°Ð5ñ6ô 7àÿùðûô "ò Ýûðûô ò Ø!#§¡‘J�S˜#ÙÐ[Ø!Ÿ]™]¨C°Ð5ñ6ô 7àûð	ûô ò 3ØŸW™W‘
��cÙÐ]ØŸ™¨¨SÐ1ñ2÷ 3ð 3ð ûð3úsy   ¨&E ÁAF( Â<H Ã H$ Ä&.I Å	F%Å$F ÆF Æ F%Æ(	H
Æ1AHÈH
È	H!ÈH!È$	IÈ-(IÉIÉ	JÉ&'JÊJc           	      ó¶  •— ‰
j                   dk7  rûd}t        dd«      D ]]  }	 t        j                  ‰
j                   t        j                  t        j
                  z  «       d}|r nt        j                  d«       Œ_ |s5 ‰	d| ›d	‰
j                  ›d
�«       t        d| ›d	‰
j                  ›d�«      ‚| �d| z  }nd }	 t        j                   ‰
j                   d«       |�)t        j"                  ‰
j                   t%        |«      «       | ‰
_        ‰
j&                  � ‰	d‰
j&                  z  «       d‰
j(                  z  dz   dz   }‰
j&                  �|d‰
j&                  z  z  }|ddt+        j,                  t/        t        j                  «       «      «      z  z   z  }‰
j0                  j3                  |«       y # t        $ rZ}|j                  \  }}|t        j                  k7  r-|t        j                  k7  r ‰	d| ‰
j                  ||fz  «       ‚ Y d }~�Œ¶d }~ww xY w# t        $ r-}|j                  \  }} ‰	d‰
j                  ||fz  «       ‚ d }~ww xY w)Nrá  Fr   rï  Tz:update_pid(%r): failed to get exclusive lock[%s] - %s (%d)r   zupdate_pid(z ): failed to get exclusive lock[ú]z] after 5 secondsz%d
zAcheck_current_pid_conflict: failed to write pid to [%s] - %s (%d)zcurrentPid: %d
rÅ  úchangetype: modify
zreplace: currentPid
úreplace: currentTime
rÏ  )r   Úranger  r  r  r  r  r  rE  r  r	  rÿ  rµ  Úsleepr   rE   r  r²   r   rÜ  rÓ  rñ   rC  rÛ   rÒ  rj  )Úpidr  r  rÓ   r  r  r  Úe3rj  rº  rº   s            €€r*   Ú
update_pidz.cmd_user_syncpasswords.run.<locals>.update_pidÌ	  s/  ø€ Ø�{‰{˜bÒ Ø %�ä˜q !›ò "�Að"ÜŸ™ D§K¡K´·±ÄÇÁÑ1NÔOØ(,˜ñ %ÙÜ—J‘J˜q•Mð"ñ %ÚÚ  $§-£-ð1ô 2å&â(+¨T¯]«]ð(<ó =ð =ð �?Ø  3™,‘Cà�CðÜ—L‘L §¡¨aÔ0Ø�ÜŸ™ §¡¬i¸«nÔ=ð  #ˆDÔØ×ÑÐ+ÙÐ*¨T×-=Ñ-=Ñ=Ô>à$¨¯©Ñ6Ø0ñ1à1ñ2ˆKð ×ÑÐ+ØÐ1°T×5EÑ5EÑFÑF�ØÐ3Ø.´·±ÄÄDÇIÁIÃKÓ@PÓ1QÑQñRñ RˆKà�J‰J×"Ñ" ;Ô/ØøôS #ò "Ø%&§V¡V™
˜˜cØ¤%§,¡,Ò.°3¼%¿,¹,Ò3FÙ#Ð$`Ø%(¨$¯-©-¸¸cÐ$Bñ%Cô Dà!ÿùð"ûô0 ò Ø!#§¡‘J�S˜#ÙÐ_Ø!Ÿ]™]¨C°Ð5ñ6ô 7àûð	ús2   £AF<ÃAH" Æ<	HÇAHÈHÈ"	IÈ+(IÉIc                 ó€  •— t        | «      dkD  sJ ‚| d   j                  dk(  sJ ‚d| d   _        t        | d   «      dg‰_        d‰j
                  z  dz   dz   d‰j                  d   z  z   d	z   d
t        j                  t        t        j                  «       «      «      z  z   }‰j                  j                  |«       y )Nr   ú1.2.840.113556.1.4.841TrÄ  rÅ  r  zreplace: dirsyncControl
rÌ  r  rÏ  )rM   ÚoidÚcriticalrÚ   rØ  rÓ  rñ   rC  rÛ   rµ  rÒ  rj  )Úres_controlsrj  rº   s     €r*   Úupdate_cachez0cmd_user_syncpasswords.run.<locals>.update_cacheÿ	  sÒ   ø€ Ü�|Ó$ qÒ(Ð(Ð(Ø ‘?×&Ñ&Ð*BÒBÐBÐBØ'+ˆL˜‰OÔ$Ü%(¨°a©Ó%9Ð;LÐ$MˆDÔ!ð %¨¯©Ñ6Ø0ñ1à5ñ6ð 1°D×4IÑ4IÈ!Ñ4LÑMñNð 3ñ	3ð
 .´·±¼sÄ4Ç9Á9Ã;Ó?OÓ0PÑPñQˆKð �J‰J×"Ñ" ;Ô/Ør,   c                 ó‚  •— t        |«      dkD  sJ ‚|d   j                  dk(  sJ ‚| j                  j                  d«      }t	        t
        j                  |«      }d|z  }t        |d   «      }‰j                  j                  |t        j                  dt        j                  |«      z  g ¬«      }t        |«      dk(  ryy	)
Nr   r  re  úKEY=%sz(lastCookie=%s)rë   r   TF)rM   r   rê   rh  r   r   rN  rÚ   rÒ  ró   rñ   rP  rò   )ró  r"  rö  r£  rê   Ú
lastCookierù   rº   s          €r*   Úcheck_objectz0cmd_user_syncpasswords.run.<locals>.check_object
  sº   ø€ Ü�|Ó$ qÒ(Ð(Ð(Ø ‘?×&Ñ&Ð*BÒBÐBÐBà$Ÿ™×>Ñ>¸uÓEˆJÜœX×-Ñ-¨zÓ:ˆCØ˜C‘ˆBÜ˜\¨!™_Ó-ˆJà—*‘*×#Ñ#¨´3·>±>Ø/@Ü(+×(9Ñ(9¸*Ó(Eñ0Gà*,ð $ó .ˆCô �3‹x˜1Š}ØØr,   c                 ó¢  •— t        |«      dkD  sJ ‚|d   j                  dk(  sJ ‚| j                  j                  d«      }t	        t
        j                  |«      }d|z  }t        |d   «      }‰
j                  j                  «        	 ‰
j                  j                  |t        j                  ddg¬«      }t        |«      dk(  r^d|z  d	z   d
|z  z   dt        j                  t        t        j                  «       «      «      z  z   }‰
j                  j!                  |«       ncd|z  dz   dz   d
|z  z   dz   dt        j                  t        t        j                  «       «      «      z  z   }‰
j                  j#                  |«       ‰
j                  j%                  «        y # t&        $ r$}	‰
j                  j)                  «        Y d }	~	y d }	~	ww xY w)Nr   r  re  r%  z(objectClass=*)r&  rë   rÅ  zobjectClass: userCookie
zlastCookie: %s
rÏ  r  zreplace: lastCookie
r  )rM   r   rê   rh  r   r   rN  rÚ   rÒ  Útransaction_startró   rñ   rP  rC  rÛ   rµ  rÛ  rj  Útransaction_commitr¹   Útransaction_cancel)ró  r"  rö  r£  rê   r&  rù   rÛ  rj  rÓ   rº   s             €r*   Úupdate_objectz1cmd_user_syncpasswords.run.<locals>.update_object!
  s¸  ø€ Ü�|Ó$ qÒ(Ð(Ð(Ø ‘?×&Ñ&Ð*BÒBÐBÐBà$Ÿ™×>Ñ>¸uÓEˆJÜœX×-Ñ-¨zÓ:ˆCØ˜C‘ˆBÜ˜\¨!™_Ó-ˆJà�J‰J×(Ñ(Ô*ð0Ø—j‘j×'Ñ'¨R´s·~±~Ø3DØ/;¨nð (ó >�ô �s“8˜q’=Ø *¨bÑ 1Ø ;ñ!<à 2°jÑ Añ!Bð !4´c·n±nÄSÌÏÉËÓEUÓ6VÑ Vñ!W�Hð —J‘J×'Ñ'¨Õ1à",°Ñ"3Ø"8ñ#9à"9ñ#:ð #5¸
Ñ"Cñ#Dð #;ñ	#;ð
 #6¼¿¹ÄsÌ4Ï9É9Ë;ÓGWÓ8XÑ"Xñ#Y�Kð —J‘J×*Ñ*¨;Ô7Ø—
‘
×-Ñ-Ô/ð øô ò 0Ø—
‘
×-Ñ-×/Ð/àûð0ús   Â	DF! Æ!	GÆ*G	Ç	Gc                  ó˜  •— 	 ‰j                   j                  t        ‰j                  «      t        j
                  ‰j                  ‰j                  ¬«      }  ‰dt        | «      z  «       d}| D ]8  } ‰|| j                  «      }|s ‰||«        ‰	|| j                  «       |dz  }Œ:  ‰| j                  «       t        | «      dk(  ry ŒÉ)N)rî   rí   rï   rd  zdirsync_loop(): results %d
r   r   )
rÒ   ró   rÚ   rÖ  rñ   rõ   r×  rØ  rM   rd  )
rù   Úrir„  Údoner'  rû  rº  rº   r#  r,  s
       €€€€€€r*   Údirsync_loopz0cmd_user_syncpasswords.run.<locals>.dirsync_loopC
  sÅ   ø€ ØØ—j‘j×'Ñ'´3°t×7JÑ7JÓ3KÜ.1×.?Ñ.?Ø.2×.@Ñ.@Ø15×1FÑ1Fð (ó H�ñ Ð6¼¸S»ÑAÔBØ�Øò �AÙ'¨¨3¯<©<Ó8�DÙÙ% b¨!Ô,Ù% a¨¯©Ô6Ø˜!‘G‘Bðñ ˜SŸ\™\Ô*Ü�s“8˜q’=Øð r,   c           
      óÚ  •— g d¢}ddg}‰
j                   j                  dt        j                  ||d¬«      }| du r	 ‰	d«       n ‰	d	«       ‰
j                  j                  d
‰
j                  z  «       ‰
j                  j                  d‰
j                  z  «       ‰
j                  j                  d‰
j                  z  «        ‰«        | dury |D ]†  }t        |t        j                  «      s‰
j                  j                  d|z  «       Œ<|j                  d«      d   }|j                  d«      d   } ‰	d|j                  ›d|›d|›d�«        ‰«        Œˆ |j                  «       }y )N)rª  Ú
uSNCreatedÚ
uSNChangedÚobjectClassznotification:1rÈ  zobjectClass=*rá  )rî   rí   rï   rd  ÚtimeoutTzResuming monitoring
zGetting changes
zdirsyncFilter: %s
zdirsyncControls: %r
rÎ  zreferral: %s
r2  r   r3  z	# Notify z uSNCreated[z] uSNChanged[z]
)rÒ   Úsearch_iteratorrñ   rõ   r±   r²   rÖ  rØ  rÙ  r<  ÚMessager·   rê   Úresult)rê  Únotify_attrsÚnotify_controlsÚnotify_handler  ÚcreatedÚchangedrù   r0  rº  rº   s           €€€r*   Ú	sync_loopz-cmd_user_syncpasswords.run.<locals>.sync_loopU
  sK  ø€ ÚNˆLØ/Ð1BÐCˆOØ ŸJ™J×6Ñ6À/Ü=@×=NÑ=NØ=IØ@OØ?Að	 7ó CˆMð �t‰|ÙÐ/Õ0áÐ+Ô,Ø�I‰I�O‰OÐ1°D×4GÑ4GÑGÔHØ�I‰I�O‰OÐ3°d×6KÑ6KÑKÔLØ�I‰I�O‰OÐ/°$×2CÑ2CÑCÔDÙŒNà˜4ÑØà$ò 	�Ü! #¤s§{¡{Ô3Ø—I‘I—O‘OÐ$4°sÑ$:Ô;ØØŸ'™' ,Ó/°Ñ2�ØŸ'™' ,Ó/°Ñ2�ÚØŸ›¢ª'ð3ô 4ñ •ð	ð  ×&Ñ&Ó(‰Cr,   c                  óR  •— d ‰_         d ‰_        t        j                  «       } t        j                  «       }|dk(  rVt        j
                  «        t        j                  «       }|dk(  r)t        j                  «       } ‰d|| fz  «        ‰«        y t        j                  d«       y )Nr   zDaemonized as pid %d (from %d)
)rÒ   rÒ  rE   r·  ÚforkÚsetsidÚ_exit)Úorig_pidr  râ  rº  rº   s     €€€r*   Ú	daemonizez-cmd_user_syncpasswords.run.<locals>.daemonizew
  sy   ø€ ØˆDŒJØˆDŒJÜ—y‘y“{ˆHÜ—'‘'“)ˆCØ�aŠxÜ—	‘	”Ü—g‘g“i�Ø˜!’8ÜŸ)™)›+�CÙÐ>À#ÀxÀÑPÔQÙ”LØÜ�H‰H�Q�Kr,   )r”   r¡  r   r   i   r¬  zUsing logfile[%s]
rŽ   zAttached to logfile[%s]
zNo process running.
z#Process %d is not running anymore.
zSending SIGTERM to process %d.
z4Exiting pid %d, command is already running as pid %diX  z Wait before connect - sleep(%d)
r˜  )r”   z#Connect to samdb Exception => (%s)
zldb.LdbError(%d) => (%s)
)/rµ   r–   r   rÔ  rÒ   rÒ  r   rE   ÚpathÚexistsÚabspathrñ   r  r   r  Úprivate_pathrR  r”  r†  r�  rž  rÿ  r¤  ÚresourceÚ	getrlimitÚRLIMIT_NOFILEÚRLIM_INFINITYr¯  r°  r±  r²  r±   r²   r  r´  rD  r³  rÜ  ÚkillÚsignalÚSIGTERMr·  rµ  r  r¹   ÚLdbErrorr  )/rº   rœ  r�  rd   rø   r€  r‘  rž  rŸ  r   r¡  r¢  rƒ   r…   rr  Úlower_attrsr’  r  r  r>  rD  rI  Úmaxfdr¹  ÚfdÚconflictrê  Úretry_sleep_minÚretry_sleep_maxÚretry_sleepr  Úe7ÚenumÚestrr'  r×  rÖ  r0  rú  rû  râ  rº  r�  rî  rÙ  r#  r,  s/   ````  `                           @@@@@@@@@@@@@r*   rÔ   zcmd_user_syncpasswords.run~  sý  ÿÿù€ ð ×(Ñ(Ó*ˆŒØˆŒØˆŒØˆŒ
ØˆŒ
á#ØÐ%Ü"Ð#fÓgÐgÙ Ü"Ð#mÓnÐnØÐ!Ü"Ð#bÓcÐcØÐ!Ü"Ð#bÓcÐcØˆ}Ü"Ð#bÓcÐcà˜UÑ"Ü"Ð#bÓcÐcØÐ"Ü"Ð#bÓcÐcØ˜UÑ"Ü"Ð#aÓbÐbØ Ñ%Ü"Ð#dÓeÐeà�T‰>Ø˜‰~Ü"Ð#TÓUÐUØ Ñ%Ü"Ð#WÓXÐXà˜Ñ ¨4¡ÜÐRÓSÐSà�T‰>˜g˜oÜÐQÓRÐRà˜Ñ  ÜÐTÓUÐUàÐÜ—7‘7—>‘> &Ô)Ü"Ð#?À&Ñ#HÓIÐIà¤"§'¡'§/¡/°&Ó"9Ñ9‰LàˆLàˆØÐ!ð4à<Ü#&×#9Ñ#9¼4×;QÑ;Qð@Sñ  SñSð  =ñ	=ð
 !ñ!ˆNò 
Ðð -ò 0
ñ 
ˆð ˆáØˆyØ ¤2§7¡7§?¡?°4·7±7×3GÑ3GÐHYÓ3ZÓ#[Ñ[�á ­Ü"Ô#9Ó:Ð:à!×2Ñ2°:Ó>ˆNØ.<Ö=¨˜1Ÿ7™7�9Ð=ˆKÐ=à>ò *�Ø—7‘7“9 KÒ/Ø" q cÑ)‘Nð*ð Ð Ø�‰Ó ×+Ñ+¨JÔ7Ü"Ð#JÓKÐKØ—‘Ó"×-Ñ-¨iÔ8Ü"Ð#IÓJÐJØ—‘Ó"×-Ñ-¨jÔ9Ü"Ð#JÓKÐKØ—‘Ó"×-Ñ-¨hÔ7Øä—w‘w—~‘~ iÔ0Ø $§¡× 4Ñ 4°YÓ ?‘IàŸ™×,Ñ,Ð-KÓLˆIà  9Ñ,ˆŒõ	÷*S	õ S	õj	?÷2	+õ>9	õv1	ôf	ô"	ô" 	÷D	ñ 	ö$ 	)öD	ñ  ØˆDŒNØ×2Ñ2°t·~±~Ø;?ð 3ó AˆDŒJáŒLØàÑÛØ×&Ñ& x×'=Ñ'=Ó>¸qÑAˆEØ˜×.Ñ.Ò.Ø�Ü—G‘G˜G¤R§[¡[´2·;±;Ñ%>ÄÇÁÑ%KÈUÓSˆEØ�I‰I�O‰OÐ1°GÑ;Ô<Ü˜A˜u“oò �Ø˜’;ØðÜ—H‘H˜R•Lð	ô �G‰G�E˜1ÔÜ�G‰G�E˜1ÔÜ�G‰G�E˜1ÔÜ�H‰H�UŒOÙÐ/°7Ñ;Ô<Ø"ˆDŒLáŒÙ-¨iÓ8ˆÙØ×ÑÐ'ÙÐ/Ô0ØÙÙÐ>Ø×(Ñ(ñ*ô +á˜4Ô ØÙÐ6Ø×$Ñ$ñ&ô 'ä�G‰G�D×$Ñ$¤f§n¡nÔ5ØÙÜÐUÜ!Ÿy™y›{¨D×,<Ñ,<ðY>ñ  >ó ?ð ?ð �T‰>ÙŒKÙ”2—9‘9“;ÔàˆØ�d‰lØˆOØ!ˆOØ˜‰~Ø�Ø‘à-�à—*‘*Ð$Ø !Ò#ÙÐ?À+ÑMÔNÜ—J‘J˜{Ô+Ø)¨A™o�Ø /Ò1Ø"1�KÙÐ.°·±Ñ?Ô@ðØ!%×!:Ñ!:¸t¿~¹~Ð!:Ó!N�D”Jð —*‘*Ñ$ð EÙ˜$”ð5 �dŠlñ@ 	�4ÔØùòG >øôB ò Úðûôh !ò Ø!%�D”JÙÐBÀSÑHÔIØ 4Ñ'Øô (ûðûô —<‘<ò EØ!Ÿw™w‘��tØ!�”
ÙÐ4¸¸d°|ÑC×DÑDûðEúsH   ÈZÒZÙ!Z% Ù:[ Ú	Z"Ú!Z"Ú%	[Ú.[
Û
[Û\Û%#\Ü\)FNNNNNNNNNNNN)rÕ   rÖ   r×   rØ   rˆ  rÙ   rÞ   rß   rá   râ   r   rÚ   r˜  r”  rÜ   rÔ   r‡  rˆ  s   @r*   rš  rš  ™  sD  ø„ ñ{ôx7ð :€Hð ×)Ñ)Ø×-Ñ-ñÐñ 	Ð'Ø=Ø*°<ô	Añ 	ˆ}Ð#RÐY\Ø'¨kô	;áˆt�WÐ#NÐUXØ 3ô	(áˆzÐ IÐPSØ+°(ô	<áˆ~ CØ+Ø&¨\ô	;ñ 	Ð$Ø*Ø"¨EÐ8Kô	Mñ 	ˆzÐ PÐWZØ6¸Xô	Gáˆ{Ð!BØ"¨E¸ô	Báˆ{ ØEØ3¸)ô	Eñ 	ˆzÐ ?Ø"¨E¸ô	Báˆ}ØKØ"¨E¸ô	Eð3€Mð< 9=ØØ/3ØKOØ(,÷	]	r,   rš  c                   ó    — e Zd ZdZdZ edddedd¬«       ed	d
e¬«      gZdgZe	j                  e	j                  e	j                  dœZ	 	 dd„Zy)Úcmd_user_editaÁ  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.

ræ   r`   ra   rb   rc   rd   re   z--editorzQEditor to use instead of the system default, or 'vi' if no system default is set.rs   r�   r‚   Nc                 óæ  — |j                  «       }|j                  |d¬«      }t        |t        «       ||¬«      }	dt        j
                  t        j                  |«      fz  }
|	j                  «       }	 |	j                  ||
t        j                  ¬«      }|d   j                  }dd l}|D ]È  }t        j                   |	|«      }|€#t"        j$                  j'                  d«      }|€d	}|j)                  d
¬«      5 }|j+                  t-        |«      «       |j/                  «        	 t1        ||j2                  g«       t7        |j2                  «      5 }|j9                  «       }d d d «       d d d «       ŒÊ |	j;                  «      }t=        |«      d   }|	j?                  |«      }tA        |«      dk(  r| jB                  j+                  d«       y 	 |	jE                  |«       | jB                  j+                  d|z  «       y # t        $ r t        d|z  «      ‚w xY w# t4        $ r}t5        d|«      ‚d }~ww xY w# 1 sw Y   Œ×xY w# 1 sw Y   �Œ¥xY w# tF        $ r}t        d|z  |«      ‚d }~ww xY w)NTrè   r“   ú)(&(sAMAccountType=%d)(sAMAccountName=%s))©rì   rî   rí   r   rð   ÚEDITORÚviz.tmp)Úsuffixrç  r   zNothing to do
zFailed to modify user '%s': z Modified User '%s' successfully
)$rµ   r¶   r
   r	   r   ÚATYPE_NORMAL_ACCOUNTrñ   rò   rô   ró   rõ   rê   rö   r   Útempfiler   Úget_ldif_for_editorrE   Úenvironr·   ÚNamedTemporaryFiler²   r   Úflushr   rª  r   r¯  r
  rÝ  rP  Úmsg_diffrM   r±   Úmodifyr¹   )rº   r�   r„   rƒ   r…   rd   Úeditorr–   rÑ   rÒ   rø   Údomaindnrù   rú   rd  r  Úresult_ldifÚt_filerÓ   Úedited_fileÚedited_messageÚmsgs_editedÚ
msg_editedÚres_msg_diffs                           r*   rÔ   zcmd_user_edit.run  sa  € à×#Ñ#Ó%ˆØ×(Ñ(¨¸dÐ(ÓCˆÜ˜!¬.Ó*:Ø"'¨Bô0ˆð >Ü×,Ñ,¬c×.?Ñ.?ÀÓ.IÐJñKˆð —?‘?Ó$ˆð	HØ—,‘, HØ*0Ü%(×%6Ñ%6ð ó 8ˆCð ˜!‘f—i‘iˆGó 	Øò 	8ˆCÜ ×4Ñ4°U¸CÓ@ˆKàˆ~ÜŸ™Ÿ™¨Ó1�Ø�>Ø!�Fà×,Ñ,°FÐ,Ó;ð 8¸vØ—‘œY {Ó3Ô4Ø—‘”ð;Ü ¨¯©Ð4Ô5ô ˜&Ÿ+™+Ó&ð 8¨+Ø%0×%5Ñ%5Ó%7�N÷8÷8ð 8ð	8ð& ×&Ñ& ~Ó6ˆÜ˜+Ó& qÑ)ˆ
à—~‘~ c¨:Ó6ˆÜˆ|Ó Ò!Ø�I‰I�O‰OÐ-Ô.Øð	MØ�L‰L˜Ô&ð 	�	‰	�‰Ð;¸hÑFÕGøôI ò 	HÜÐ9¸XÑFÓGÐGð	Hûô" *ò ;Ü,¨Y¸Ó:Ð:ûð;ú÷8ð 8ú÷8ñ 8ûô* ò 	MÜÐ=ÀÑHÈ!ÓLÐLûð	Músl   Á41H Ã;+IÄ'HÄ>IÅH:Å$IÇI ÈHÈ	H7È&H2È2H7È7IÈ:IÈ?IÉI	É	I0ÉI+É+I0©NNNNNrü   rã   r,   r*   r\  r\  Þ
  s}   „ ñ!ðD ,€Hñ 	ˆt�WÐ#JØ ¨Sô	2áˆzð !7Ø=@ô	Bð€Mð �€Jà×)Ñ)Ø×.Ñ.Ø×-Ñ-ñÐð HLØô5Hr,   r\  c                   ó¢   — e Zd ZdZdZ edddedd¬«       ed	d
ed¬«      gZdgZe	j                  e	j                  e	j                  dœZ	 	 dd„Zy)Úcmd_user_showaú  Display a user AD object.

This command displays a user account and it's attributes in the Active
Directory domain.
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.

The '--attributes' parameter takes a comma separated list of the requested
attributes. Without '--attributes' or with '--attributes=*' all usually
available attributes are selected.
Hidden attributes in addition to all usually available attributes can be
selected with e.g. '--attributes=*,msDS-UserPasswordExpiryTimeComputed'.
If a specified attribute is not available on a user object it's silently
omitted.

Attributes with time values can take an additional format specifier, which
converts the time value into the requested format. The format can be specified
by adding ";format=formatSpecifier" to the requested attribute name, whereby
"formatSpecifier" must be a valid specifier. The syntax looks like:

  --attributes=attributeName;format=formatSpecifier

The following format specifiers are available:
  - GeneralizedTime (e.g. 20210224113259.0Z)
  - UnixTime        (e.g. 1614166392)
  - TimeSpec        (e.g. 161416639.267546892)

Attributes with an original NTTIME value of 0 and 9223372036854775807 are
treated as non-existing value.

Example1:
samba-tool user show User1 -H ldap://samba.samdom.example.com \
    -U administrator --password=passw1rd

Example1 shows how to display 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 show User2

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

Example3:
samba-tool user show User2 --attributes=objectSid,memberOf

Example3 shows how to display a users objectSid and memberOf attributes.

Example4:
samba-tool user show User2 \
    --attributes='pwdLastSet;format=GeneralizedTime,pwdLastSet;format=UnixTime'

The result of Example 4 provides the pwdLastSet attribute values in the
specified format:
    dn: CN=User2,CN=Users,DC=samdom,DC=example,DC=com
    pwdLastSet;format=GeneralizedTime: 20210120105207.0Z
    pwdLastSet;format=UnixTime: 1611139927
ræ   r`   ra   rb   rc   rd   re   r�  z›Comma separated list of attributes, which will be printed. Possible supported virtual attributes: virtualGeneralizedTime, virtualUnixTime, virtualTimeSpec.Ú
user_attrs)rf   rg   ri   r�   r‚   Nc           
      óè  — |j                  «       }|j                  |d¬«      }t        |t        «       ||¬«      }	| j	                  |	«       |r| j                  |«      }
ndg}
dt        j                  t        j                  |«      fz  }|	j                  «       }| j                  |	|||t        j                  |
dd¬«      }t        j                  |	|«      }| j                  j!                  |«       y )NTrè   r“   rÄ  r^  F)r\  rø   rí   rï   r%   r]  )rµ   r¶   r
   r	   r“  r†  r   rc  rñ   rò   rô   ry  rõ   r   re  r±   r²   )rº   r�   r„   rƒ   r…   rd   rw  r–   rÑ   rÒ   rï   rø   rl  r6  Ú	user_ldifs                  r*   rÔ   zcmd_user_show.runž  sï   € ð ×#Ñ#Ó%ˆØ×(Ñ(¨¸dÐ(ÓCˆÜ˜!¬.Ó*:Ø"'¨Bô0ˆð 	×&Ñ& uÔ-áØ×)Ñ)¨*Ó5‰Eà�EˆEà=Ü×,Ñ,¬c×.?Ñ.?ÀÓ.IÐJñKˆð —?‘?Ó$ˆà×)Ñ)¨%°Ø19Ø17Ü03×0AÑ0AØ05Ø27Ø;@ð *ó Bˆô ×.Ñ.¨u°cÓ:ˆ	Ø�	‰	�‰˜	Õ"r,   rt  rü   rã   r,   r*   rv  rv  I  s€   „ ñ?ð@ ,€Hñ 	ˆt�WÐ#JØ ¨Sô	2áˆ~ðQð ˜lô	,ð	€Mð �€Jà×)Ñ)Ø×.Ñ.Ø×-Ñ-ñÐð HLØ#ô#r,   rv  c                   óŽ   — e Zd ZdZdZ edddedd¬«      gZd	d
gZe	j                  e	j                  e	j                  dœZ	 	 dd„Zy)Úcmd_user_moveaã  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]r`   ra   rb   rc   rd   re   r�   Únew_parent_dnr‚   Nc                 óV  — |j                  «       }|j                  |d¬«      }t        |t        «       ||¬«      }	t	        j
                  |	|	j                  «       «      }
dt        j                  t	        j                  |«      fz  }	 |	j                  |
|t        j                  ¬«      }|d   j                  }	 |	j                  |«      }t	        j
                  |	t#        |«      «      }|j%                  t'        |«      d
z
  «       |j)                  |«       	 |	j+                  ||«       | j,                  j/                  d|›d|›d�«       y # t        $ r t        d|z  «      ‚w xY w# t         $ r}t        d|›d	|›�«      ‚d }~ww xY w# t         $ r}t        d|z  |«      ‚d }~ww xY w)NTrè   r“   r^  r_  r   rð   zInvalid new_parent_dn "z": r   zFailed to move user "%s"zMoved user "z" into "z"
)rµ   r¶   r
   r	   rñ   rg  rô   r   rc  rò   ró   rõ   rê   rö   r   r  r¹   rÚ   Úremove_base_componentsrM   Úadd_baseÚrenamer±   r²   )rº   r�   r|  r„   rƒ   r…   rd   r–   rÑ   rÒ   rô   rø   rù   rú   Úfull_new_parent_dnrÓ   Úfull_new_user_dns                    r*   rÔ   zcmd_user_move.runè  s£  € à×#Ñ#Ó%ˆØ×(Ñ(¨¸dÐ(ÓCˆÜ˜!¬.Ó*:Ø"'¨Bô0ˆä—F‘F˜5 %§/¡/Ó"3Ó4ˆ	à=Ü×,Ñ,¬c×.?Ñ.?ÀÓ.IÐJñKˆð	HØ—,‘, IØ*0Ü%(×%6Ñ%6ð ó 8ˆCð ˜!‘f—i‘iˆGð	3Ø!&×!=Ñ!=¸mÓ!LÐô
 Ÿ6™6 %¬¨W«Ó6ÐØ×/Ñ/´°G³¸qÑ0@ÔAØ×!Ñ!Ð"4Ô5ð	IØ�L‰L˜Ð"2Ô3ð 	�	‰	�ŠÚ!Ò#5ð7õ 	8øô# ò 	HÜÐ9¸XÑFÓGÐGð	Hûô
 ò 	3ÝÚ -©qð 2ó 3ð 3ûð	3ûô ò 	IÜÐ9¸HÑDÀaÓHÐHûð	Iús<   Â1E Â:E) ÄF ÅE&Å)	FÅ2FÆFÆ	F(ÆF#Æ#F(rû   rü   rã   r,   r*   r{  r{  ¼  sk   „ ñð: <€Hñ 	ˆt�WÐ#JØ ¨Sô	2ð€Mð
 ˜oÐ.€Jà×)Ñ)Ø×.Ñ.Ø×-Ñ-ñÐð EIØ $ô!8r,   r{  c                   óN  — e Zd ZdZdZ edddedd¬«       ed	d
e¬«       edde¬«       edde¬«       edded¬«       eddd¬«       edde¬«       edde¬«       edde¬«       edde¬«      g
Zd gZe	j                  e	j                  e	j                  d!œZ	 	 	 	 	 d%d#„Zd$„ Zy")&Úcmd_user_renamea‰  Rename a user and related attributes.

    This command allows to set the user's name related attributes. The user's
    CN will be renamed automatically.
    The user's new CN will be made up by combining the given-name, initials
    and surname. A dot ('.') will be appended to the initials automatically
    if required.
    Use the --force-new-cn option to specify the new CN manually and the
    --reset-cn option to reset this change.

    Use an empty attribute value to remove the specified attribute.

    The username specified on the command is the sAMAccountName.

    The command may be run locally 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 rename johndoe --surname='Bloggs'

    Example1 shows how to change the surname of a user 'johndoe' to 'Bloggs' on
    the local server. The user's CN will be renamed automatically, based on
    the given name, initials and surname.

    Example2:
    samba-tool user rename johndoe --force-new-cn='John Bloggs (Sales)' \
        --surname=Bloggs -H ldap://samba.samdom.example.com -U administrator

    Example2 shows how to rename the CN of a user 'johndoe' to 'John Bloggs (Sales)'.
    Additionally the surname ('sn' attribute) is set to 'Bloggs'.
    The -H parameter is used to specify the remote target server.
    ræ   r`   ra   rb   rc   rd   re   rt   zNew surnamers   ru   zNew given namerv   zNew initialsz--force-new-cnz^Specify a new CN (RDN) instead of using a combination of the given name, initials and surname.ÚNEW_CN)rf   rg   rh   z
--reset-cnz–Set the CN (RDN) to the combination of the given name, initials and surname. Use this option to reset the changes made with the --force-new-cn option.rl   rm   z--display-namezNew display namerw   zNew email addressz--samaccountnamez,New account name (sAMAccountName/logon name)z--upnzNew user principal namer�   r‚   Nc           	      ód  — |r|rt        d«      ‚|dk(  rt        d«      ‚|dk(  rt        d«      ‚|j                  «       }|j                  |d¬«      }t        |t	        «       ||¬«      }t        j                  ||j                  «       «      }dt        j                  t        j                  |«      fz  }	 |j                  ||t
        j                  g d	¢¬
«      }|d   }|j                  }|j                  «       }|d   d   }|�|n|d   }|�|}n|j!                  |||||¬«      }|j!                  ||d   ¬«      }t#        |«      t#        |«      k7  xr( t#        |«      t#        |«      k(  xs |xs t%        |«      }t        j                  |d|z  «      }|j'                  |«       |�#| j)                  ||«      dk(  rt        d|z  «      ‚t        j*                  «       }||_        |j-                  ||d|«       |j-                  ||d|«       |j-                  ||d|«       |j-                  ||d|	«       |j-                  ||d|
«       |j-                  ||d|«       |j-                  ||d|«       t/        |«      dkD  }|j1                  «        	 |dk(  r|j3                  |«       |dk(  r|j5                  ||«       |j;                  «        |dk(  r%| j<                  j?                  d|›d|›d|›d�«       |dk(  re| j<                  j?                  d|z  «       |jA                  «       D ]3  }!|!d k(  rŒ	| j<                  j?                  |!›d!||!   r||!   nd"›d#�«       Œ5 y y # t        $ r t        d|z  «      ‚w xY w# t6        $ r$} |j9                  «        t        d|z  | «      ‚d } ~ ww xY w)$NzEIt is not allowed to specify --force-new-cn together with --reset-cn.rC   z7Failed to rename user - delete protected attribute 'CN'zCFailed to rename user - delete protected attribute 'sAMAccountName'Trè   r“   r^  )rL  Ú	givenNamerœ   ÚsnÚmailrÅ  ÚdisplayNameÚcnrI  r   rð   r‹  rL  )Ú	old_attrsr¿   rœ   rš   Úfallback_default)rŒ  r�  zCN=%sFzo"%s" is not a valid upn. You can manage the upn suffixes with the "samba-tool domain trust namespaces" command.r‡  rœ   rˆ  rŠ  r‰  rÅ  zFailed to rename user "%s"zRenamed CN of user "z" from "z" to "z" successfully
zBFollowing attributes of user "%s" have been changed successfully:
rê   ry  z	[removed]rä  )!r   rµ   r¶   r
   r	   rñ   rg  rô   r   rc  rò   ró   rõ   rê   rö   ÚparentÚfullname_from_namesrÚ   Úboolr  Úis_valid_upnr7  Úprepare_attr_replacerM   r)  rj  r€  r¹   r+  r*  r±   r²   rŽ  )"rº   r�   r„   rƒ   r…   rd   rš   r¿   rœ   Údisplay_namerÅ   r  ÚupnÚforce_new_cnÚreset_cnr–   rÑ   rÒ   rô   rø   rù   Úold_userrú   Úuser_parent_dnÚold_cnÚnew_fallback_cnÚnew_user_cnÚexpected_cnÚmust_change_cnÚnew_user_dnrw  Úattributes_changedrÓ   r°  s"                                     r*   rÔ   zcmd_user_rename.run^  s,  € ñ ™HÜð  ;ó <ð <à˜2ÒÜð  0ó 1ð 1à˜RÒÜð  <ó =ð =ð ×#Ñ#Ó%ˆØ×(Ñ(¨¸dÐ(ÓCˆÜ˜!¬.Ó*:Ø"'¨Bô0ˆä—F‘F˜5 %§/¡/Ó"3Ó4ˆ	à=Ü×,Ñ,¬c×.?Ñ.?ÀÓ.IÐJñKˆð	HØ—,‘, IØ*0Ü%(×%6Ñ%6ò&,ð ó 
-ˆCð ˜1‘vˆHØ—k‘kˆGð !Ÿ™Ó)ˆØ˜$‘ Ñ"ˆð -;Ð,F™.Ø*2Ð3CÑ*Dð 	ð Ð#Ø&‰Kà×3Ñ3¸hØ?IØ=EØ<CØETð	 4ó VˆKð ×/Ñ/¸(Ø9AÐBRÑ9Sð 0ó Uˆä˜V›¬¨KÓ(8Ñ8ò :Ü˜f›+¬¨[Ó)9Ñ9ò 9Ø"ò9Ü&*¨<Ó&8ð 	ô —f‘f˜U G¨kÑ$9Ó:ˆØ×Ñ˜^Ô,àˆ?Ø× Ñ  ¨Ó,°Ò5Ü"ð $@ð CFñ$Fó Gð Gô
 —[‘[“]ˆ
Øˆ
ŒØ×"Ñ" :¨x¸ÀjÔQØ×"Ñ" :¨x¸ÀXÔNØ×"Ñ" :¨x¸¸wÔGØ×"Ñ" :¨x¸ÈÔUØ×"Ñ" :¨x¸ÀÔNØ×"Ñ" :¨xÐ9IÈ>ÔZØ×"Ñ" :¨xÐ9LÈcÔRä  ›_¨qÑ0Ðà×ÑÔ!ð	KØ! TÒ)Ø—‘˜ZÔ(Ø Ò%Ø—‘˜W kÔ2ð 	× Ñ Ô"à˜TÒ!Ø�I‰I�OŠOÚ08º&Â+ðOô Pð  Ò%Ø�I‰I�O‰Oð 6Ø9AñCô Dà"Ÿ™Ó)ò G�Ø˜D’LØØ—	‘	—‘ªdØ#-¨dÒ#3ð 5?¸tÒ4DØ9Dñ5Eð !Fõ GñGð &øôA ò 	HÜÐ9¸XÑFÓGÐGð	Hûôn ò 	KØ×$Ñ$Ô&ÜÐ;¸hÑFÈÓJÐJûð	Kús$   Â76M' Ê-N Í'M?Î	N/ÎN*Î*N/c                 óÀ  — |j                  «       }|j                  «       }||g}|j                  «       }d|z  }|j                  |t        j
                  ddg¬«      }t        |«      dk\  r;|d   }	d|	v r2|	d   D ]*  }
|j                  t        |
«      j                  «       «       Œ, |j                  d«      }t        |«      dk  ry	|d
   j                  «       }||vry	y)NzCN=Partitions,%sz(objectClass=crossRefContainer)ÚuPNSuffixesrë   r   r   rÉ  rŽ   Frá  T)rO  Úforest_dns_nameÚget_config_basednró   rñ   rP  rM   ri  rÚ   r�  rO  )rº   rÒ   r”  Ú
domain_dnsÚ
forest_dnsÚupn_suffixesÚconfig_basednÚpartitions_dnrù   r  ÚsÚ	upn_splitÚ
upn_suffixs                r*   r‘  zcmd_user_rename.is_valid_upnÍ  sí   € Ø×*Ñ*Ó,ˆ
Ø×*Ñ*Ó,ˆ
Ø" JÐ/ˆà×/Ñ/Ó1ˆØ*¨]Ñ:ˆØ�l‰lØÜ—.‘.Ø8Ø �/ð	 ó #ˆô �‹H˜ŠMØ�a‘&ˆCØ Ñ#Ø˜]Ñ+ò 8�AØ ×'Ñ'¬¨A«¯©«Õ7ð8ð —I‘I˜c“Nˆ	Ü�	‹N˜QÒØà˜r‘]×(Ñ(Ó*ˆ
Ø˜\Ñ)Øàr,   )NNNNNNNNNNNNN)rÕ   rÖ   r×   rØ   rÙ   r   rÚ   rÜ   rÝ   rÞ   rß   rà   rá   râ   rÔ   r‘  rã   r,   r*   r„  r„    s(  „ ñ"ðH ,€Hñ 	ˆt�WØ;Ø ¨Sô	2ñ 	ˆ{Ø!Øô	ñ 	ˆ~Ø$Øô	ñ 	ˆ|Ø"Øô	ñ 	Ðð?à ô	+ñ 	ˆ|ðGð #ô		$ñ
 	ÐØ&Øô	ñ 	ÐØ'Øô	ñ 	Ð!ØBØô	ñ 	ˆwØ-Øô	ð?"€MðH �€Jà×)Ñ)Ø×.Ñ.Ø×-Ñ-ñÐð 6:Ø?CØ;?Ø8<Øó	mGó^r,   r„  c            
       óô   — e Zd ZdZdZ edddedd¬«       ed	d
e¬«       edde¬«       edde¬«       edde¬«       edde¬«      gZddgZe	j                  e	j                  e	j                  dœZ	 	 	 dd„Zy)Úcmd_user_add_unix_attrsa…
  Add RFC2307 attributes to a user.

This command adds Unix attributes to a user account in the Active
Directory domain.

The username specified on the command is the sAMaccountName.

You must supply a unique uidNumber.

Unix (RFC2307) attributes will be added to the user account.

If you supply a gidNumber with '--gid-number', this will be used for the
users Unix 'gidNumber' attribute.

If '--gid-number' is not supplied, the users Unix gidNumber will be set to the
one found in 'Domain Users', this means Domain Users must have a gidNumber
attribute.

if '--unix-home' is not supplied, the users Unix home directory will be
set to /home/DOMAIN/username

if '--login-shell' is not supplied, the users Unix login shell will be
set to '/bin/sh'

if ---gecos' is not supplied, the users Unix gecos field will be set to the
users 'CN'

Add 'idmap_ldb:use rfc2307 = Yes' to the smb.conf on DCs, to use these
attributes for UID/GID mapping.

The command may be run from the root userid or another authorised userid.
The -H or --URL= option can be used to execute the command against a
remote server.

Example1:
samba-tool user addunixattrs User1 10001

Example1 shows how to add RFC2307 attributes to a domain enabled user
account, Domain Users will be set as the users gidNumber.

The users Unix ID will be set to '10001', provided this ID isn't already
in use.

Example2:
samba-tool user addunixattrs User2 10002 --gid-number=10001 --unix-home=/home/User2

Example2 shows how to add RFC2307 attributes to a domain enabled user
account.

The users Unix ID will be set to '10002', provided this ID isn't already
in use.

The users gidNumber attribute will be set to '10001'

The users Unix home directory will be set to '/home/user2'

Example3:
samba-tool user addunixattrs User3 10003 --gid-number=10001 --login-shell=/bin/false --gecos='User3 test'

Example3 shows how to add RFC2307 attributes to a domain enabled user
account.

The users Unix ID will be set to '10003', provided this ID isn't already
in use.

The users gidNumber attribute will be set to '10001'

The users Unix login shell will be set to '/bin/false'

The users gecos field will be set to 'User3 test'

Example4:
samba-tool user addunixattrs User4 10004 --gid-number=10001 --unix-home=/home/User4 --login-shell=/bin/bash --gecos='User4 test'

Example4 shows how to add RFC2307 attributes to a domain enabled user
account.

The users Unix ID will be set to '10004', provided this ID isn't already
in use.

The users gidNumber attribute will be set to '10001'

The users Unix home directory will be set to '/home/User4'

The users Unix login shell will be set to '/bin/bash'

The users gecos field will be set to 'User4 test'

z'%prog <username> <uid-number> [options]r`   ra   rb   rc   rd   re   r|   zUser's Unix/RFC2307 GIDrs   rx   ry   r   r€   r}   r~   rz   r{   r�   z
uid-numberr‚   Nc           	      ó  — |j                  «       }|j                  |«      }t        |t        «       ||¬«      }|j	                  «       }dj                  |«      }|j                  |t        j                  |¬«      }t        |«      dk7  rt        dj                  |«      «      ‚dj                  t        j                  |«      «      }|j                  |t        j                  |¬«      }t        |«      dk(  rt        dj                  |«      «      ‚|d   j                  }d|d   v rt        d	j                  |«      «      ‚|
€|d   d
   d   }
|€|d   d
   d   }|€`dj                  t        j                  d«      «      }	 |j                  |t        j                  |¬«      }|D ]  }|j                  d«      }Œ 	 |	€d}	|€P|j                  «       }|€t        d«      ‚|j                  d«      }|j!                  d|«      j!                  d|«      }|j                  d«      s| j"                  j%                  d«       dj                  ||||
||	|«      }|j'                  «        	 |j)                  |«       |j+                  «        | j"                  j%                  dj                  |«      «       y # t        $ r t        d«      ‚w xY w# t        j,                  $ r }t        dj                  ||«      «      ‚d }~ww xY w)Nr“   z%(&(objectClass=person)(uidNumber={})))rí   rî   r   z#uidNumber {} is already being used.z(samaccountname={})zUnable to find user '{}'Ú	uidNumberzUser {} is already a Unix user.r‹  zDomain UsersÚ	gidNumberz0Domain Users does not have a gidNumber attributez/bin/shzUnable to find Unix domainztemplate homedirz%Dz%Ur’   z“You are setting a Unix/RFC2307 UID & GID. You may want to set 'idmap_ldb:use rfc2307 = Yes' in smb.conf to use the attributes for XID/SID-mapping.
zÎ
dn: {0}
changetype: modify
add: uidNumber
uidNumber: {1}
add: gidnumber
gidNumber: {2}
add: gecos
gecos: {3}
add: uid
uid: {4}
add: loginshell
loginShell: {5}
add: unixHomeDirectory
unixHomeDirectory: {6}
z Modified User '{}' successfully
z Failed to modify user '{0}': {1})rµ   r¶   r
   r	   rô   r·  ró   rñ   rõ   rM   r   rò   rê   r·   rö   rY  rI   r±   r²   r)  rj  r*  rP  )rº   r�   rÌ   r„   rƒ   r…   rd   rÍ   rË   rÎ   r®   r«   r–   rÑ   rÒ   rl  rø   rù   rú   Úsearch_filterr  Úunix_domainÚtmplÚuser_modrÓ   s                            r*   rÔ   zcmd_user_add_unix_attrs.run_  s  € ð ×#Ñ#Ó%ˆØ×(Ñ(¨Ó,ˆä˜!¬.Ó*:Ø"'¨Bô0ˆð —?‘?Ó$ˆð :ß‘6˜*Ó%ð 	à�l‰l˜8Ü!$×!2Ñ!2Ø&,ð ó .ˆô �‹H˜ŠMÜÐDß &¡ zÓ 2ó4ð 4ð '×-Ñ-¬c×.?Ñ.?ÀÓ.IÓJˆØ�l‰l˜8Ü!$×!2Ñ!2Ø&,ð ó .ˆô �‹H˜ŠMÜÐ9×@Ñ@ÀÓJÓKÐKà�a‘&—)‘)ˆà˜#˜a™&Ñ ÜÐ@ß &¡ xÓ 0ó2ð 2ð ˆ=Ø˜‘F˜4‘L ‘OˆEàˆ;Ø�a‘&˜‘,˜q‘/ˆCàÐØ2ß%™v¤c×&7Ñ&7¸Ó&GÓHð ð;Ø—l‘l 8Ü),×):Ñ):Ø.;ð #ó =�ð ò 4�CØ"Ÿw™w {Ó3‘Jñ4ð ÐØ#ˆKàÐà×3Ñ3Ó5ˆKØÐ"Ü"Ð#?Ó@Ð@à—6‘6Ð,Ó-ˆDØŸ™ T¨;Ó7×?Ñ?ÀÀhÓOˆIà�v‰vÐ-Ô.Ø�I‰I�O‰Oð 1ô 2ð
÷ �Fˆ7�J 
¨E°3¸ÀYÓOð 	ð" 	×ÑÔ!ð	/Ø×Ñ˜hÔ'ð
 ×$Ñ$Ô&Ø�I‰I�O‰OÐ?ß#™V HÓ-õ/øô_ ò ;Ü"ð $:ó ;ð ;ð;ûôT �|‰|ò 	5ÜÐAß &¡ x°Ó 3ó5ð 5ûð	5ús$   Æ:J4 É(K Ê4K	ËK?ËK:Ë:K?)	NNNNNNNNNrü   rã   r,   r*   r­  r­  ë  sº   „ ñ[ðz 9€Hñ 	ˆt�WÐ#JØ ¨Sô	2áˆ~Ð$=ÀCÔHÙˆ}Ð#GØô	áˆÐ%FØô	áˆyÐ@ÀsÔKÙˆwÐ;À#ÔFð
€Mð ˜lÐ+€Jð ×)Ñ)Ø×.Ñ.Ø×-Ñ-ñ
Ðð BFØAEØ.2ôc/r,   r­  c                   ó¨   — e Zd ZdZdZ edddedd¬«       ed	d
e¬«      gZdgZe	j                  e	j                  e	j                  dœZ	 	 	 	 	 	 dd„Zy)Úcmd_user_unlockaz  Unlock a user account.

    This command unlocks a user account in the Active Directory domain. The
    username specified on the command is the sAMAccountName. The username may
    also be specified using the --filter option.

    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.

    Example:
    samba-tool user unlock user1 -H ldap://samba.samdom.example.com \
        --username=Administrator --password=Passw0rd

    The example shows how to unlock a user account in the domain against a
    remote LDAP server. The -H parameter is used to specify the remote target
    server. The --username= and --password= options are used to pass the
    username and password of a user that exists on the remote server and is
    authorized to issue the command on that server.
r  r`   ra   rb   rc   rd   re   r  r  rs   r  r‚   Nc                 óZ  — |€|€t        d«      ‚|€dt        j                  |«      z  }|j                  «       }|j	                  |d¬«      }t        |t        «       ||¬«      }		 |	j                  |«       y # t        t        j                  f$ r}
t        d|xs |›d|
›�«      ‚d }
~
ww xY w)Nr!  r"  Trè   r“   zFailed to unlock user 'r#  )
r   rñ   rò   rµ   r¶   r
   r	   Úunlock_accountr   rP  r%  s              r*   rÔ   zcmd_user_unlock.runð  sÇ   € ð Ð  Üð  ,ó -ð -ð ˆ>Ø@Ü×!Ñ! (Ó+ñ-ˆFð ×#Ñ#Ó%ˆØ×(Ñ(¨¸dÐ(ÓCˆä˜!Ü#1Ó#3Ø"'Øôˆð	9Ø× Ñ  Õ(øÜœCŸL™LÐ)ò 	9ÝØ'Ò1¨6Ñ1±3ð 8ó 9ð 9ûð	9ús   Á%A7 Á7B*ÂB%Â%B*r&  rü   rã   r,   r*   r¶  r¶  Ä  sŠ   „ ñð* @€Hñ 	ˆtØØ;ØØØô	ñ 	ˆzØ4Øô	ð
€Mð �€Jð ×)Ñ)Ø×.Ñ.Ø×-Ñ-ñÐð ØØØØØô9r,   r¶  c                   óŽ   — e Zd ZdZdZej                  ej                  ej                  dœZ	 e
dddedd¬	«      gZd
dgZ	 	 dd„Zy)Úcmd_user_sensitivez2Set/unset or show UF_NOT_DELEGATED for an account.z-%prog <accountname> [(show|on|off)] [options]r‚   r`   ra   rb   rc   rd   re   ÚaccountnameÚcmdNc                 óö  — |dvrt        d|z  «      ‚|j                  «       }|j                  |d¬«      }t        |t	        «       ||¬«      }	dt        j                  |«      z  }
t        j                  }|dk(  r¾|	j                  t
        j                  |
dg¬	«      }t        |«      d
k(  rt        d|
z  «      ‚t        |d
   j                  d«      d
   «      }| j                  j!                  dt#        |d
   j$                  «      z  «       | j                  j!                  dt'        ||z  «      z  «       y |dk(  rd}n|dk(  rd}	 |	j)                  |
|dd¬«       y # t        $ r}t        |«      ‚d }~ww xY w)N)Úshowrx  Úoffz8invalid argument: '%s' (choose from 'show', 'on', 'off')Trè   r“   zsAMAccountName=%sr¾  r§  r  r   z!Unable to find account where '%s'zAccount-DN: %s
zUF_NOT_DELEGATED: %s
rx  r¿  FzNot-Delegated)Ú	flags_strrx  Ústrict)r   rµ   r¶   r
   r	   rñ   rò   r   ÚUF_NOT_DELEGATEDró   rõ   rM   r¹   rÛ   r·   r±   r²   rÚ   rê   r�  r  )rº   r»  r¼  rd   r„   rƒ   r…   r–   rÑ   Úsamr±  Úflagrù   Úuacrx  r  s                   r*   rÔ   zcmd_user_sensitive.run  sw  € ð Ð+Ñ+ÜÐYÐ\_Ñ_Ó`Ð`à×#Ñ#Ó%ˆØ×(Ñ(¨¸dÐ(ÓCˆÜ˜¬Ó(8Ø %¨"ô.ˆð ,¬c×.?Ñ.?ÀÓ.LÑLˆÜ×$Ñ$ˆà�&Š=Ø—*‘*¤3×#4Ñ#4ÀØ$8Ð#9ð ó ;ˆCä�3‹x˜1Š}ÜÐ CÀmÑ SÓTÐTä�c˜!‘f—j‘jÐ!5Ó6°qÑ9Ó:ˆCà�I‰I�O‰OÐ.´°S¸±V·Y±Y³Ñ?Ô@Ø�I‰I�O‰OÐ4´t¸CÀ$¹JÓ7GÑGÔHàà�$Š;Ø‰BØ�EŠ\ØˆBð	$Ø×'Ñ'¨°tÀØ+-°dð (õ <øäò 	$Ü˜sÓ#Ð#ûð	$ús   ÅE Å	E8Å(E3Å3E8rû   )rÕ   rÖ   r×   rØ   rÙ   rÞ   rß   rà   rá   râ   r   rÚ   rÜ   rÝ   rÔ   rã   r,   r*   rº  rº    sf   „ Ù<à>€Hð ×)Ñ)Ø×.Ñ.Ø×-Ñ-ñÐñ 	ˆt�WÐ#JÐQTØ 3ô	(ð€Mð
   Ð'€JàEIØô$$r,   rº  c                   ó¤  — e Zd ZdZi Z e«       ed<    e«       ed<    e«       ed<    e«       ed<    e«       ed<    e	«       ed<    e
«       ed<    e«       ed	<    e«       ed
<    e«       ed<    e«       ed<    e«       ed<    e«       ed<    e«       ed<    e«       ed<    e«       ed<    e«       ed<    e«       ed<    e«       ed<    e«       ed<   y)Úcmd_userzUser management.ÚaddÚcreater÷   ÚdisableÚenablerò  r1  r»   Ú	getgroupsÚsetprimarygroupr€  ÚgetpasswordÚsyncpasswordsÚeditr¾  Úmover€  ÚunlockÚaddunixattrsÚ	sensitiveN)rÕ   rÖ   r×   rØ   Úsubcommandsr_   rå   r)  r  rþ   r-  r5  rB  ra  rv  rŠ  rš  r\  rv  r{  r„  r¶  r­  rº  rã   r,   r*   rÇ  rÇ  E  s	  „ Ùà€KÙ%›€K�ÑÙ(›N€K�ÑÙ+Ó-€K�ÑÙ-Ó/€K�	ÑÙ+Ó-€K�ÑÙ'›/€K�ÑÙ1Ó3€K�ÑÙ/Ó1€K�
ÑÙ1Ó3€K�ÑÙ%=Ó%?€KÐ!Ñ"Ù!5Ó!7€K�ÑÙ!5Ó!7€K�ÑÙ#9Ó#;€K�Ñ Ù'›/€K�ÑÙ'›/€K�ÑÙ'›/€K�ÑÙ+Ó-€K�ÑÙ+Ó-€K�ÑÙ"9Ó";€K�ÑÙ1Ó3€K�Òr,   rÇ  rM  )brQ  Úsamba.getoptÚgetoptrÞ   rñ   r³   rE   r#   r  rN  rE  rµ  rG   rÍ  Ú
subprocessr   r   r   r   r   r   Ú
samba.authr	   Úsamba.samdbr
   r   Úsamba.dcerpcr   r   r   Ú	samba.ndrr   Úsambar   r   r   r   r   r   Ú	samba.netr   Úsamba.netcmdr   r   r   r   Úsamba.commonr   r   rC   r   r+   r4   rR  r    ÚImportErrorr/   r”  r  ÚATTR_FLAG_FORCE_BASE64_LDIFr�  rW   rV  rW  rÓ   rY   rN   r°  rK   rL   r  rr  r˜  rÚ  rŒ  rŽ  rM   r_   rå   rþ   r  r)  r-  r5  rB  ra  rv  r„  rŠ  rš  r\  rv  r{  r„  r­  r¶  rº  rÇ  rã   r,   r*   ú<module>rã     så  ðó( Ý Û 
Û 
Û 	Û 	Û Û Û Û Û Û ß JÕ JÝ Ý %ß )Ý Ý !Ý !Ý  ÷÷ õ ÷ó õ #Ý #Ý òòð €áðÛØ$ˆñ ðÛØ"ˆñ ð1ÑðJÐðÐ ð
 	�×0Ñ0ðð 	�×0Ñ0ðð 	�×0Ñ0ðñ
Ð óð:
ÛØ€G‡L�L„Nð)Ð�}Ñ%ð Nò 
�K€Sˆ$ð
ÛÙ˜˜RÔ ð$
Ð˜4Ò ð	
ñ& 
ˆq�"‹ò 6€AØ35ÐÐ+¨aÑ/Ò0ð6ð -/Ð Ð(Ñ )àJÐ Ø ÐFÈÏÉÑSYÐZl×ZqÑZqÓZsÓStÓIuÑuÑ uÐ ÙÐ"Ó# qÒ(ØÐCÀdÇiÁiÑPVÐWr×WwÑWwÓWyÓPzÓF{Ñ{Ñ{ÐôqE�7ô qEôf:8�gô :8ôzOG�Gô OGôdAF�gô AFôH#^�wô #^ôLH+˜ô H+ôV,1˜ô ,1ô^Y1˜ô Y1ôxkN˜wô kNô\B5˜7ô B5ôJp
˜ô p
ôfh-Ð-ô h-ôVBÐ/ô BôJhH�Gô hHôVq#Ð&ô q#ôfM8�Gô M8ô`\�gô \ô~W/˜gô W/ôrF9�gô F9ôP6$˜ô 6$ôr4ˆ|õ 4øðSo ò Úðûð ò Úðûðz ò Ø€FØ
ˆkÑ€Fà�&ð2Ð ×.ûðûð ò 
ØˆØ�+Ñˆà�fð-
Ð# D×)ûð ò 
Ø:¸cÑBˆà�fð-
Ð# D×)ûð
ús`   Â,J Â5J Ã3J( ÄK	ÊJÊJÊJ%Ê$J%Ê(KÊ-KËKË	LËK"Ë"LË*K<Ë<L