Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Network Login Authentication 2

Status
Not open for further replies.

Wantabie

Programmer
Apr 29, 2004
72
0
0
US
I was recently asked if it would be possible to use the Network domain username and password (Windows login) in Access 2000/Access 2002/Access 2003? If so, How would this be occomplished?

Basiclly, i want to take the Windows Login (Domain) username and password and implement it into an Access application. Is this possible? If so, How?
 
Public TheComputerName As String
Public TheUserDomain As String
Public TheUserName As String

Sub UserLogging ()
Dim objWscript As Object
Set objWscript = CreateObject("Wscript.Network")
TheComputerName = objWscript.ComputerName
TheUserDomain = objWscript.UserDomain
TheUserName = objWscript.UserName
Set objWscript = Nothing
End Sub

I don't think that the password should be found for the user! And I don't think that someone would provide such code at Tek-Tips.-
 
You are probably right, I am not sure if this process is possible.

Let try explainign this way:

The database back-end is located on a shared Network drive. The front-end is located locally on the users workstation. Due to corporation policy. all network applications, need to have a seperate user authentication process. I was asked if it was possible to have the application authentication process coincide with users network login.

In other words, when the user tries to login into the application. The users name and pass is authenticated against the network doamin username and password. Is there a way to get the username and password to authenticate with the domain server?
 
Windows XP is the workstations OS. I believe that the domain is running over Win Server 2003 software.
 
I leave it to you to put together a nice logon form (with your OS you could use the CredUIPromptForCredentials API call to get some consistency with normal Windows logon prompts):
Code:
[blue]
Option Explicit

Private Declare Function LogonUser Lib "advapi32" Alias "LogonUserA" (ByVal lpszUsername As String, ByVal lpszDomain As String, ByVal lpszPassword As String, ByVal dwLogonType As Long, ByVal dwLogonProvider As Long, phToken As Long) As Long
Private Declare Function CloseHandle Lib "kernel32" (ByVal hObject As Long) As Long

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_PROVIDER_WINNT50 As Long = 3&

Private Const LOGON32_LOGON_NETWORK As Long = 3&
Private Const LOGON32_LOGON_BATCH As Long = 4&
Private Const LOGON32_LOGON_SERVICE As Long = 5&
'End AD security declarations

Public Function VerifyLogon(sUsername As String, sPassword As String, sDomain As String) As Boolean
  Dim p_lngToken As Long
  VerifyLogon = LogonUser(sUsername, sDomain, sPassword, LOGON32_LOGON_NETWORK, LOGON32_PROVIDER_DEFAULT, p_lngToken)
End Function[/blue]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top