a „oe´ ã@sXdZddlZddlZddlmZddlZddlZddlZdd„ZedkrTe  eƒ¡dS)a9A 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 Csztjddd�}|jddddd�|jd d dd d�|jd d dddd�|jddddd�|jdddddd�| ¡\}}|s‚dg}|D]î}|dkr¤d|ji}tj}n,|dkrÆ|j|j|jdœ}tj }n |  d¡zt   |j d||¡\}}WnTt�y tdƒYd St j �y>}ztd!|ƒWYd}~d Sd}~00|j�rXtd"ƒt|ƒtd#||t |¡ ¡fƒq†d$S)%Nz%prog [options] auth|change ...z*A win32net.NetValidatePasswordPolicy demo.)Ú descriptionz-uz --usernameÚstorezAThe 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_falseTz‰Used to specify the password does NOT match (ie, uses False for the PasswordMatch/PasswordMatched arg, both 'auth' and 'change' commands))rÚdefaultrz-sz--serverz0The name of the server to execute the command onz-fz --show_fieldsÚ store_trueFz0Print the NET_VALIDATE_PERSISTED_FIELDS returnedZauthZPasswordMatchedZchange)Z ClearPasswordZ PasswordMatchZUserAccountNamez(Invalid arg - must be 'auth' or 'change'z;NetValidatePasswordPolicy not implemented on this platform.éz"NetValidatePasswordPolicy failed: z%NET_VALIDATE_PERSISTED_FIELDS fields:z!Result of %r validation is %d: %sr)ÚoptparseZ OptionParserZ add_optionÚ parse_argsZpassword_matchedÚ win32netconZNetValidateAuthenticationÚpasswordÚusernameZNetValidatePasswordChangeÚerrorÚwin32netZNetValidatePasswordPolicyZserverÚNotImplementedErrorÚprintZ show_fieldsrÚwin32apiZ FormatMessageÚstrip) ÚparserÚoptionsÚargsÚargÚinputZval_typeÚfieldsÚstatusÚexc©rúFC:\Program Files\Certbot\pkgs\win32\Demos\NetValidatePasswordPolicy.pyÚmain$sŒþüüû üû ÿý  ÿ  ÿÿr Ú__main__) Ú__doc__r Úsysrrrr r Ú__name__ÚexitrrrrÚs Z