Security based on the current user

Christopherusly

Village Idiot.
Local time
Today, 01:45
Joined
Jan 16, 2005
Messages
81
Having had a read through the various security options availble to me when looking to secure my database, talks with the users move towards using a system which is based on the current logged on machine user, rather than requiring a user name and password combination.

I would have three levels of access, Administration // Manager // User.

Is there anyway i can set access rights to the forms // tables dependent upon the current logged in machine user.

Whilst i see that this in essence is not the most secure way to go, it has some benefit given that offices are locked when not occupied by the owner.

Any suggestion ? :confused:
 
You can pick up the users LoginName by using

Code:
Environ("UserName")

Col
 
Chris, just so you know... this is not the machine name. Essentially this is the same thing as the UserName/Password ability without the user knowing.

If you wanna get the machine name go here:
http://www.mvps.org/access/api/api0062.htm

It's an access file that gets the username,machine name, and admin rights. You'll have to do some fishing through the code to get the piece you need about the machine name... but it's there if you want to put the effort in.


Additionally you might want to go here for some explanation:
http://www.p6c.com/TechnicalArticles/WBHowTo_Call_Windows_API_Functions.html
 
Last edited:
Here's the code you put in a module to actually call the computer name:
Code:
Private Declare Function GetComputerName Lib "kernel32" _
    Alias "GetComputerNameA" _
    (ByVal lpBuffer As String, nSize As Long) As Long


Function ReturnComputerName() As String
Dim rString As String * 255, sLen As Long, tString As String
    tString = ""
    On Error Resume Next
    sLen = GetComputerName(rString, 255)
    sLen = InStr(1, rString, Chr(0))
    If sLen > 0 Then
        tString = Left(rString, sLen - 1)
    Else
        tString = rString
    End If
    On Error GoTo 0
    ReturnComputerName = UCase(Trim(tString))
End Function

To actually get it... just call it with ReturnComputerName from anywhere you need it.
 
Last edited:

Users who are viewing this thread

Back
Top Bottom