Check for active workgroup file

ewong1

Eric Wong
Local time
Today, 11:34
Joined
Dec 4, 2004
Messages
96
I currently have a database set up that is run off of a shortcut linking to a specific workgroup file that I want my users on to create user level security. is there a way for me to check which file access is using to confirm that the correct workgroup file is being used?

I would like to set it up so that when the database opens, it looks for the active work group file, and if it is the correct workgroup file, continues, otherwise, if it is the incorrect file, the db will close.

Thanks for your help!
 
You can set or return the path to the system database using the "SystemDB" property of the "DBEngine" object.

Code:
MsgBox SystemDB
 
If they can get in without using the correct workgroup file, have you secured your database correctly and adequately ?
 
Anybody know how to get this help file provided function to work for a truely "secured" database?

Code:
Sub AllPermissionsX()

   ' Ensure that the Microsoft Jet workgroup information
   ' file is available.
   DBEngine.SystemDB = "system.mdw"

   Dim dbsNorthwind As Database
   Dim ctrLoop As Container

   Set dbsNorthwind = OpenDatabase("Northwind.mdb")

   ' Enumerate Containers collection and display the current
   ' user and the permissions set for that user.
   For Each ctrLoop In dbsNorthwind.Containers
      With ctrLoop
         Debug.Print "Container: " & .Name
         Debug.Print "User: " & .UserName
         Debug.Print "  Permissions: " & .Permissions
         Debug.Print "  AllPermissions: " & _
            .AllPermissions
      End With
   Next ctrLoop

   dbsNorthwind.Close

End Sub
 
Ewong1 - Access should refuse to open with out the correct username/password combination. You will not be able to run code to check it is right before logon as the DB is not open!


Ghudson - Do you want the code to run from inside or outside of the secure db?

Peter
 
Bat17 said:
Ghudson - Do you want the code to run from inside or outside of the secure db?

Peter
Both would be awesome if that is feasible. Thanks!
 
This works for me from within the secure enviroment

Sub AllPermissionsX()

Dim strPath As String
Dim db As Database
Dim ctrLoop As Container
Set db = CurrentDb
For Each ctrLoop In db.Containers
With ctrLoop
Debug.Print "Container: " & .Name
Debug.Print "User: " & .UserName
Debug.Print " Permissions: " & .Permissions
Debug.Print " AllPermissions: " & _
.AllPermissions
End With
Next ctrLoop
Set db = Nothing
End Sub

Now to have a play from outside :)

Peter
 
Thanks Peter. That works from the inside of a secured db. I have to question the "value" of the numeric value the code returns with the Permissions & AllPermissions options. I get a six or seven digit number that does not mean much to me. I was hoping it would show what permissions were assigned to each object.
 
Chapter 14 of "Access 97 Developer's Handbook, 3rd Edition" by Litwin, Getz and Gilbert is primarily devoted to programatically checking against and changing Access security.

More importantly, there is code included that contains functions related to your request. You could use this code, then simply go through the tables collection and check each individual right for each table in a nested loop. I stop short of adding the code to this post as it would be a copyright infringement :(

Specifically, you can read permissions of an object (table or otherwise) by checking the value of the Permissions or AllPermissions property of the object. (Assuming you have Administrator rights yourself.) Permissions will check individual permissions while AllPermissions will return the union of all permissions in one value. Both return a long integer.

ex: lngPermission = db.Containers!tables.Documents!tblorder.Permissions

Using AllPermissions, you could parse the returned long integer bit by bit via bit masking to determine all the rights for that object.

ex: canread = ((doc.Permissions And dbSecRetrieveData) = dbSecRetrieveData) returns true if read rights are available, false if not. (Doc is a document set to db.Containers!tables.Documents!tblCustomer)

There is quite a bit about it in the book and I will try to find time to read up on it.

in object browser you can find the security constants under DAD.PermissionEnum This will show you what is available.

I have never used bit masking and most of the above is copied from an old posting elsewhere :D S I have some heavy reading ahead

Peter
 
Out of luck since I do not have an Access 97 Developer's Handbook. Thanks for the info.
 

Users who are viewing this thread

Back
Top Bottom