Current Security Group

  • Thread starter Thread starter JF Bouthillier
  • Start date Start date
J

JF Bouthillier

Hi all,

I was wondering if there was an easy way to know the
security group of current user.

I know that CurrentUser returns the user but how do I
know his group?

Thank you so much.
JF
 
JF Bouthillier said:
Hi all,

I was wondering if there was an easy way to know the
security group of current user.

I know that CurrentUser returns the user but how do I
know his group?

A user can belong to multiple groups, so you can't just ask, "What group
does this user belong to?" You could conceivably ask for some sort of
list or array of groups, but most often what you want to know is, "Does
the current user belong to group X?". For that you can use a function
like this:

'----- start of code -----
Function fncUserIsInGroup(GroupName As String) As Boolean

' Returns True if the current user is a member of the specified
' security group; False if not, or if the group doesn't exist, or
' if an error occurs reading the groups.

Dim ws As Workspace

Set ws = DBEngine.Workspaces(0)

On Error Resume Next
fncUserIsInGroup = _
(ws.Users(CurrentUser).Groups(GroupName).Name = GroupName)

Set ws = Nothing

End Function
'----- end of code -----
 
Back
Top