How do I use LogonUser (win32 api) together with vb.
The following is the problem, they are constants and how do I get those constants to work with VB?
DWORD dwLogonType, //
DWORD dwLogonProvider, //
Printable View
How do I use LogonUser (win32 api) together with vb.
The following is the problem, they are constants and how do I get those constants to work with VB?
DWORD dwLogonType, //
DWORD dwLogonProvider, //
use the API Viewer add-in to get those constants in VB syntax.
I did it for you:
Public Const LOGON32_LOGON_INTERACTIVE = 2
Public Const LOGON32_PROVIDER_WINNT35 = 1
Thanks! But why doesn't it work (login failed)??
the code is under a command_button in a form with nothing else...
the domain, pwd and user is correct (string type).
Dim TokenHandle as Long
Dim lstatus as Long
lstatus = LogonUser("user", "domain", "pwd", LOGON32_LOGON_INTERACTIVE,
LOGON32_PROVIDER_DEFAULT, TokenHandle)
If lstatus then
lstatus = CloseHandle(TokenHandle)
MsgBox "Login Successful"
else
MsgBox "Login Failed"
End If
always call FormatMessage and pass the err.lastDLLerror to get a readable description of the reason of your error