Skip to main content
.NET 8.0+

SecurityStrategyComplex Class

A Security Strategy that maintains users who have a list of associated roles.

Namespace: DevExpress.ExpressApp.Security

Assembly: DevExpress.ExpressApp.Security.v24.2.dll

Declaration

[ToolboxTabName("DX.24.2: XAF Security")]
public class SecurityStrategyComplex :
    SecurityStrategy,
    ISecurityComplex,
    ISecurityStrategyBase,
    IRoleTypeProvider,
    IServiceProviderContainer
[ToolboxTabName("DX.24.2: XAF Security")]
public class SecurityStrategyComplex :
    SecurityStrategy,
    ISecurityComplex,
    ISecurityStrategyBase,
    IRoleTypeProvider

Remarks

In the SecurityStrategyComplex security strategy, each user can belong to one or more groups. These groups are called Roles (see XPO PermissionPolicyRole or EF Core PermissionPolicyRole). Roles are characterized by an associated permission set. An application administrator creates users and roles, and assigns roles to users. An application developer can create a set of predefined users and roles that can be extended later by an administrator (see Client-Side Security (2-Tier Architecture)).

Note

To see what capabilities are provided to an administrator within the SecurityStrategyComplex security strategy, refer to the Security System Overview topic.

A newly created XAF application uses no security. To enable the SecurityStrategyComplex security strategy, invoke the Application Designer and drag the SecurityStrategyComplex component from the Toolbox‘s DX.24.2: XAF Security category to the designer’s Security pane.

Security_UseSecurityStrategyComplex

You can specify a custom user and role type by changing the SecurityStrategy.UserType and SecurityStrategyComplex.RoleType values in the Properties window.

Security_SetCustomUserType

Then, specify the authentication type that will accompany the security strategy. Drag either the AuthenticationStandard or AuthenticationActiveDirectory component from the toolbox to the Security pane of the designer. You can also use a custom authentication (see Customize Standard Authentication Behavior and Supply Additional Logon Parameters (.NET Applications)).

Security_DesignerAuthenticationSimple

Alternatively, you can enable the SecurityStrategyComplex Security Strategy in code. It is required to instantiate the SecurityStrategyComplex class and assign this instance to the XafApplication.Security property. In a Windows Forms application project, modify the Program.cs file in the following manner.

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

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

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

    // ...
}

As a result, in a WinForms application you can see the User, Role, and My Details navigation items. The active user name is displayed in the status bar.Tutorial_Security_ActiveDir

See Also