List of Groups

P

Paul Overway

Sample code follows...

Function IsInGroup(UserName As String, GroupName As String) As Boolean

Dim wrk As Workspace
Dim strTemp As String

On Error Resume Next

Set wrk = DBEngine(0)

strTemp = wrk.Groups(GroupName).Users(UserName).name

IsInGroup = (Err.Number = 0)

End Function

Sub ListUserGroups(UserName As String)

Dim wrk As Workspace
Dim grp As Group

Set wrk = DBEngine(0)

For Each grp In wrk.Groups
If IsInGroup(UserName, grp.name) Then Debug.Print grp.name
Next

End Sub
 
J

Jeff Conrad

Directly from the Security FAQ:

List Groups User is a member of:
Function faq_ListGroupsOfUser (strUserName As String)
Dim ws As WorkSpace
Dim usr As User
Dim i As Integer

Set ws = DBEngine.Workspaces(0)
Set usr = ws.Users(strUserName)
For i = 0 To usr.Groups.count - 1
Debug.Print usr.Groups(i).Name
Next i
End Function
 
Z

Zaima

Thanks Paul!
Have a good day!

Paul Overway said:
Sample code follows...

Function IsInGroup(UserName As String, GroupName As String) As Boolean

Dim wrk As Workspace
Dim strTemp As String

On Error Resume Next

Set wrk = DBEngine(0)

strTemp = wrk.Groups(GroupName).Users(UserName).name

IsInGroup = (Err.Number = 0)

End Function

Sub ListUserGroups(UserName As String)

Dim wrk As Workspace
Dim grp As Group

Set wrk = DBEngine(0)

For Each grp In wrk.Groups
If IsInGroup(UserName, grp.name) Then Debug.Print grp.name
Next

End Sub
 
Z

Zaima

Thanks a lot, Jeff!


Jeff Conrad said:
Directly from the Security FAQ:

List Groups User is a member of:
Function faq_ListGroupsOfUser (strUserName As String)
Dim ws As WorkSpace
Dim usr As User
Dim i As Integer

Set ws = DBEngine.Workspaces(0)
Set usr = ws.Users(strUserName)
For i = 0 To usr.Groups.count - 1
Debug.Print usr.Groups(i).Name
Next i
End Function
 
L

Levans digital

How Can I this example to output a list of users/groups to a form or more
desireable in a query ot table
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top