[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Validating a password

Posted on 1997-06-10
3
Medium Priority
?
179 Views
Last Modified: 2008-03-06
Hello!

I would like to validate a password using VB 5.0 against either the
password you enter into Windows 95 or against the network. I can find out how to get the current user id - but not to validate the password!!!!

Thanks

David
0
Comment
Question by:denaumow
3 Comments
 
LVL 1

Expert Comment

by:ksleung
ID: 1427039
Due to the security, you will not know the password (encrypted or not) and you do not know the encryption methodology. Hence, you have to try to pass your password and id to the OS an let it do the validation. You have to have your handling routine for the incorrect password (the OS rejects your login).
0
 

Author Comment

by:denaumow
ID: 1427040
I know that you have to have the OS validate the password - butI cannot find a windows API Call to have the OS do the validation.  What/How do I get VB5 to ask the OS to validate a password? (thatis heart of the original question.)
0
 
LVL 5

Accepted Solution

by:
y96andha earned 400 total points
ID: 1427041
This is how to do a user validation. In order for this to work, the user account which runs the program must either be the SYSTEM account or an account with the SeTcbPrivilege - "Act as part of the operating system" user right.

The user account which is validated must have the appropriate privilege too, depending on whether you will use
LOGON32_LOGON_BATCH, LOGON32_LOGON_INTERACTIVE or LOGON32_LOGON_SERVICE.

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 CloseHandle Lib "kernel32" (ByVal hObject As Long) As Long
Private Declare Function GetLastError Lib "kernel32" () As Long
Private Const LOGON32_PROVIDER_DEFAULT = 0
Private Const LOGON32_LOGON_BATCH = 4
Private Const LOGON32_LOGON_INTERACTIVE = 2
Private Const LOGON32_LOGON_SERVICE = 5



Validation function:

Replace username, domain and password with the values to be verified. Use either LOGON32_LOGON_BATCH, LOGON32_LOGON_INTERACTIVE or LOGON32_LOGON_SERVICE. In this example I use LOGON32_LOGON_BATCH, which means that the user account which is being verified must have the "Logon as a batch job" user right.


Private Sub Command1_Click()
    Dim token As Long, status As Long
    token = 0
    status = LogonUser("username", "domain", "password", _
LOGON32_LOGON_BATCH, _
LOGON32_PROVIDER_DEFAULT, token)
    If status = 0 Then
    MsgBox "Logon Failed"
    Else
    MsgBox "Logon successful"
    CloseHandle token
    End If
End Sub

I have never tried this in Windows 95, though, only in NT.
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Suggested Courses

834 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question