Jump to content

Recommended Posts

Posted

Seem to be correct code but it fails to change password:

#NoTrayIcon
#include <Array.au3>

Global $aRet = _NetUserChangePassword("User","user","qwerty")
_ArrayDisplay($aRet, "Debug")

Func _NetUserChangePassword($sUsername, $sOldPassword, $sNewPassword, $sServer = '')

    Local $aRet = DllCall("Netapi32.dll", "int", "NetUserChangePassword", _
            "wstr", $sServer, "wstr", $sUsername, "wstr", $sOldPassword, "wstr", $sNewPassword)
   ;If $aRet[0] Then Return SetError(1, $aRet[0], False)
    
    Return $aRet
EndFunc     ;_NetUserChangePassword

Any ideas how to correct this?

And maybe translate error codes that are returned from this function.

Posted (edited)

Try getting the last error after the function call. Maybe it's as simple as an access denied error. Does it work in another language?

_WinAPI_GetLastError()

Thanks for the tip.

Something like this?

#NoTrayIcon
#include <Array.au3>
#include <WinAPI.au3>

Global $aRet = _NetUserChangePassword("User","user","qwerty")
$Ret = _WinAPI_GetLastError()
MsgBox(64, "Debug", $Ret)
$Ret = _WinAPI_GetLastErrorMessage()
MsgBox(64, "Debug", $Ret)
_ArrayDisplay($aRet, "Debug")

Func _NetUserChangePassword($sUsername, $sOldPassword, $sNewPassword, $sServer = '')

    Local $aRet = DllCall("Netapi32.dll", "int", "NetUserChangePassword", _
            "wstr", $sServer, "wstr", $sUsername, "wstr", $sOldPassword, "wstr", $sNewPassword)
  ;If $aRet[0] Then Return SetError(1, $aRet[0], False)
    
    Return $aRet
EndFunc ;_NetUserChangePassword

Function returns operation successful but, password stays the same.

What I am doing wrong?

Help me!

Edited by Ghost1987

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...