The access rights (permissions) associated with an object store control the level of access that users have to the objects within the object store.
In the following code examples, user CEMPAdmin is granted full control to work with documents in this object store. Granting full control means that the specified user is granted permission to connect to the object store, store objects, modify objects, and remove objects.
Java Example
// Set access rights.
public static void setAccessRights(
Domain domain,
String granteeName, // Example: "CEMPAdmin"
String objStoreName) // Example: "ObjectStore1"
{
final int ACCESS_REQUIRED = AccessRight.WRITE_ANY_OWNER.getValue() |
AccessRight.REMOVE_OBJECTS.getValue() | AccessRight.STORE_OBJECTS.getValue() |
AccessRight.CONNECT.getValue() | AccessRight.WRITE_ACL.getValue() |
AccessRight.READ_ACL.getValue() | AccessRight.MODIFY_OBJECTS.getValue();
// Create a new access permission object.
AccessPermission ap = Factory.AccessPermission.createInstance();
// Set access permissions.
ap.set_GranteeName(granteeName);
ap.set_AccessType(AccessType.ALLOW);
ap.set_AccessMask(new Integer(ACCESS_REQUIRED));
// Set and save the new permissions.
ObjectStore objStore = Factory.ObjectStore.fetchInstance(domain, objStoreName, null);
AccessPermissionList apl = objStore.get_Permissions();
apl.add(ap);
objStore.set_Permissions(apl);
objStore.save(RefreshMode.REFRESH);
}
C# Example
// Set access rights.
public static void SetAccessRights(
IDomain domain,
String granteeName, // Example: "CEMPAdmin"
String objStoreName) // Example: "ObjectStore1"
{
const int ACCESS_REQUIRED = (int)AccessRight.WRITE_ANY_OWNER |
(int)AccessRight.REMOVE_OBJECTS | (int)AccessRight.STORE_OBJECTS |
(int)AccessRight.CONNECT | (int)AccessRight.WRITE_ACL |
(int)AccessRight.READ_ACL | (int)AccessRight.MODIFY_OBJECTS;
// Create a new access permission object.
IAccessPermission ap = Factory.AccessPermission.CreateInstance();
// Set access permissions.
ap.GranteeName = granteeName;
ap.AccessType = AccessType.ALLOW;
ap.AccessMask = (Int32)ACCESS_REQUIRED;
// Set and save the new permissions.
IObjectStore objStore = Factory.ObjectStore.FetchInstance(domain, objStoreName, null);
objStore.Permissions.Add(ap);
objStore.Save(RefreshMode.REFRESH);
}