The requested page is not available for the requested platform. You are viewing the content for Default platform.

SecuritySystemUser Class

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

Namespace: DevExpress.ExpressApp.Security.Strategy

Assembly: DevExpress.ExpressApp.Security.Xpo.v19.1.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
<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
    Inherits SecuritySystemUserBase
    Implements 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("FullName", ref fullName, value); }
    }
    private Department department;
    public Department Department {
        get { return department; }
        set { SetPropertyValue("Department", ref department, value); }
    }
    [Association("Employee-Task")]
    public XPCollection<Task> Tasks {
        get { return GetCollection<Task>("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.

Implements

DevExpress.Xpo.Helpers.IXPClassInfoAndSessionProvider
DevExpress.Xpo.Helpers.IXPClassInfoProvider
DevExpress.Xpo.Helpers.IObjectLayerProvider
DevExpress.Xpo.Helpers.IDataLayerProvider
DevExpress.Xpo.Metadata.Helpers.IXPDictionaryProvider
DevExpress.Xpo.IXPCustomPropertyStore
DevExpress.Xpo.IXPInvalidateableObject
DevExpress.Xpo.IXPReceiveOnChangedFromDelayedProperty
DevExpress.Xpo.IXPReceiveOnChangedFromArbitrarySource
DevExpress.Xpo.Helpers.IXPImmutableHashCode
DevExpress.Xpo.IXPReceiveOnChangedFromXPPropertyDescriptor
DevExpress.ExpressApp.Security.ICanInitialize
See Also