VB6 NT challenge

Posted on 2003-04-01
Medium Priority
Last Modified: 2010-04-07
I need some simple code for a vb6 app that a user will enter their NT name and Password.
and I need a true if the user and password is valid and false if not valid.

They will be on a NT4 or 2000
Question by:LeeHopkins
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
LVL 10

Accepted Solution

aeklund earned 750 total points
ID: 8247851
This should be EXACTLY what your looking for:

Expert Comment

ID: 8247961
You need to declare the appropriate API and just call the function. It's a simple as that:

Here's the declaration (usually you stick these in a module):

Public Declare Function LogonUser _
        Lib "kernel32" 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

Once you have that you can code,

Dim lLngReturn as long
lLngReturn = LogonUser( "username", "password"....

The rest of the details you can get from

Once you go there, you'll probably find it's a bit complicated, but it's not *too* scary. You can use the API viewer addin that comes with VB to find the values of the appropriate constants mentioned in the help pages: e.g.

Public Const LOGON32_LOGON_BATCH = 4
Public Const LOGON32_LOGON_SERVICE = 5
Public Const LOGON32_PROVIDER_WINNT35 = 1

Good luck

Author Comment

ID: 8257023

This info talks about changing the logon of the computer to the net work. I am just trying to validate that a user is who they say they are not really connect to the net work

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!

LVL 10

Expert Comment

ID: 8257062
Did you try the example I posted?  It does just that, it only verifies that the user get's authenticated and does not log that use on.

Expert Comment

ID: 8263921
We could get into a whole discussion here about what "logging on" means. Generally it means that you identify yourself to an authenticating authority - perhaps a domain controller. If you're not connected to the network, then you could use local accounts on the machine and connect to that.

The point is that if you want to know whether their password is valid, you have to log on. It is possible to determine whether the account exists without logging on, but then you don't know whether the password is correct.

The link given by aeklund does show some techniques for doing both these things (across a network), but all you really need to do is call LogonUser.

Expert Comment

ID: 8531183
Hi LeeHopkins,
This old question (QID 20570499) needs to be finalized -- accept an answer, split points, or get a refund.  Please see http://www.cityofangels.com/Experts/Closing.htm for information and options.

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

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.
This article describes how to use a set of graphical playing cards to create a Draw Poker game in Excel or VB6.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses
Course of the Month14 days, 5 hours left to enroll

800 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