
    g                     ^    S SK Jr  S SKJr  S SKJr  S SKJrJ	r	J
r
  S SKJr   " S S\5      rg)    N)ldb)system_session)CommandCommandErrorOption)SamDBc            
           \ rS rSrSrSr\R                  \R                  \R                  S.r
\" SSS\SS	S
9\" SS\S9\" SS\SS9\" SSSSS9/rS/r  SS jrSrg)cmd_user_setexpiry   a  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.

z.%prog (<username>|--filter <filter>) [options])	sambaoptsversionoptscredoptsz-Hz--URLz%LDB URL for database or target serverURLH)helptypemetavardestz--filterzLDAP Filter to set password on)r   r   z--dayszDays to expiryr   )r   r   defaultz
--noexpiryzPassword does never expire
store_trueF)r   actionr   z	username?Nc	                     Uc  Uc  [        S5      eUc  S[        R                  " U5      -  nUR                  5       n	UR	                  U	5      n
[        U[        5       XS9n UR                  XgS-  S-  US9  U(       a(  U R                  R                  S	U=(       d    U-  5        g U R                  R                  S
U=(       d    UU4-  5        g ! [         a!  n[        SU=(       d    U< SU< 35      eS nAff = f)Nz4Either the username or '--filter' must be specified!z((&(objectClass=user)(sAMAccountName=%s)))urlsession_infocredentialslp   i  )no_expiry_reqzFailed to set expiry for user 'z': zExpiry for user '%s' disabled.
z%Expiry for user '%s' set to %u days.
)r   r   binary_encodeget_loadparmget_credentialsr   r   	setexpiry	Exceptionoutfwrite)selfusernamer   r   r   r   filterdaysnoexpiryr   credssamdbmsgs                =/usr/lib/python3/dist-packages/samba/netcmd/user/setexpiry.pyruncmd_user_setexpiry.runL   s   UVV>?3CTCTU]C^_F##%((,!.*:"'0	*OOF2I$4HOM
 IIOO>"F$ % IIOOD"FDH* * +  	*"F"C ) * *	*s   #C 
C=C88C= )NNNNNNNN)__name__
__module____qualname____firstlineno____doc__synopsisoptionsSambaOptionsVersionOptionsCredentialsOptionstakes_optiongroupsr   strinttakes_options
takes_argsr/   __static_attributes__r1       r.   r
   r
      s    8 @H ))--.. 	tW#JQT3	(z @sKx.S!D|">|]bcM J:>GK+rB   r
   )samba.getoptgetoptr8   sambar   
samba.authr   samba.netcmdr   r   r   samba.samdbr   r
   r1   rB   r.   <module>rI      s'   ,   % 6 6 H+ H+rB   