
    r@;j                         d Z ddlZddlZddlmZ ddlZddlZddlZd Zedk    r ej	         e                       dS dS )a9  A demo of using win32net.NetValidatePasswordPolicy.

Example usage:

% NetValidatePasswordPolicy.py --password=foo change
which might return:

> Result of 'change' validation is 0: The operation completed successfully.

or depending on the policy:

> Result of 'change' validation is 2245: The password does not meet the
> password policy requirements. Check the minimum password length,
> password complexity and password history requirements.

Adding --user doesn't seem to change the output (even the PasswordLastSet seen
when '-f' is used doesn't depend on the username), but theoretically it will
also check the password history for the specified user.

% NetValidatePasswordPolicy.py auth

which always (with and without '-m') seems to return:

> Result of 'auth' validation is 2701: Password must change at next logon
    N)pprintc                     t          j        dd          } |                     dddd           |                     d	d
dd           |                     ddddd           |                     dddd           |                     ddddd           |                                 \  }}|sdg}|D ]}|dk    rd|j        i}t
          j        }n=|dk    r"|j        |j        |j        d}t
          j	        }n| 
                    d           	 t          j        |j        d ||          \  }}n.# t          j
        $ r}t          d|           Y d }~ d S d }~ww xY w|j        rt          d!           t!          |           t          d"|d#| d$t#          j        |                                                     d%S )&Nz%prog [options] auth|change ...z*A win32net.NetValidatePasswordPolicy demo.)descriptionz-uz
--usernamestorezDThe username to pass to the function (only for the 'change' command))actionhelpz-pz
--passwordzOThe clear-text password to pass to the function (only for the 'change' command)z-mz--password-matchedstore_falseTzUsed to specify the password does NOT match (ie, uses False for the PasswordMatch/PasswordMatched arg, both 'auth' and 'change' commands))r   defaultr   z-sz--serverz0The name of the server to execute the command onz-fz--show_fields
store_trueFz0Print the NET_VALIDATE_PERSISTED_FIELDS returnedauthPasswordMatchedchange)ClearPasswordPasswordMatchUserAccountNamez(Invalid arg - must be 'auth' or 'change'z"NetValidatePasswordPolicy failed:    z%NET_VALIDATE_PERSISTED_FIELDS fields:z
Result of z validation is :r   )optparseOptionParser
add_option
parse_argspassword_matchedwin32netconNetValidateAuthenticationpasswordusernameNetValidatePasswordChangeerrorwin32netNetValidatePasswordPolicyserverprintshow_fieldsr   win32apiFormatMessagestrip)	parseroptionsargsarginputval_typefieldsstatusexcs	            sC:\Users\Administrator\AppData\Local\Temp\2\pip-target-b0z114gj\lib\python\win32/Demos/NetValidatePasswordPolicy.pymainr1   $   s   ")@  F
 S	     *	     2     ?	     ?     %%''MGT x 
 
&==!7#;E #<HHH__!(!1!(!9#*#3 E
 #<HHLLCDDD	%?h NFFF ~ 	 	 	6<<<111111	  	9:::6NNN888v888"6**0022	
 	
 	
 	

 1s   D11E EE__main__)
__doc__r   sysr   r$   r   r   r1   __name__exit     r0   <module>r9      s    4  



            T T Tn zCHTTVV r8   