Skip to main content
A newer version of this page is available. .
.NET Framework 4.5.2+

SecuritySystemUser Class

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

Namespace: DevExpress.ExpressApp.Security.Strategy

Assembly: DevExpress.ExpressApp.Security.Xpo.v20.2.dll

Declaration

[MapInheritance(MapInheritanceType.ParentTable)]
[RuleCriteria("SecuritySystemUser_XPO_Prevent_delete_logged_in_user", DefaultContexts.Delete, "[Oid] != CurrentUserId()", "Cannot delete the current logged-in user. Please log in using another user account and retry.")]
public class SecuritySystemUser :
    SecuritySystemUserBase,
    IOperationPermissionProvider,
    ISecurityUserWithRoles,
    ICanInitialize

Remarks

Note

It is recommended to use the Allow/Deny Permission Policy. For this purpose, migrate from SecuritySystemUser 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 SecuritySystemUser user with a custom type that exposes additional properties.

using DevExpress.ExpressApp.Security;
// ...
public class Employee : SecuritySystemUser {
    public Employee(Session session) : base(session) { }
    private string fullName;
    public string FullName {
        get { return fullName; }
        set { SetPropertyValue(nameof(FullName), ref fullName, value); }
    }
    private Department department;
    public Department Department {
        get { return department; }
        set { SetPropertyValue(nameof(Department), ref department, value); }
    }
    [Association("Employee-Task")]
    public XPCollection<Task> Tasks {
        get { return GetCollection<Task>(nameof(Tasks)); }
    }
}

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

Security_SetCustomUserType

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(SecuritySystemRole), 
            new AuthenticationStandard());
    // ...
}

In an ASP.NET 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(SecuritySystemRole), 
            new AuthenticationStandard());
    // ...
}

If server-side security is used, change the security settings in a QueryRequestSecurityStrategyHandler handler.

QueryRequestSecurityStrategyHandler securityProviderHandler = delegate() {
    return new SecurityStrategyComplex(
        typeof(Employee), typeof(SecuritySystemRole), new AuthenticationStandard());

More examples on implementing a custom user object are provided in the How to: Implement Custom Security Objects (Users, Roles, Operation Permissions) and How to: Use Custom Logon Parameters and Authentication topics.

Tip

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

See Also