Solved

NT Security

Posted on 2000-04-08
4
192 Views
Last Modified: 2010-05-02
Does anyone know the API to check NT Security.
I want as input:
- UserID
- Password
- Domain

I want as return:
- True (if user has access)
- False (if user isn't allowed)
0
Comment
Question by:ndb
  • 2
4 Comments
 
LVL 28

Expert Comment

by:AzraSound
ID: 2696515
http://support.microsoft.com/support/kb/articles/q151/7/74.asp?FR=0

The USER_INFO_3 structure that the above link references holds most of that info youre looking for.  Heres more about the structure itself:


http://msdn.microsoft.com/library/psdk/network/ntlmapi3_0a5u.htm

0
 
LVL 1

Author Comment

by:ndb
ID: 2696658
An example would b nice ;0)
0
 

Accepted Solution

by:
bhuitema earned 50 total points
ID: 2697426
Try this:

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

Function CheckPwd(FUserName As String, FPassword As String, _
                     FDomain As String) As Boolean

Dim token As Long, status As Long
token = 0
status = LogonUser(FUserName, FDomain, FPassword, _
         LOGON32_LOGON_INTERACTIVE, _
         LOGON32_PROVIDER_DEFAULT, token)
   
If status = 0 Then
 CheckPwd = False
Else
 CheckPwd = True
 CloseHandle token
End If

End Function

Note that the account running this program needs to have the "Act as part of the operating system" policy set for it.
0
 
LVL 1

Author Comment

by:ndb
ID: 2697654
It seems that "Act as part of the operating system" is very important.
I had to relogon to get it working.
Thanx
0

Featured Post

Technology Partners: 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

Introduction I needed to skip over some file processing within a For...Next loop in some old production code and wished that VB (classic) had a statement that would drop down to the end of the current iteration, bypassing the statements that were c…
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 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…

740 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