Setting Permissions

Setting object permissions is similar to setting any other property, but it is worth mentioning that you can not only set the property, but can also simultaneously set multiple permissions, and add or remove one or more permissions.

To explicitly set the permissions for an object, you simply assign the permission to the object's Permission property. For example, to assign the permission for the current user to delete data from Tablel:

Set doc = dbs.Containers!Tables.Documents!Table1 doc.Permissions = dbSecInsertData Or dbSecDeleteData

To add a permission to an object's existing permissions, you use the bitwise Or operator with the existing permissions. For example, to add permission for the current user to delete data from Tablel:

Set doc = dbs.Containers!Tables.Documents!Table1 doc.Permissions = doc.Permissions Or dbSecInsertData

To remove one or more permissions from the object's existing permissions, you make use of the And Not operators. For example, to remove two permissions from Tablel; the ability to modify and delete data:

Set doc = dbs.Containers!Tables.Documents!Table1 doc.permissions = doc.Permissions And Not ( _ dbSecReplaceData Or dbSecDeleteData)

0 0

Post a comment