Hi All,
Has anyone got the LogonUser API to work successfully as a means to verify a
user's username and password? I have the following code which _should_
work, but doesn't=2E I read someone you need special privileges to use
LOGONUSER=2E
I have a feeling that this code will need to be compiled as a "service" or
something of that nature and reside on the server=2E My application would
then need to pass user credentials to this "service" in otder to verify
them=2E Can anyone give me some pointers on how I would do this?
This code currently resides on a client windows 2000 machine=2E=2E=2E
I found it on
http://www=2Einquiry=2Ecom/techtips/nt_pro/10_minute_solutions/10min0498=2Easp
Hope someone can help me!
Alastair=2E
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
' Constants used by LogonUser
Private Const LOGON32_PROVIDER_DEFAULT As Long =3D 0&
Private Const LOGON32_PROVIDER_WINNT35 As Long =3D 1&
Private Const LOGON32_LOGON_INTERACTIVE As Long =3D 2&
Private Const LOGON32_LOGON_NETWORK As Long =3D 3&
Private Const LOGON32_LOGON_BATCH As Long =3D 4&
Private Const LOGON32_LOGON_SERVICE As Long =3D 5&
Private Function VerifyPassword(ByVal xi_strUserID As String, _
ByVal xi_strPassword As String) As Boolean
On Error Resume Next ' Don't accept errors here
Dim p_lngToken As Long
Dim p_lngRtn As Long
p_lngRtn =3D LogonUser(lpszUsername:=3Dxi_strUserID, _
lpszDomain:=3D0&, _
lpszPassword:=3Dxi_strPassword, _
dwLogonType:=3DLOGON32_LOGON_NETWORK, _
dwLogonProvider:=3DLOGON32_PROVIDER_DEFAULT, _
phToken:=3Dp_lngToken)
If p_lngRtn =3D 0 Then
VerifyPassword =3D False
Else
VerifyPassword =3D True
End If
On Error GoTo 0
End Function