If you are using Access 2000 and ADO then paste this function into the standard module and run it.
Function JetSecurity()
'-- set reference to ADOX library
'- Microsoft ADO Ext. 2.6 for DDL and Security
'-- Microsoft ActiveX data objects 2.6 library also needed for ADO
Dim cg As New ADOX.Catalog
Set cg.ActiveConnection = CurrentProject.Connection
Dim ur As User, gp As Group
For Each ur In cg.Users
Debug.Print "Users = "; ur.Name
For Each gp In ur.Groups
Debug.Print " Group = "; gp.Name
And just another way. Give it a username and a groupname and you will get a boolean response. This doesn't user ADOX but relies solely on Access.
Public Function UserIsMemberOfGroup(strUsr As String, strGrp As String) As Boolean
' This function determines the groups the current user is assigned
' and returns true if the user is a member of the group being
' tested by the parameter strGrp
' Parameters:
' strUsr is a string value for the user to test
' strGrp is a string value for a valid group
Dim wsp As DAO.Workspace
Dim DBS As DAO.Database
Dim usr As User
Dim grp As Group
Dim strGrps As String
On Error GoTo HandleErr
' Return reference to default workspace.
Set wsp = DBEngine.Workspaces(0)
' Return reference to current database.
Set DBS = CurrentDb
' Set User object to the CurrentUser
Set usr = wsp.Users(strUsr)
For Each grp In usr.Groups
If grp.Name = strGrp Then
UserIsMemberOfGroup = True
GoTo Proc_Exit
End If
DocSkip:
Next grp
Proc_Exit:
Set wsp = Nothing
Set DBS = Nothing
Set usr = Nothing
Set grp = Nothing
Exit Function
HandleErr:
Select Case Err.Number
Case Else
Call HandleTheError("basPermissions", "UserIsMemberOfGroup", Err, ShowMsg)
End Select
Resume Proc_Exit
Resume
End Function
----------------------
scking@arinc.com
Life is filled with lessons.
We are responsible for the
results of the quizzes.
-----------------------
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.