Search Tools Links Login

Test for domain/user/password combination.


Allow You to test Domain/User/Password combination ...

Original Author: ATM

Assumptions

Create form1,text1 - domain,text2 - user,text3 - password,command1.

API Declarations

Private Declare Function LogonUser Lib "advapi32" Alias "LogonUserA" (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
Private Declare Function GetLastError Lib "kernel32" () As Long
Private Const LOGON32_LOGON_BATCH = 4
Private Const LOGON32_PROVIDER_DEFAULT = 0

Code

Private Sub Command1_Click()
Dim szDomain As String
Dim szUser As String
Dim szPassword As String
Dim lToken As Long
Dim lResult As Long
szDomain = Text1.Text & Chr(0)
szUser = Text2.Text & Chr(0)
szPassword = Text3.Text & Chr(0)
lToken = 0&
lResult = LogonUser(szUser, _
       szDomain, _
       szPassword, _
       ByVal LOGON32_LOGON_BATCH, _
       ByVal LOGON32_PROVIDER_DEFAULT, _
       lToken)
If lResult = 0 Then
MsgBox "Error: " & Err.LastDllError
Else
If lToken = 0 Then
MsgBox "Not Valid user, password or domain"
Else
MsgBox "Valid User"
End If
End If
End Sub

About this post

Posted: 2002-06-01
By: ArchiveBot
Viewed: 91 times

Categories

Visual Basic 6

Attachments

No attachments for this post


Loading Comments ...

Comments

No comments have been added for this post.

You must be logged in to make a comment.