Ghost1987 Posted March 27, 2009 Share Posted March 27, 2009 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. Link to comment Share on other sites More sharing options...
jvanegmond Posted March 27, 2009 Share Posted March 27, 2009 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() github.com/jvanegmond Link to comment Share on other sites More sharing options...
Ghost1987 Posted March 27, 2009 Author Share Posted March 27, 2009 (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 March 27, 2009 by Ghost1987 Link to comment Share on other sites More sharing options...
Ghost1987 Posted March 27, 2009 Author Share Posted March 27, 2009 After some googling I've found out that this function is buggy, so I'll try to use NetValidateName instead. Thx for help. Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now