See Also: SqlRoleProvider Members
This class is used by the System.Web.Security.Roles and System.Web.Security.RolePrincipal classes to provide role-management services for an ASP.NET application using a SQL Server database. You can use role management to specify different levels of authorization for your application.
To use the System.Web.Security.SqlRoleProvider class, you must first create the SQL Server database used by the System.Web.Security.SqlRoleProvider. To create the database used by the System.Web.Security.SqlRoleProvider class, run the aspnet_regsql.exe executable found in the C:\WINDOWS\Microsoft.NET\Framework\ versionNumber folder and specify the -Ar option (for example, aspnet_regsql.exe -Ar). The database created is called Aspnetdb. Alternatively, run aspnet_regsql.exe to pull up the GUI configuration mode and choose to configure all ASP.NET features.
If the role provider is configured with a connection string that uses integrated security, the process account of the ASP.NET application must have rights to connect to the SQL Server database.
The Machine.config file is configured with a System.Web.Security.SqlRoleProvider instance named AspNetSqlProvider that connects to the SQL Server on the local machine. You can use this instance of the provider, or specify your own in the Web.config file for your ASP.NET application. To use the AspNetSqlProvider instance, specify AspNetSqlProvider as the defaultProvider in your roleManager configuration.
You can configure the System.Web.Security.SqlRoleProvider to use the same database and user information as the System.Web.Security.SqlMembershipProvider in order to use a single database for authentication and authorization information. To use the same database for membership and role information, run the aspnet_regsql.exe executable and install the membership feature. Then, specify the same connection string in your configuration for both your System.Web.Security.SqlRoleProvider and System.Web.Security.SqlMembershipProvider instances. Also ensure that both provider instances are configured with the same SqlRoleProvider.ApplicationName.