Solved

Using NT Login for application login in VBA (Access 2007 and Excel 2007)

Posted on 2010-09-14
1
983 Views
Last Modified: 2012-05-10
I have the need to test a users login credentials before letting them procede past a certain point in my appication. the reason that I need this is that my application needs to open up multiple site and other applications that use the NT username and password.
What I have been doing in the past, is to get user name and password, then then pass it to one of the websites and then see if login was successful, if not, then retest for login, if so continue.
This has been working ok in the past, but now I have the need to test before login in to the other sites as some people dont have access to the same set off websites. The application that require login are harder to testfor and again, differnt sets of application depending on the user.
Is there an API or something that will test against NT LOGIN credentials?
I am posting this in the web section as we since there must be a way for the websites to test for this as well.
Thanks
Bruce
0
Comment
Question by:Bruj
1 Comment
 

Accepted Solution

by:
Bruj earned 0 total points
Comment Utility
Resolving this myself! Here is how I am doing this:
Private Declare Function LogonUser _
                          Lib "Advapi32" Alias "LogonUserA" _
                              (ByVal lpszUsername As String, _
                               ByVal lpszDomain As Any, _
                               ByVal lpszPassword As String, _
                               ByVal dwLogonType As Long, _
                               ByVal dwLogonProvider As Long, _
                               phToken As Long) As Long

' Constants used by LogonUser
Private Const LOGON32_PROVIDER_DEFAULT As Long = 0&
Private Const LOGON32_PROVIDER_WINNT35 As Long = 1&
Private Const LOGON32_LOGON_INTERACTIVE As Long = 2&
Private Const LOGON32_LOGON_NETWORK As Long = 3&
Private Const LOGON32_LOGON_BATCH As Long = 4&
Private Const LOGON32_LOGON_SERVICE As Long = 5&
Sub testcallLogin()
    Dim strPassword As String
    Dim strUserID As String
    strUserID = "username"
    strPassword = "password"
    If LogMeIn(strUserID, strPassword) Then
        MsgBox ("your password is correct")
    Else
        MsgBox ("your password is incorrect")
     
    End If
End Sub


Function LogMeIn(ByVal strUserID As String, strPassword As String) As Boolean
On Error Resume Next
    Dim lngToken As Long

    p_lngRtn = LogonUser(strUserID, 0&, strPassword, LOGON32_LOGON_INTERACTIVE, LOGON32_PROVIDER_DEFAULT, lngToken)

    If p_lngRtn = 0 Then
        LogMeIn = False
    Else
        LogMeIn = True
    End If

    On Error GoTo 0
End Function
0

Featured Post

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Why do we like using grid based layouts in website design? Let's look at the live examples of websites and compare them to grid based WordPress themes.
I've been asked to discuss some of the UX activities that I'm using with my team. Here I will share some details about how we approach UX projects.
The view will learn how to download and install SIMTOOLS and FORMLIST into Excel, how to use SIMTOOLS to generate a Monte Carlo simulation of 30 sales calls, and how to calculate the conditional probability based on the results of the Monte Carlo …
The viewer will learn how to create a normally distributed random variable in Excel, use a normal distribution to simulate the return on an investment over a period of years, Create a Monte Carlo simulation using a normal random variable, and calcul…

744 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

16 Experts available now in Live!

Get 1:1 Help Now