Determining group a logged on user is a member of...

B

Brad Pears

I would like to know if a user is a member of a particular group. Based on
this I will enable some controls.... How does one obtain the groups one
belongs to? Is that in the system tables?

Brad
 
A

Allen Browne

Function IsUserInGroup(strUser As String, strGroup As String) As Boolean
'Returns True if the user is in the group.
'Example: IsUserInGroup(CurrentUser(), "Admins")
Dim wk As Workspace
Dim grx As Groups
Dim grp As Group
Dim usx As Users
Dim usr As User

Set grx = DBEngine(0).Groups
For Each grp In grx
If grp.Name = strGroup Then
Set usx = grp.Users
For Each usr In usx
If usr.Name = strUser Then
IsUserInGroup = True
Exit For
End If
Next
End If
Next

Set usr = Nothing
Set usx = Nothing
Set grp = Nothing
Set grx = Nothing
End Function
 
B

Brad Pears

Excellent, thanks for that...

How about allowing a user to add new users (in the Access system tables) and
assign them to the Access groups within your own app instead of using the
built-in Access security options?

I am removing most toolbar and menubar items from this app - including the
ability to change security items (except for myself of course) - BUT need to
make sure they can add users and assign them to the proper security group -
as I am not around to be able to do this for them (they are a client).

Is this do-able?

Thanks,

Brad
 
A

Allen Browne

Yes, you can programmatically create groups and users add manage them using
the objects as referred to in the code example.
 
B

Brad Pears

One last question on this topic.... and I'm sure it can be done...

What would the calls be to allow a user to change their password from my app
instead of using Access security Users and Groups to do so??

Thanks,

Brad
 
Top