Back to Devexpress

Prevent Users from Deleting and Updating Administrative User and Role Objects

expressappframework-402547-data-security-and-safety-security-system-authorization-and-data-protection-prevent-deletion-and-update-of-administrative-users-and-roles.md

latest3.0 KB
Original Source

Prevent Users from Deleting and Updating Administrative User and Role Objects

  • Oct 24, 2025
  • 3 minutes to read

This topic explains how to create Validation and Conditional Appearance Rules to prevent users from deleting and updating administrative user and role objects. These rules affect all users including administrative users.

This help topic uses the ApplicationUser class generated by the Template Kit as well as the EF Core-based PermissionPolicyRole class. In applications based on XPO, use the PermissionPolicyRole class from the DevExpress.Persistent.BaseImpl.PermissionPolicy namespace.

Prevent Deletion of Administrative Users and Roles

  1. Add the Validation Module to the platform-agnostic Module (MySolution.Module).
  2. Open the Model Editor and navigate to the Application | Validation | Rules node. Right-click this node and add the following RuleCriteria that prevents deletion of the “Admin“ user and “Administrators“ role:

The following image shows the result:

Prevent Update of Administrative Users and Roles

  1. Add the Conditional Appearance Module to the platform-agnostic Module (MySolution.Module).

  2. Open the Model Editor and navigate to the Application | BOModel | MySolution.Module.BusinessObjects | ApplicationUser | AppearanceRules node. Right-click this node and add the following rule that disables editors in the Detail View of the “Admin“ User:

  3. Open the Model Editor and navigate to the Application | BOModel | DevExpress.Persistent.BaseImpl.EF.PermissionPolicy | PermissionPolicyRole | AppearanceRules node. Right-click this node and add the following rule that disables editors in the Detail View of the “Administrators“ Role:

The following image shows the result:

Footnotes

  1. Note that users should have permission to read the PermissionPolicyUser.UserName and PermissionPolicyRole.Name properties. Otherwise, their values are replaced with the “*******“ placeholder and no object matches the specified criteria. Grant permission to read the UserName and Name properties or use Oid / Id instead in criteria (all users have permission to read this property).