LogonUser from advapi32.dll
Quote:
> Please help me!
> How should I call LogonUser from the advapi32.dll?
> How should I declare the function?
> In the program that I was trying to use it, seems to me that the
> DLL was found but the function was not in it.
> Thanks in advance!
The following is one of the networkig functions I posted in
microsoft.public.vb.winapi.network (if you browse that newsgroup, you got to click
File/Get More Msg item several times to get all my postings in early April.
Jeff Hong YAN
PS: This function requires the user has permission as part of the system. You or your
user may or may not have this permission. But if you do, this function should work
without any problem.
Hi all,
The following is the function I use to validate user logon on Windows NT domain. User
account should be global account.
This function is useful if you want to implement an integrated user logon with the
Windows NT domain.
I welcome any comments and suggestions.
Rgds
Jeff Hong YAN
Option Explicit
'Author: Jeff Hong YAN
'Date: 1/21/97
'Description: Validate user id and password on Windows NT domain.
'This function works on NT Workstation
'If you want to crack a user account, this function is a start.
Private Declare Function LogonUserA Lib "advapi32.dll" _
(ByVal lpszUsername As String, ByVal lpszDomain As String, _
ByVal lpszPassword As String, ByVal dwLogonType As Long, _
ByVal dwLogonProvider As Long, phToken As Long) As Long
'Logon type
Const LOGON32_LOGON_INTERACTIVE = 2
Const LOGON32_NETWORK = 3
Const LOGON32_LOGON_BATCH = 4
Const LOGON32_LOGON_SERVICE = 5
'Provider
Const LOGON32_PROVIDER_WINNT35 = 1
Const LOGON32_PROVIDER_DEFAULT = 0
Function ValidateLogon(UserID As String, Pass As String, sDomainName As String) As
Boolean
Dim sUserID As String
Dim sPass As String
Dim sDName As String
Dim hToken As Long
Dim lReturn As Long
sUserID = Trim$(UserID)
sPass = Trim$(Pass)
ValidateLogon = False
lReturn = LogonUserA(sUserID, sDomainName, sPass, LOGON32_NETWORK ,
LOGON32_PROVIDER_DEFAULT, hToken)
If lReturn = 1 Then
ValidateLogon = True
Exit For
End If
End Function