DarkMatter Posted April 1, 2008 Posted April 1, 2008 (edited) Does anyone know how to use the LogonUser function in advapi32.dll? This is what I have right now Dim $RetCode Dim $tokenHandle $RetCode = DllCall("advapi32.dll", "bool", "LogonUser", "str", "UserName", "str", "Domain", "str", "Password", "dword", 2, "dword", 0, "ptr", $tokenHandle) The problem is @error is always 1. I have done some research on MSDN for the LogonUser function and that appears to be right, but if I open advapi32.dll in Dependency Walker there isn't a function called LogonUser within that DLL. But, for example, there is LogonUserEX, LogonUserW, LogonUserA. If I do a search for those on MSDN, it just returns "LogonUser". Not really sure what I am doing wrong for the call. Does anyone know? MSDN said: BOOL LogonUser( LPTSTR lpszUsername, LPTSTR lpszDomain, LPTSTR lpszPassword, DWORD dwLogonType, DWORD dwLogonProvider, PHANDLE phToken ); Edited April 1, 2008 by DarkMatter [sub]Quantum mechanics: The dreams stuff is made of[/sub]
DarkMatter Posted April 1, 2008 Author Posted April 1, 2008 rasim said: In AutoIT bool type is int. If I change $RetCode = DllCall("advapi32.dll", "bool", "LogonUser", "str", "USERNAME", "str", "DOMAIN", "str", "PASSWORD", "dword", 2, "dword", 0, "ptr", $tokenHandle) To $RetCode = DllCall("advapi32.dll", "int", "LogonUser", "str", "USERNAME", "str", "DOMAIN", "str", "PASSWORD", "dword", 2, "dword", 0, "ptr", $tokenHandle) AutoIT crashes... [sub]Quantum mechanics: The dreams stuff is made of[/sub]
Siao Posted April 1, 2008 Posted April 1, 2008 Type of last param should be "ptr*" "be smart, drink your wine"
DarkMatter Posted April 1, 2008 Author Posted April 1, 2008 (edited) Siao said: Type of last param should be "ptr*" I changed the last param to "ptr*" Dim $RetCode Dim $tokenHandle $RetCode = DllCall("advapi32.dll", "bool", "LogonUser", "str", "USERNAME", "str", "DOMAIN", "str", "PASSWORD", "dword", 2, "dword", 0, "ptr*", $tokenHandle) MsgBox(0,0,@error) @error is still equal to one and $RetCode is set to nothing. Edited April 1, 2008 by DarkMatter [sub]Quantum mechanics: The dreams stuff is made of[/sub]
Siao Posted April 1, 2008 Posted April 1, 2008 I assumed it's pretty obvious that what rasim said still applies and you should have no trouble incorporating both fixes. Apparently not...In any case, do yourself and everyone else a favor - read DllCall() reference in the helpfile very carefully. "be smart, drink your wine"
DarkMatter Posted April 1, 2008 Author Posted April 1, 2008 (edited) Got it thanks. Dim $RetCode Dim $tokenHandle $RetCode = DllCall("advapi32.dll", "int", "LogonUser", "str", "USERNAME", "str", "DOMAIN", "str", "PASSWORD", "dword", 2, "dword", 0, "ptr*", $tokenHandle) Edited April 1, 2008 by DarkMatter [sub]Quantum mechanics: The dreams stuff is made of[/sub]
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