Solved

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

Posted on 2010-09-14
1
989 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

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Issues with Windows Update and failing to boot - 2008 R2 18 77
Not seen Link button 5 37
Using jQuery to set a DIV attribute on page load 9 29
outlook 365  Desktop Alert 6 32
Know what services you can and cannot, should and should not combine on your server.
This article descibes how to create a connection between Excel and SAP and how to move data from Excel to SAP or the other way around.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
The viewer will learn how to  create a slide that will launch other presentations in Microsoft PowerPoint. In the finished slide, each item launches a new PowerPoint presentation and when each is finished it automatically comes back to this slide: …

815 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

8 Experts available now in Live!

Get 1:1 Help Now