How to identify groups with database level permissions

G

Guest

I have found hundreds of lines of code posted all over the internet
for determining object level permissions (Forms, Queries, Tables, etc...)
What about the database itself? Will somebody link or paste an example
of a simple routine that returns all of the group names that have permission
to open a specific database.
 
J

Joan Wild

Tools, Documenter, Current Database tab...Properties will list the users and
the groups with permissions.
or
Dim wrk As DAO.Workspace
Dim db As DAO.Database
Dim usr As DAO.User
Dim grp As DAO.Group
Dim doc As DAO.Document

Set wrk = DBEngine.Workspaces(0)
Set db = CurrentDb()
Set doc = db.Containers("Databases").Documents("MSysDB")
For Each grp In wrk.Groups
Debug.Print grp.Name & "-" & doc.Permissions
Next grp
For Each usr In wrk.Users
Debug.Print usr.Name & "-" & doc.Permissions
Next usr
 
G

Guest

Hello Joan,
thanks for the response the sample you have here is almost exactly what I am
using except that I am filtering on two groups "Admins" and "Administrators".
So one with full permissions to the database and one with none and the funny
thing about it all is that I get the exact same answer for both... I am
thinking that I should see something different. Do you know how to process
these numbers?
_________________
Group: Administrators
Document: MSysDb
Container: Databases
Permissions: 393230
All Perm: 393230
_________________
Group: Admins
Document: MSysDb
Container: Databases
Permissions: 393230
All Perm: 393230
_________________
 
J

Joan Wild

Why do you think that one has no permissions and the other has full? The
two groups have the same permissions.
 
G

Guest

If you go into Security and look at Groups I have the Admins group with all
permissions available for Database and I have the administrators group with
no permissions available for Database and this is what I want to see returned
in the results but as you can see it is not... Any thoughts on this?
 
J

Joan Wild

Sorry missing some code; it is using the currentuser for the doc.permissions
property; change to

For Each grp In wrk.Groups
doc.UserName = grp.Name
Debug.Print grp.Name & "-" & doc.Permissions
Next grp
For Each usr In wrk.Users
doc.UserName = usr.Name
Debug.Print usr.Name & "-" & doc.Permissions
Next usr
 
G

Guest

That was the ticket! Thanks so much I have spent way too much time trying to
figure that one out! You are awsome!
 

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