Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Using LogonUser
Message
 
To
21/11/2001 01:36:07
General information
Forum:
Visual Basic
Category:
Windows API functions
Title:
Miscellaneous
Thread ID:
00584333
Message ID:
00584342
Views:
35
Hi,
Here the sample of logging as another user:
Private Const LOGON32_PROVIDER_DEFAULT = 0&
Private Const LOGON32_PROVIDER_WINNT35 = 1&
Private Const LOGON32_LOGON_INTERACTIVE = 2&
Private Const LOGON32_LOGON_NETWORK = 3&
Private Const LOGON32_LOGON_BATCH = 4&
Private Const LOGON32_LOGON_SERVICE = 5&

Private Declare Function LogonUser Lib "Advapi32" _
    Alias "LogonUserA" (ByVal lpszUserName As String, _
    ByVal lpszDomain As Any, ByVal lpszPassword As String, _
    ByVal dwLogonType As Long, ByVal dwLogonProvider As Long, _
    phToken As Long) As Long
Private Declare Function ImpersonateLoggedOnUser Lib "advapi32" _
    (ByVal hToken As Long) As Long
Private Declare Function CloseHandle Lib "kernel32" _
    (ByVal hObject As Long) As Long

Public Function Login(ByVal strUserName As String, _
    ByVal strPassword As String) As Boolean
Dim lngToken As Long, lngRetValue As Long
Dim bolImpersonate As boolean

lngRetValue = LogonUser(strUserName, 0&, strPassword, _
    LOGON32_LOGON_NETWORK, LOGON32_PROVIDER_DEFAULT, lngToken)
If lngRetValue = 0 Then 
    Login = False
Else
    bolImpersonate = ImpersonateLoggedOnUser(lngToken)
    lngRetValue = CloseHandle(lngToken)
    If bolImpersonate Then
        Login = True
    Else
        Login = False
    End If
End If
End Function
> Can someone give me some examples on the usage of the LogOnUser method of the windows api function of kernel32.dll.
>
>I have been trying to use, but was ending up with some fatal errors, like dll entry point not found etc.,
Previous
Reply
Map
View

Click here to load this message in the networking platform