by Adam Rogerson (1 Submission)
Category: Windows System Services
Compatability: Visual Basic 5.0
Difficulty: Unknown Difficulty
Originally Published: Fri 12th February 1999
Date Added: Mon 8th February 2021
Rating: (1 Votes)
This code demostrates how to validate a user in a VB application against the NT domain. The purpose of this application is to allow an
API Declarations
'To set this privilege:
'Load User Manager
'Choose "User Rights" from the "Policies" menu.
'Click "Show Advanced User Rights".
'Choose "Act as part of the operating system" from the "Right" combo box
'Grant this privilege to the user or group that will be used to run the application. (i.e. on my workstation, I gave my user Id this Right)
'Logoff and back into NT to obtain the new NT security token.
Option Explicit
Public Const LOGON32_LOGON_INTERACTIVE = 2
Public Const LOGON32_LOGON_BATCH = 4
Public Const LOGON32_LOGON_SERVICE = 5
Public Const LOGON32_PROVIDER_DEFAULT = 0
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
Declare Function CloseHandle Lib "kernel32" _
(ByVal hObject As Long) As Long
'and domain (txtdomain)
'Add a login button to the form and add the following code to the click event
Private Sub cmdlogin_Click()
Dim lStatus As Long
Dim TokenHandle As Long
lStatus = LogonUser(txtuser.Text, txtdomain.Text, txtpassword.Text, LOGON32_LOGON_INTERACTIVE, LOGON32_PROVIDER_DEFAULT, TokenHandle)
If lStatus Then
lStatus = CloseHandle(TokenHandle)
MsgBox "Login Successful", , "Valid User"
Else
MsgBox "Login Failed", , "Invalid User/Password"
End If
End Sub
No comments have been posted about This code demostrates how to validate a user in a VB application against the NT domain. The purpose. Why not be the first to post a comment about This code demostrates how to validate a user in a VB application against the NT domain. The purpose.