Permissions client

The Permissions client lets you retrieve the permissions assigned to a specific entity for a given user. If no user is specified, the currently authenticated user is used. This client is useful when you need to verify access rights in scripts before taking further actions on entities.

Get entity permissions

Use GetPermissionsAsync to get the set of permissions for a user on a given entity. The method requires the ID of an existing entity. You can optionally specify a user ID. If the entity does not exist, the method returns an empty set.

RequestResponse
ISet<string> permissions = await MClient.Permissions.GetPermissionsAsync(<ENTITY_ID>);

To check permissions for a different user:

RequestResponse
ISet<string> permissions = await MClient.Permissions.GetPermissionsAsync(<ENTITY_ID>, <USER_ID>);

The returned set contains string representations of each permission granted. These permissions are calculated using the internal permission calculator service and take all applicable policies into account.

If the user ID is provided, the client fetches the user name and loads the full user entity before calculating permissions. If no user ID is provided, the client uses the current session user or falls back to the administrator account.

Note

The method throws an error if <ENTITY_ID> or <USER_ID> is less than or equal to zero.

Do you have some feedback for us?

If you have suggestions for improving this article,