Function GetSecurity()
On Error GoTo GetSecurity_Err
Dim MyUser As User, MyGroup As Group
Dim i As Integer, j As Integer
Rem Following is code culled from Access 2.0 help. It inanely creates
Rem and then deletes a fictitious user and group, but serves the purpose
Rem of effectively providing program visibility to MyUser.Groups(j).Name
Rem Full code is from "example" link from Users Object, Users Collection:
Rem "Group Object, Groups Collection; User Object, Users Collection Example"
' Create and append new user.
Set NewWorkspace = DBEngine.Workspaces(0)
Set MyUser = NewWorkspace.CreateUser("tempName", "abcd", "tmpPass")
NewWorkspace.Users.Append MyUser
' Create and append new group.
Set MyGroup = NewWorkspace.CreateGroup("tmpGroup", "tmpPassG")
NewWorkspace.Groups.Append MyGroup
' Add new user to new group
Set MyUser = NewWorkspace.CreateUser("tempName")
NewWorkspace.Groups![tmpGroup].Users.Append MyUser
'blow them away, because now we can see MyUser.Groups(j).Name
NewWorkspace.Users.Delete "tempName"
NewWorkspace.Groups.Delete "tmpGroup"
For i = 0 To NewWorkspace.Users.Count - 1
Set MyUser = NewWorkspace.Users(i)
For j = 0 To MyUser.Groups.Count - 1
If MyUser.Groups(j).Name <> "Users" And MyUser.Groups(j).Name <> "Guests" Then
MsgBox (MyUser.Name)
End If
Next j
Next i
GetSecurity_Exit:
NewWorkspace.Close
Exit Function
GetSecurity_Err:
MsgBox "Error: " + Error$
'Resume Next 'developmental plug
Resume GetSecurity_Exit
End Function
'don't forget to clean everything up - e.g. "= Nothing"