?
Solved

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

Posted on 2010-09-14
1
Medium Priority
?
1,011 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Get MySQL database support online, now!

At Percona’s web store you can order your MySQL database support needs in minutes. No hassles, no fuss, just pick and click. Pay online with a credit card.

Question has a verified solution.

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

Originally, this post was published on Monitis Blog, you can check it here . It goes without saying that technology has transformed society and the very nature of how we live, work, and communicate in ways that would’ve been incomprehensible 5 ye…
CTAs encourage people to do something specific to show interest in your company, product or service. Keep reading to learn why CTAs should always be thought of as extremely important, albeit small, sections of websites.
The viewer will get a basic understanding of what section 508 compliance can entail, learn about skip navigation links, alt text, transcripts, and font size controls.
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…
Suggested Courses

752 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