Permissions for Containers

You can directly set permissions for Container objects to control a user’s ability to create new objects of a given type. The dbSecCreate permission constant gives the user the ability to create an object in the container it’s associated with. Note that this permission is useful only in the context of Container objects. The following code shows you how to check to see if a user has permission to create an object in a given container. In this example, strWorkGroup is the path to the workgroup information file, strDbPath is the path to the database, strUser is the name of the user or group, and strContainer is the name of the container for which permissions are being checked:

Dim dbs As Database
Dim ctr As Container
    
' Specify the workgroup information file to use.
DBEngine.SystemDB = strWorkgroup
    
Set dbs = OpenDatabase(strDbPath)
Set ctr = dbs.Containers(strContainer)

' Specify the user account to check.
ctr.UserName = strUser
' Check whether the dbSecCreate permission is set.
If ctr.Permissions And dbSecCreate Then
	Debug.Print strUser & " can create " & strContainer & "."
Else
	Debug.Print strUser & " can't create " & strContainer & "."
End If
dbs.Close

Note that you can use the Inherit property in conjunction with the Permissions property to define what permissions new documents will have automatically when they’re created. If you set the Inherit property to True, and then set a permission on a container, then whenever a new document is created in that container, that permission will be set for the new document. This is a convenient way of presetting permissions on an object.

Setting the Inherit property will not affect existing documents in the container — you can’t modify all the permissions on all existing documents in a container by setting the Inherit property and a new permission. It will affect only new documents that are created after the Inherit property is set.