User-Level Security

accessman2

Registered User.
Local time
Today, 14:42
Joined
Sep 15, 2005
Messages
335
I have a question of the user-level security.

I setup the user-level security in MS Access, there are many users.

I want to write the code to find which users are Administrator.

Do we have function to check the user's permission?

eg.
user1: Administrator
user2: full permission
user3: backup operator


Thanks.
 
I am sure this must have been answered before on here, but heres a function called CurrentUserGroup() that returns the current users group (does exactly what is says on the tin!)


Public Function CurrentUserGroup() As String
Dim MyWorkSpace As Workspace
Dim i As Integer
Dim nGroupCount As Integer
Dim MyGroup As Group, MyUser As User

On Error GoTo err_CurrentUserInGroup

Set MyWorkSpace = DBEngine.Workspaces(0)

For nGroupCount = 0 To MyWorkSpace.Groups.Count - 1
Set MyGroup = MyWorkSpace.Groups(nGroupCount)
Set MyUser = MyWorkSpace.Users(CurrentUser())
For i = 0 To MyGroup.Users.Count - 1
If MyGroup.Users(i).Name = MyUser.Name Then
CurrentUserGroup = MyWorkSpace.Groups(nGroupCount).Name
Exit Function
End If
Next i
Next nGroupCount

CurrentUserGroup = ""
MyWorkSpace.Close
Exit Function

err_CurrentUserInGroup:
If err = 3265 Then
MsgBox UCase(MyWorkSpace.Groups(nGroupCount).Name) & " isn't a valid group name", 16, "Error"
CurrentUserGroup = ""
ElseIf err = 3029 Then
MsgBox "The account used to create the workspace does not exist"
Else: MsgBox Error(err)
End If

MyWorkSpace.Close
Exit Function
End Function
 

Users who are viewing this thread

Back
Top Bottom