C
ceejay14
Guest
Hey everyone,
I’m a newbie to access security and it’s my first time posting, but I’ve been surfing around here for a while and I’ve learned a lot by visiting here. The database that I am currently working on has Access user-level security implemented with 3 user groups with permissions assigned: Admin, Read-only and Full Data Users.
My question is in regard to logging the database users in a table. I have already performed a search on this topic and was able to obtain success with this code
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, db As Database, r As Recordset
'rst As Recordset
'Dim table2 As String
Set db = CurrentDb
Set r = db.OpenRecordset("UserLog") 'Open the table User Log
strUserName = String$(254, 0)
lngLen = 255
lngX = apiGetUserName(strUserName, lngLen)
If lngX <> 0 Then
fOSUserName = Left$(strUserName, lngLen - 1)
Else
fOSUserName = ""
End If
r.AddNew
r.Fields("UserID") = UCase(fOSUserName)
r.Fields("EntryTime") = Now()
r.Update
My question is that opposed to logging the network log-in name of the user, is there a way to log the actual username of the user? For instance if I have a user called ‘ap01’ in my workgroup file can I have this name show in my UserLog table?
Whatever help you can provide would be great. Thank you
I’m a newbie to access security and it’s my first time posting, but I’ve been surfing around here for a while and I’ve learned a lot by visiting here. The database that I am currently working on has Access user-level security implemented with 3 user groups with permissions assigned: Admin, Read-only and Full Data Users.
My question is in regard to logging the database users in a table. I have already performed a search on this topic and was able to obtain success with this code
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, db As Database, r As Recordset
'rst As Recordset
'Dim table2 As String
Set db = CurrentDb
Set r = db.OpenRecordset("UserLog") 'Open the table User Log
strUserName = String$(254, 0)
lngLen = 255
lngX = apiGetUserName(strUserName, lngLen)
If lngX <> 0 Then
fOSUserName = Left$(strUserName, lngLen - 1)
Else
fOSUserName = ""
End If
r.AddNew
r.Fields("UserID") = UCase(fOSUserName)
r.Fields("EntryTime") = Now()
r.Update
My question is that opposed to logging the network log-in name of the user, is there a way to log the actual username of the user? For instance if I have a user called ‘ap01’ in my workgroup file can I have this name show in my UserLog table?
Whatever help you can provide would be great. Thank you