Determining If a User Belongs to a Specific Group

When determining if a user should have access to a particular object or function, you may need to determine whether the user belongs to a specific group. As with most other functions, this is also fairly easy; simply check if the name of the user exists in the group's Users collection, or if the group exists in the user's Groups collection.

Public Function IsUserInGroup (strUser As String, strGroup As String) As Boolean Dim wrk As DAO.Workspace Set wrk = DBEngine(0)

On Error Resume Next

IsUserInGroup = False

'Check in the Users --> Groups collection IsUserInGroup = _

(wrk.Users(strUser).Groups(strGroup).Name = strGroup)

'Check in the Groups --> Users collection

'IsUserInGroup = _


.Groups(strGroup).Users(strUser).Name =

= strUser)

Set wrk =


End Function

0 0

Post a comment