DarkMatter Posted April 1, 2008 Share 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? 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] Link to comment Share on other sites More sharing options...
rasim Posted April 1, 2008 Share Posted April 1, 2008 In AutoIT bool type is int. Link to comment Share on other sites More sharing options...
DarkMatter Posted April 1, 2008 Author Share Posted April 1, 2008 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] Link to comment Share on other sites More sharing options...
Siao Posted April 1, 2008 Share Posted April 1, 2008 Type of last param should be "ptr*" "be smart, drink your wine" Link to comment Share on other sites More sharing options...
DarkMatter Posted April 1, 2008 Author Share Posted April 1, 2008 (edited) 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] Link to comment Share on other sites More sharing options...
Siao Posted April 1, 2008 Share 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" Link to comment Share on other sites More sharing options...
DarkMatter Posted April 1, 2008 Author Share 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] 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