Solved

Validating a password

Posted on 1997-06-10
3
176 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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 200 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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
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…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

691 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