.NET Framework 4.5.2+
.NET Framework 4.5.2+
.NET Standard 2.0+
The page you are viewing does not exist in the .NET Standard 2.0+ platform documentation. This link will take you to the parent topic of the current section.
.NET 5.0+

User Class

An XAF user who has a list of associated security roles.

Namespace: DevExpress.Persistent.BaseImpl.EF

Assembly: DevExpress.ExpressApp.Security.EF6.v21.2.dll


[RuleCriteria("SecuritySystemUser_EF_Prevent_delete_logged_in_user", DefaultContexts.Delete, "[ID] != CurrentUserId()", "Cannot delete the current logged-in user. Please log in using another user account and retry.")]
public class User :



It is recommended to use the Allow/Deny Permission Policy. For this purpose, migrate from User to PermissionPolicyUser. If you use Entity Framework as the ORM system, you may also need to perform a migration.

Associated roles are exposed via the SecuritySystemUser.Roles property. To get the complete list of permissions granted to the current user via their associated roles, use the IOperationPermissionProvider.GetPermissions method.

Inherit this class when you use the SecurityStrategyComplex Security Strategy and want to replace the default User with a custom type that exposes additional properties.

using DevExpress.Persistent.BaseImpl.EF;
// ...
public class Employee : User {
    public int ID { get; protected set; }
    public string FullName {get; set; }
    public virtual Department Department { get; set; }
    public virtual IList<Task> Tasks { get; set; }

Then, invoke the Application Designer, focus the SecurityStrategyComplex component and change the SecurityStrategy.UserType value in the Properties window.


Alternativaly, you can specify the user type in code. In a Windows Forms application project, modify the Program.cs (Program.vb) file in the following manner.

public static void Main(string[] arguments) {
    MySolutionWinApplication winApplication = new MySolutionWinApplication();
    winApplication.Security = 
        new SecurityStrategyComplex(typeof(Employee), typeof(Role), 
            new AuthenticationStandard());
    // ...

In an ASP.NET Web Forms application project, modify the Global.asax.cs (Global.asax.vb) file in the following manner.

protected void Session_Start(Object sender, EventArgs e) {
    WebApplication.SetInstance(Session, new MySolutionAspNetApplication());
    WebApplication.Instance.Security = 
       new SecurityStrategyComplex(typeof(Employee), typeof(Role), 
            new AuthenticationStandard());
    // ...


You can use the UserWithRolesExtensions.IsUserInRole extension method with User objects because User implements ISecurityUserWithRoles.


See Also