Skip to main content
.NET 6.0+

SecurityStrategyComplex.NewUserRoleName Property

Specifies the name of role which is assigned to auto-created users.

Namespace: DevExpress.ExpressApp.Security

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

Declaration

public string NewUserRoleName { get; set; }

Property Value

Type Description
String

A string which is the name of the role assigned to auto-created users.

Remarks

For instance, users are auto-created when AuthenticationActiveDirectory authentication is used and the AuthenticationActiveDirectory.CreateUserAutomatically property is set to true.

You can use this property to update existing applications with Active Directory authentication. For this purpose, follow the steps below:

  1. In Release mode (for production purposes), you can create security users and roles (other than Admins) according to your specific business needs in SolutionName.Module\DatabaseUpdate\Updater.xx. In this case, ensure that this code is not placed under the #if DEBUG preprocessor directive. Alternatively, you can create new users and roles at runtime directly from your production application UI or database.

  2. Set the SecurityStrategyComplex.NewUserRoleName property to the name of the role you want to assign to new users automatically.

WinForms Applications

File: MySolution.Win\ApplicationBuilder.cs

public class ApplicationBuilder : IDesignTimeApplicationFactory {
    public static WinApplication BuildApplication(string connectionString) {
        var builder = WinApplication.CreateBuilder();
        // ...
        builder.Security
            .UseIntegratedMode(options => {
                // ...
                // Assign the role with the 'Default' name to new users.
                options.NewUserRoleName = "Default"; 
                // ...
            })
            .UseWindowsAuthentication(options => {
                options.CreateUserAutomatically();
                // ...
            });
        // ...
    }
}

ASP.NET Core Blazor Applications

File: MySolution.Blazor.Server\Startup.cs

public class Startup {
    // ...
    public void ConfigureServices(IServiceCollection services) {
        // ...
        services.AddXaf(Configuration, builder => {
            // ...
            builder.Security
                .UseIntegratedMode(options => {
                    // ...
                    // Assign the role with the 'Default' name to new users.
                    options.NewUserRoleName = "Default";
                    // ...
                })
                // ...
                .AddWindowsAuthentication(options => {
                    options.CreateUserAutomatically();
                    // ...
                });
            // ...
        });
    }
}

Web API Applications

File: MySolution.WebApi\Startup.cs

public class Startup {
    // ...
    public void ConfigureServices(IServiceCollection services) {
        // ...
        services.AddXafWebApi(builder => {
            builder.Security
                .UseIntegratedMode(options => {
                    // ...
                    // Assign the role with the 'Default' name to new users.
                    options.NewUserRoleName = "Default";
                    // ...
                })
                // ...
                .AddWindowsAuthentication(options => {
                    options.CreateUserAutomatically();
                    // ...
                });
            // ...
        }, Configuration);
    }
}

Middle Tier Server Applications

File: MySolution.MiddleTierWebApi\Startup.cs

public class Startup {
    // ...
    public void ConfigureServices(IServiceCollection services) {
        // ...
        services.AddXafMiddleTier(Configuration, builder => {
            // ...
            builder.Security
                .UseIntegratedMode(options => {
                    // ...
                    // Assign the role with the 'Default' name to new users.
                    options.NewUserRoleName = "Default";
                    // ...
                })
                .AddWindowsAuthentication(options => {
                    options.CreateUserAutomatically();
                    // ...
                });
            // ...
        });
    }
}

The following code snippets (auto-collected from DevExpress Examples) contain references to the NewUserRoleName property.

Note

The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.

See Also