Share via


add Element for providers for roleManager (ASP.NET Settings Schema)

Adds a role provider instance to the collection of role management providers.

This element is new in the .NET Framework version 2.0.

configuration Element (General Settings Schema)
  system.web Element (ASP.NET Settings Schema)
    roleManager Element (ASP.NET Settings Schema)
      providers Element for roleManager (ASP.NET Settings Schema)
        add Element for providers for roleManager (ASP.NET Settings Schema)

<add name="provider name" 
     type="string"
     connectionStringName="string"
     applicationName="string" 
     commandTimeout="number" 
     description="string" 
     cacheRefreshInterval="number" 
     scopeName="string"/>

Attributes and Elements

The following sections describe attributes, child elements, and parent elements.

Attributes

Attribute

Description

applicationName

Optional String attribute.

Specifies the name of the application under which role names are stored at the data source. The application name enables multiple ASP.NET applications to use the same database without encountering duplicate role names for different applications. Alternatively, multiple ASP.NET applications can use the same role information by specifying the same application name.

The role providers that are included with the .NET Framework use the ApplicationVirtualPath value for the ApplicationName property, if this attribute is not specified.

cacheRefreshInterval

Optional Int32 attribute.

Specifies the number of minutes between forced updates of the cached policy store data and Applies to the AuthorizationStoreRoleProvider only.

The default is 60.

commandTimeout

Optional Int32 attribute.

Specifies the number of seconds before a command that is issued to the Role Manager data source times out. This time-out is used by the SQL provider when creating SqlCommand objects. By default, this attribute is not set in the ASP.NET configuration. As a result the ADO.NET default of 30 seconds is used. If this attribute is set, the SQL provider uses the configured time-out value for all SQL commands that are issued to the database.

The default is 30 (the ADO.NET default).

connectionStringName

Required String attribute.

Specifies the name of a connection string that is defined in the <connectionStrings> element. The specified connection string will be used by the provider that is being added.

description

Optional String attribute.

Specifies a description of the role provider instance.

name

Required String attribute.

Specifies the name of the provider instance. This is the value that is used for the defaultProvider attribute of the <roleManager> element to identify the provider instance as the default role provider.

The name of the provider is also used to index the provider in the Providers collection.

scopeName

Optional String attribute.

Specifies the security scope of an Authorization Manager policy store that the provider instance should connect to and applies to the AuthorizationStoreRoleProvider only. If scopeName is specified, the combination of applicationName and scopeName is used by the provider when connecting to the policy store.

type

Required String attribute.

Specifies the type that is implementing the RoleProvider abstract base class.

Child Elements

None.

Parent Elements

Element

Description

configuration

Specifies the required root element in every configuration file that is used by the common language runtime and the .NET Framework applications.

system.web

Specifies the root element for the ASP.NET configuration section.

roleManager

Configures an application for role management.

providers

Defines a collection of role providers for role management.

Remarks

The add element adds a role provider instance to the role management provider collection that is stored in the providers element.

The providers element defines a collection of role providers for role management.

For information about accessing and modifying configuration values for the roleManager element in application code, see RoleManagerSection, WindowsTokenRoleProvider, SqlRoleProvider, and AuthorizationStoreRoleProvider.

Default Configuration

The following default providers element is configured in the Machine.config file.

<roleManager>
   <providers>
<add name="AspNetSqlRoleProvider" connectionStringName="LocalSqlServer" applicationName="/" type="System.Web.Security.SqlRoleProvider, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
        <add name="AspNetWindowsTokenRoleProvider" applicationName="/" type="System.Web.Security.WindowsTokenRoleProvider, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />   </providers>
</roleManager>

Example

The following code example shows how to configure an ASP.NET application to use the SqlRoleProvider class to store and retrieve role information.

<configuration>
  <system.web>
      <roleManager defaultProvider="SqlProvider" 
                   enabled="true"
                   cacheRolesInCookie="true"
                   cookieName=".ASPROLES"
                   cookieTimeout="30"
                   cookiePath="/"
                   cookieRequireSSL="false"
                   cookieSlidingExpiration="true"
                   cookieProtection="All" >
        <providers>
          <add
            name="SqlProvider"
            type="System.Web.Security.SqlRoleProvider"
            connectionStringName="SqlServices" 
            applicationName="SampleApplication" />
            
        </providers>
      </roleManager>
  </system.web>
</configuration>

Element Information

Configuration section handler

RoleManagerSection

Configuration member

Add

Configurable locations

Machine.config

Root-level Web.config

Application-level Web.config

Requirements

Microsoft Internet Information Services (IIS) version 5.0, 5.1, or 6.0

The .NET Framework version 2.0

Microsoft Visual Studio 2003 or Visual Studio 2005

See Also

Tasks

How to: Configure Specific Directories Using Location Settings

How to: Lock ASP.NET Configuration Settings

Reference

providers Element for roleManager (ASP.NET Settings Schema)

clear Element for providers for roleManager (ASP.NET Settings Schema)

remove Element for providers for roleManager (ASP.NET Settings Schema)

roleManager Element (ASP.NET Settings Schema)

system.web Element (ASP.NET Settings Schema)

configuration Element (General Settings Schema)

System.Configuration

System.Web.Configuration

RoleManagerSection

RoleManager

Concepts

Understanding Role Management

Securing ASP.NET Configuration

ASP.NET Configuration Scenarios

Other Resources

General Configuration Settings (ASP.NET)

ASP.NET Configuration Settings

ASP.NET Reference

ASP.NET Web Site Administration

ASP.NET Configuration API