Repository navigation
platform sdk partitions
Partitions organize entities in Security Center and control which users can access them. By assigning entities to partitions and granting users access to specific partitions, you control visibility and access throughout the system.
A partition is a container for entities. A user can see an entity when the user has access to at least one partition that contains the entity. An entity can belong to multiple partitions.
Partitions work together with privileges:
- Partition access determines which entities a user can see.
- Privileges determine what operations a user can perform on those entities.
For a user to modify a camera, they need both access to the camera's partition and the ModifyCameras privilege.
Use either the partition API or the entity API depending on which object you already have in scope.
Add an entity to a partition using the AddMember() method:
var partition = (Partition)engine.GetEntity(partitionGuid);
var camera = (Camera)engine.GetEntity(cameraGuid);
partition.AddMember(camera);Add an entity to a partition from the entity side:
var camera = (Camera)engine.GetEntity(cameraGuid);
camera.InsertIntoPartition(partitionGuid);Both approaches produce the same result. An entity can belong to multiple partitions.
Not all entity types support partition membership. Entity types like Camera, Alarm, Cardholder, Credential, and CustomEntity implement IPartitionSupport and can be added to or removed from partitions. Entity types like Server, Network, and Device do not support partition manipulation.
Unless you set DefaultEntityCreationPartitions, Security Center places new partition-supporting entities in the root partition (Partition.DefaultPartitionGuid). To place new entities in specific partitions instead, set this property on the engine:
// Set default partitions for the current Engine connection
engine.DefaultEntityCreationPartitions = new CreationPartitions(
salesPartitionGuid,
null,
null);
// New entities are automatically added to the default partitions
var camera = (Camera)engine.CreateEntity("Lobby Camera", EntityType.Camera);
// camera is now a member of salesPartitionGuidThis setting only applies to the current Engine connection. Each connection maintains its own default partitions.
The three-parameter constructor accepts up to three default partitions:
engine.DefaultEntityCreationPartitions = new CreationPartitions(
partition1Guid,
partition2Guid,
partition3Guid);Pass null only for trailing unused parameters. If you need to provide a collection of partition GUIDs, use the CreationPartitions(IEnumerable<Guid>) constructor.
Important
In partition-isolated deployments, such as Security Center SaaS (Classic), users often do not have access to the root partition. In those environments, set DefaultEntityCreationPartitions to one or more partitions the user can access before you create entities.
Setting DefaultEntityCreationPartitions throws SdkException with SdkError.UnsufficientPrivilege if the logged-on user cannot access any specified partition. Creating an entity also requires the add and view privileges for that entity type in each creation partition.
Removing membership uses the same two-sided API pattern as adding membership.
var partition = (Partition)engine.GetEntity(partitionGuid);
var camera = (Camera)engine.GetEntity(cameraGuid);
partition.RemoveMember(camera);var camera = (Camera)engine.GetEntity(cameraGuid);
camera.RemoveFromPartition(partitionGuid);To move an entity to a different partition, add it to the new partition before removing its previous memberships:
Camera camera = (Camera)engine.GetEntity(cameraGuid);
Guid[] previousPartitionGuids = camera.GetPartitions()
.Where(partitionGuid => partitionGuid != newPartitionGuid)
.ToArray();
camera.InsertIntoPartition(newPartitionGuid);
foreach (Guid previousPartitionGuid in previousPartitionGuids)
{
camera.RemoveFromPartition(previousPartitionGuid);
}These APIs let you inspect partition membership from either the partition or the entity side.
Retrieve the direct members of a partition:
Partition partition = (Partition)engine.GetEntity(partitionGuid);
ReadOnlyCollection<Guid> members = partition.Members;
foreach (Guid memberGuid in members)
{
Entity entity = engine.GetEntity(memberGuid);
Console.WriteLine(entity.Name);
}Retrieve the partitions to which an entity is directly assigned:
Camera camera = (Camera)engine.GetEntity(cameraGuid);
IEnumerable<Guid> partitions = camera.GetPartitions();
foreach (Guid partitionGuid in partitions)
{
Partition partition =
(Partition)engine.GetEntity(partitionGuid);
Console.WriteLine(partition.Name);
}Partition access controls who can see entities in a partition. Privileges still control what actions that person can perform.
Add a user or user group to a partition:
var partition = (Partition)engine.GetEntity(partitionGuid);
partition.AddUserAccess(userGuid);Users with partition access can see entities in that partition, subject to their privileges.
Remove a user or user group from a partition:
var partition = (Partition)engine.GetEntity(partitionGuid);
partition.RemoveUserAccess(userGuid);Get all users and user groups with access to a partition:
Partition partition = (Partition)engine.GetEntity(partitionGuid);
ReadOnlyCollection<Guid> userAccesses = partition.UserAccesses;
foreach (Guid userOrGroupGuid in userAccesses)
{
Entity userOrGroup = engine.GetEntity(userOrGroupGuid);
Console.WriteLine(userOrGroup.Name);
}This includes users with inherited access through the partition hierarchy.
Partitions can be organized in a hierarchy by adding partitions as members of other partitions.
var parentPartition = (Partition)engine.GetEntity(parentGuid);
var childPartition = (Partition)engine.GetEntity(childGuid);
parentPartition.AddMember(childPartition);When a user has access to a parent partition, child partitions inherit that access unless an access restriction is configured on a child partition. The user can see entities in the parent and accessible child partitions, subject to the user's privileges.
When an intermediate partition is deleted, its child partitions are automatically moved to the parent partition.
Partition exceptions allow you to override a user's global privilege setting within a specific partition. For example, you can grant a user ModifyCameras globally but deny it in a specific partition.
var partition = (Partition)engine.GetEntity(partitionGuid);
partition.CreateOrUpdatePartitionException(
userGuid,
SdkPrivilege.ModifyCameras,
PrivilegeAccess.Denied);Only PrivilegeAccess.Granted or PrivilegeAccess.Denied are valid. You cannot set an exception to Undefined.
var partition = (Partition)engine.GetEntity(partitionGuid);
partition.RemovePartitionException(userGuid, SdkPrivilege.ModifyCameras);GetPrivilegeExceptionPossibleStates returns the states that can be assigned. Because PrivilegeAccess is a flags enumeration, test for the required state before creating the exception:
Partition partition = (Partition)engine.GetEntity(partitionGuid);
PrivilegeAccess possibleStates =
partition.GetPrivilegeExceptionPossibleStates(
userGuid,
SdkPrivilege.ModifyCameras);
if ((possibleStates & PrivilegeAccess.Denied) != 0)
{
partition.CreateOrUpdatePartitionException(
userGuid,
SdkPrivilege.ModifyCameras,
PrivilegeAccess.Denied);
}- Only Entity privileges can have partition exceptions. Task privileges cannot.
- When you set an exception on a parent privilege, child privileges are also affected.
- You cannot create exceptions for administrator users.
- You cannot manage your own partition exceptions.
Grant a user read-only access to configuration in a partition:
var partition = (Partition)engine.GetEntity(partitionGuid);
partition.SetConfigurationPrivilegesPartitionExceptions(userGuid, isReadOnly: true);Partition exceptions specify a user's privileges for entities in a particular partition. Calling this method with isReadOnly: true sets the configuration-viewing exceptions to Granted and the configuration-modification exceptions to Denied, allowing read-only configuration access.
Calling it with isReadOnly: false sets both sets of exceptions to Granted. This does not undo the previous call. For example, a modification exception that was Denied before the first call becomes Granted, rather than returning to Denied. To restore the previous configuration, record the exceptions before calling this method and restore them afterwards.
Retrieve the current partition exceptions for a user:
var partition = (Partition)engine.GetEntity(partitionGuid);
ReadOnlyCollection<PrivilegeInformation> exceptions = partition.GetPartitionExceptions(userGuid);
foreach (var exception in exceptions)
{
Console.WriteLine($"{exception.PrivilegeGuid}: {exception.State}");
}You can also retrieve exceptions from the user side:
var user = (User)engine.GetEntity(userGuid);
ReadOnlyCollection<PrivilegeInformation> exceptions = user.GetPartitionExceptions(partitionGuid);Security Center has built-in system partitions that cannot be deleted:
| Partition | Description |
|---|---|
| Root partition | The default partition (Partition.DefaultPartitionGuid) |
| System partition | Public partition accessible by all users |
Administrator users and members of the Administrators user group bypass all partition restrictions. They can see and modify all entities regardless of partition membership.
var user = (User)engine.GetEntity(userGuid);
if (user.IsAdministrator)
{
// User has access to all partitions
}Because administrators bypass partition restrictions, you cannot limit their access with partition exceptions. CreateOrUpdatePartitionException, RemovePartitionException, and SetConfigurationPrivilegesPartitionExceptions throw SdkException with SdkError.InvalidOperation and make no change when the target is an administrator or the logged-on user.
Create a new partition using the Engine.CreateEntity() method:
var partition = (Partition)engine.CreateEntity("Sales Department", EntityType.Partition);After creating the partition, add users and entities as needed:
partition.AddUserAccess(salesManagerGuid);
partition.AddMember(lobbyCamera);- About privileges: Privilege types, states, and per-user privilege computation.
-
About entities: Entity model and
IPartitionSupport. -
About the Platform SDK: SDK assemblies and the
Engineclass.
- Overview
- Connecting to Security Center
- SDK certificates
- Referencing SDK assemblies
- ASP.NET hosting
- SDK compatibility
- Migrating to modern .NET
- Entities
- Entity cache
- Entity loading, cache, and query options
- Detecting entity changes
- Entity change event reference
- Transactions
- Security Center events
- Actions
- Security Desk
- Custom events
- Event-to-actions
- Managing macros
- ReportManager
- ReportManager query reference
- Access control raw events
- DownloadAllRelatedData and StrictResults
- Privileges
- Partitions
- Entity write restrictions
- About custom fields
- About video
- About cameras
- Enrolling a video unit
- Ingesting third-party video
- Archiver and auxiliary archiver roles
- Archive transfer
- About access control
- About cardholders and credentials
- About doors, areas, elevators, and access points
- About access rules and schedules
- About access control units and interface modules
- Enrolling an access control unit
- Door templates
- Visitors
- Mobile credentials
- About threat levels
- About alarms
- About incidents
- Maps
- Logging
- Overview
- Localization
- Certificates
- Lifecycle
- Threading
- State management
- Configuration
- Restricted configuration
- Events
- Queries
- Request manager
- Database
- Entity ownership
- Engine extensions
- Entity mappings
- Server management
- Custom privileges
- Custom entity types
- Resolving non-SDK assemblies
- Deploying plugins
- Modern .NET support
- Overview
- Localization
- Certificates
- Creating modules
- Tasks
- Pages
- Components
- Tile extensions
- Services
- Contextual actions
- Custom actions
- Options extensions
- Configuration pages
- Monitors
- Shared components
- Commands
- Extending events
- Map extensions
- Timeline providers
- Image extractors
- Credential encoders
- Credential readers
- Cardholder fields extractors
- Badge printers
- Content builders
- Dashboard widgets
- Incidents
- Logon providers
- Pinnable content builders
- Custom report pages
- Overview
- Getting started
- Media file formats
- MediaPlayer
- VideoSourceFilter
- MediaExporter
- MediaFile
- G64 converters
- FileCryptingManager
- PlaybackSequenceQuerier
- PlaybackStreamReader
- OverlayFactory
- PtzCoordinatesManager
- AudioTransmitter
- AudioRecorder
- AnalogMonitorController
- Camera blocking
- Overview
- Getting started
- Referencing entities
- Entity operations
- About access control in the Web SDK
- About video in the Web SDK
- Users and user groups
- Partitions
- Custom fields
- Custom card formats
- Actions
- Events and alarms
- Incidents
- Reports
- Tasks
- Macros
- Custom entity types
- System endpoints
- Performance guide
- Reference
- Endpoints
- Constants
- Enumerations
- Under the hood
- Troubleshooting