Click to See Complete Forum and Search --> : LogonUser
Johan A
July 22nd, 1999, 05:43 AM
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, //
Lothar Haensler
July 22nd, 1999, 06:13 AM
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
Johan A
July 22nd, 1999, 08:22 AM
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
Lothar Haensler
July 22nd, 1999, 11:38 AM
always call FormatMessage and pass the err.lastDLLerror to get a readable description of the reason of your error
codeguru.com
Copyright Internet.com Inc., All Rights Reserved.