Solved

Verify User in NT

Posted on 2000-04-13
7
208 Views
Last Modified: 2011-09-20
I need to write a program (in VB) which allows me to verify that a user is indeed a user in the NT PDC.

The user merely needs to provide a user name and password and my program will verify it from the list of NT users in a particular domain.
0
Comment
Question by:idleworm
7 Comments
 
LVL 28

Expert Comment

by:AzraSound
ID: 2710881
Public Declare Function NetLocalGroupGetMembers Lib "netapi32.dll" (ByVal psServer As Long, ByVal psLocalGroup As Long, ByVal lLevel As Long, pBuffer As Long, ByVal lMaxLength As Long, plEntriesRead As Long, plTotalEntries As Long, phResume As Long) As Long



info about this function:
http://msdn.microsoft.com/library/psdk/network/ntlmapi2_9zw3.htm


are you looking for something like this?
0
 
LVL 28

Expert Comment

by:AzraSound
ID: 2710900
http://www.mvps.org/vb/code/NetUser.zip
good sample application that shows how to use the various calls to the netapi32.dll
you can decide which one would best suit your needs to implement your task since you have several options to choose from.
0
 
LVL 1

Author Comment

by:idleworm
ID: 2710935
Thanx AzraSound although not what I exactly wanted...

All I need is to do is to verify whether the user (coming in) is indeed a valid user in the domain (given a User Name and Password). Assuming a user need to log On to my Exchange Server
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 28

Expert Comment

by:AzraSound
ID: 2710973
so you already have coded all the available users on the domain?  then just perform check on what the user enters.  check the users username and if it is found in your list use the netusergetinfo to check whether the password is valid.

0
 
LVL 1

Author Comment

by:idleworm
ID: 2710996
Will check it out & let u know...
0
 
LVL 1

Accepted Solution

by:
Gotcha007 earned 100 total points
ID: 2711364
Hello , go to this URL
http://www.netfokus.dk/vbadmincode/
and choose WindowsNt in the top Menu.
Then choose User/group.
There are that's you want (like account).

0
 
LVL 1

Expert Comment

by:ATM
ID: 2714433
Here is simple method to do that:
Create
form1,
text1 - domain
text2 - user
text3 - pass
button1

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

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: " & GetLastError() & Err.LastDllError
Else
  If lToken = 0 Then
   MsgBox "Not Valid user, password or domain"
  Else
   MsgBox "Valid User"
  End If
End If
End Sub

Hope this help.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
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 process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…

863 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

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now