?
Solved

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

Posted on 2010-09-14
1
Medium Priority
?
1,024 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
ID: 33677258
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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Windows Explorer lets you open cabinet (cab) files like any other folder. In VBA you can easily handle normal files and folders, but opening and indeed creating cabinet files takes a lot more - and that's you'll find here.
The first step to building an amazing About page is to figure out what you want the page to say about your company. You then must grab the attention of the reader, boast a bit, tell a story and let others brag about you. With a little bit of thought…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …
Suggested Courses

840 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