win32netcon.NetValidateAuthentication

Here are the examples of the python api win32netcon.NetValidateAuthentication taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

2 Examples 7

Example 1

Project: WAPT
Source File: NetValidatePasswordPolicy.py
View license
def main():
    parser = optparse.OptionParser("%prog [options] auth|change ...",
                                   description="A win32net.NetValidatePasswordPolicy demo.")

    parser.add_option("-u", "--username",
                      action="store",
                      help="The username to pass to the function (only for the "
                           "change command")

    parser.add_option("-p", "--password",
                      action="store",
                      help="The clear-text password to pass to the function "
                            "(only for the 'change' command)")

    parser.add_option("-m", "--password-matched",
                      action="store_false", default=True,
                      help="Used to specify the password does NOT match (ie, "
                           "uses False for the PasswordMatch/PasswordMatched "
                           "arg, both 'auth' and 'change' commands)")

    parser.add_option("-s", "--server",
                      action="store",
                      help="The name of the server to execute the command on")

    parser.add_option("-f", "--show_fields",
                      action="store_true", default=False,
                      help="Print the NET_VALIDATE_PERSISTED_FIELDS returned")

    options, args = parser.parse_args()

    if not args:
        args = ["auth"]

    for arg in args:
        if arg == "auth":
            input = {"PasswordMatched": options.password_matched,
                     }
            val_type = win32netcon.NetValidateAuthentication
        elif arg == "change":
            input = {"ClearPassword": options.password,
                     "PasswordMatch": options.password_matched,
                     "UserAccountName": options.username,
                     }
            val_type = win32netcon.NetValidatePasswordChange
        else:
            parser.error("Invalid arg - must be 'auth' or 'change'")

        try:
            fields, status = win32net.NetValidatePasswordPolicy(options.server,
                                                         None, val_type, input)
        except NotImplementedError:
            print "NetValidatePasswordPolicy not implemented on this platform."
            return 1
        except win32net.error, exc:
            print "NetValidatePasswordPolicy failed: ", exc
            return 1

        if options.show_fields:
            print "NET_VALIDATE_PERSISTED_FIELDS fields:"
            pprint(fields)

        print "Result of %r validation is %d: %s" % \
                    (arg, status, win32api.FormatMessage(status).strip())

    return 0

Example 2

View license
def main():
    parser = optparse.OptionParser("%prog [options] auth|change ...",
                                   description="A win32net.NetValidatePasswordPolicy demo.")

    parser.add_option("-u", "--username",
                      action="store",
                      help="The username to pass to the function (only for the "
                           "change command")

    parser.add_option("-p", "--password",
                      action="store",
                      help="The clear-text password to pass to the function "
                            "(only for the 'change' command)")

    parser.add_option("-m", "--password-matched",
                      action="store_false", default=True,
                      help="Used to specify the password does NOT match (ie, "
                           "uses False for the PasswordMatch/PasswordMatched "
                           "arg, both 'auth' and 'change' commands)")

    parser.add_option("-s", "--server",
                      action="store",
                      help="The name of the server to execute the command on")

    parser.add_option("-f", "--show_fields",
                      action="store_true", default=False,
                      help="Print the NET_VALIDATE_PERSISTED_FIELDS returned")

    options, args = parser.parse_args()

    if not args:
        args = ["auth"]

    for arg in args:
        if arg == "auth":
            input = {"PasswordMatched": options.password_matched,
                     }
            val_type = win32netcon.NetValidateAuthentication
        elif arg == "change":
            input = {"ClearPassword": options.password,
                     "PasswordMatch": options.password_matched,
                     "UserAccountName": options.username,
                     }
            val_type = win32netcon.NetValidatePasswordChange
        else:
            parser.error("Invalid arg - must be 'auth' or 'change'")

        try:
            fields, status = win32net.NetValidatePasswordPolicy(options.server,
                                                         None, val_type, input)
        except NotImplementedError:
            print("NetValidatePasswordPolicy not implemented on this platform.")
            return 1
        except win32net.error as exc:
            print("NetValidatePasswordPolicy failed: ", exc)
            return 1

        if options.show_fields:
            print("NET_VALIDATE_PERSISTED_FIELDS fields:")
            pprint(fields)

        print("Result of %r validation is %d: %s" % \
                    (arg, status, win32api.FormatMessage(status).strip()))

    return 0