
    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/rS/r  SS jrSrg)cmd_user_enable   a  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.

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	username?Nc                    Uc  Uc  [        S5      eUc  S[        R                  " U5      -  nUR                  5       nUR	                  USS9n[        U[        5       XS9n	 U	R                  U5        U R                  R                  SU=(       d    U-  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))T)fallback_machine)urlsession_infocredentialslpzFailed to enable user 'z': zEnabled user '%s'
)r   r   binary_encodeget_loadparmget_credentialsr   r   enable_account	Exceptionoutfwrite)selfusernamer   r   r   filterr   r   credssamdbmsgs              :/usr/lib/python3/dist-packages/samba/netcmd/user/enable.pyruncmd_user_enable.runM   s    UVV>?3CTCTU]C^_F##%((d(C!.*:"'0	]  ( 			-1CVDE  	]8CUvCUWZ[\\	]s   "B 
C%CC )NNNNNN)__name__
__module____qualname____firstlineno____doc__synopsisoptionsSambaOptionsVersionOptionsCredentialsOptionstakes_optiongroupsr   strtakes_options
takes_argsr)   __static_attributes__r+       r(   r
   r
      sv    > @H ))--.. 	tW#JQT3	(z @sKM J:>-1Fr;   r
   )samba.getoptgetoptr2   sambar   
samba.authr   samba.netcmdr   r   r   samba.samdbr   r
   r+   r;   r(   <module>rB      s)   ,   % 6 6 AFg AFr;   