Sign in to follow this  
Followers 0
Ghost1987

NetUserChangePassword()

4 posts in this topic

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.

Share this post


Link to post
Share on other sites



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()

Share this post


Link to post
Share on other sites

#3 ·  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

Share this post


Link to post
Share on other sites

After some googling I've found out that this function is buggy, so I'll try to use NetValidateName instead.

Thx for help.

Share this post


Link to post
Share on other sites

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
Sign in to follow this  
Followers 0