Using Domain User ID

  • Thread starter Thread starter Bryan
  • Start date Start date
B

Bryan

I have an access DB on a network. I want to only allow
users to access who are in my users table. I want the
application to look at their domain ID (bob123 for
example) and if that exists in my table allow them
access. Any ideas, I don't want to have to make users
login with a password...
 
I hope that this is what you want. The following code is in a module in my
database. It allows you to use "fOSUserName()" to get the network
login of the person. You could then compare to your table using code and a
form that opens automatically.

The user would be able to get around all this by holding down the shift key
and preventing your auto-open form from opening.

I always recommend using real Access security.

Rick B


Module code follows...





Option Compare Database
Option Explicit

Private Declare Function apiGetUserName Lib "advapi32.dll" Alias _
"GetUserNameA" (ByVal lpBuffer As String, nSize As Long) As Long

Function fOSUserName() As String
' Returns the network login name
Dim lngLen As Long, lngX As Long
Dim strUserName As String
strUserName = String$(254, 0)
lngLen = 255
lngX = apiGetUserName(strUserName, lngLen)
If lngX <> 0 Then
fOSUserName = Left$(strUserName, lngLen - 1)
Else
fOSUserName = ""
End If
End Function





I have an access DB on a network. I want to only allow
users to access who are in my users table. I want the
application to look at their domain ID (bob123 for
example) and if that exists in my table allow them
access. Any ideas, I don't want to have to make users
login with a password...
 
Shame on you for stripping out the copyright information.
http://www.mvps.org/access/api/api0008.htm
' This code was originally written by Dev Ashish.
' It is not to be altered or distributed,
' except as part of an application.
' You are free to use it in any application,
' provided the copyright notice is left unchanged.
'
' Code Courtesy of
' Dev Ashish
'
Private Declare Function apiGetUserName Lib "advapi32.dll" Alias _
"GetUserNameA" (ByVal lpBuffer As String, nSize As Long) As Long

Function fOSUserName() As String
' Returns the network login name
Dim lngLen As Long, lngX As Long
Dim strUserName As String
strUserName = String$(254, 0)
lngLen = 255
lngX = apiGetUserName(strUserName, lngLen)
If ( lngX > 0 ) Then
fOSUserName = Left$(strUserName, lngLen - 1)
Else
fOSUserName = vbNullString
End If
End Function
 
Oooh. When that code was passed onto me (many many moons ago) I guess that
was already stripped. Thanks for catching that Joan!!!

Sorry Dev!


Rick B

Shame on you for stripping out the copyright information.
http://www.mvps.org/access/api/api0008.htm
' This code was originally written by Dev Ashish.
' It is not to be altered or distributed,
' except as part of an application.
' You are free to use it in any application,
' provided the copyright notice is left unchanged.
'
' Code Courtesy of
' Dev Ashish
'
Private Declare Function apiGetUserName Lib "advapi32.dll" Alias _
"GetUserNameA" (ByVal lpBuffer As String, nSize As Long) As Long

Function fOSUserName() As String
' Returns the network login name
Dim lngLen As Long, lngX As Long
Dim strUserName As String
strUserName = String$(254, 0)
lngLen = 255
lngX = apiGetUserName(strUserName, lngLen)
If ( lngX > 0 ) Then
fOSUserName = Left$(strUserName, lngLen - 1)
Else
fOSUserName = vbNullString
End If
End Function
 
Back
Top