Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

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

Posted on 2010-09-14
1
Medium Priority
?
1,019 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

Plesk WordPress Toolkit

Plesk's WordPress Toolkit allows server administrators, resellers and customers to manage their WordPress instances, enabling a variety of development workflows for WordPress admins of all skill levels, from beginners to pros.

See why 2/3 of Plesk servers use it.

Question has a verified solution.

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

This article describes a serious pitfall that can happen when deleting shapes using VBA.
Without even knowing it, most of us are using web applications on a daily basis.  In fact, Gmail and Yahoo email, Twitter, Facebook, and eBay are used by most of us daily—and they are web applications. We generally confuse these web applications to…
The viewer will learn how to count occurrences of each item in an array.
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…

650 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