RoleManagerSection Clase

Definición

Define las opciones de configuración que se usan para admitir la infraestructura de administración de roles de las aplicaciones web. Esta clase no puede heredarse.

public ref class RoleManagerSection sealed : System::Configuration::ConfigurationSection
public sealed class RoleManagerSection : System.Configuration.ConfigurationSection
type RoleManagerSection = class
    inherit ConfigurationSection
Public NotInheritable Class RoleManagerSection
Inherits ConfigurationSection
Herencia

Ejemplos

En esta sección se proporcionan dos ejemplos de código. En la primera se muestra cómo especificar de forma declarativa valores para varias propiedades de la RoleManagerSection clase . En el segundo se muestra cómo usar el RoleManagerSection tipo .

En el siguiente ejemplo de archivo de configuración se muestra cómo especificar de forma declarativa valores para varias propiedades de la RoleManagerSection clase .

<system.web>
  <roleManager
    enabled="false"
    cacheRolesInCookie="false"
    cookieName=".ASPXROLES" cookieTimeout="30"
    cookiePath="/" cookieRequireSSL="false"
    cookieSlidingExpiration="true" createPersistentCookie="false"
    cookieProtection="All"
    defaultProvider="AspNetSqlRoleProvider"
    maxCachedResults="25"  >
    <providers>
      <add
        name="AspNetSqlRoleProvider"
        connectionStringName="LocalSqlServer"
        applicationName="/"
        type="System.Web.Security.SqlRoleProvider, System.Web,
          Version=2.0.3600.0, Culture=neutral,
          PublicKeyToken=b03f5f7f11d50a3a" />
      <add
        name="AspNetWindowsTokenRoleProvider"
        applicationName="/"
        type="System.Web.Security.WindowsTokenRoleProvider, System.Web,
          Version=2.0.3600.0, Culture=neutral,
          PublicKeyToken=b03f5f7f11d50a3a" />
    </providers>
  </roleManager>
</system.web>

En el ejemplo de código siguiente se muestra cómo usar el RoleManagerSection tipo .

#region Using directives

using System;
using System.Collections.Generic;
using System.Text;
using System.Configuration;
using System.Web;
using System.Web.Configuration;

#endregion

namespace Samples.Aspnet.SystemWebConfiguration
{
  class UsingRoleManagerSection
  {
    static void Main(string[] args)
    {
      try
      {
        // Set the path of the config file.
        string configPath = "";

        // Get the Web application configuration object.
        Configuration config = WebConfigurationManager.OpenWebConfiguration(configPath);

        // Get the section related object.
        RoleManagerSection configSection =
          (RoleManagerSection)config.GetSection("system.web/roleManager");

        // Display title and info.
        Console.WriteLine("ASP.NET Configuration Info");
        Console.WriteLine();

        // Display Config details.
        Console.WriteLine("File Path: {0}",
          config.FilePath);
        Console.WriteLine("Section Path: {0}",
          configSection.SectionInformation.Name);

        // Display CacheRolesInCookie property.
        Console.WriteLine("CacheRolesInCookie: {0}",
          configSection.CacheRolesInCookie);

        // Set CacheRolesInCookie property.
        configSection.CacheRolesInCookie = false;

        // Display CookieName property.
        Console.WriteLine("CookieName: {0}", configSection.CookieName);

        // Set CookieName property.
        configSection.CookieName = ".ASPXROLES";

        // Display CookiePath property.
        Console.WriteLine("CookiePath: {0}", configSection.CookiePath);

        // Set CookiePath property.
        configSection.CookiePath = "/";

        // Display CookieProtection property.
        Console.WriteLine("CookieProtection: {0}",
          configSection.CookieProtection);

        // Set CookieProtection property.
        configSection.CookieProtection =
          System.Web.Security.CookieProtection.All;

        // Display CookieRequireSSL property.
        Console.WriteLine("CookieRequireSSL: {0}",
          configSection.CookieRequireSSL);

        // Set CookieRequireSSL property.
        configSection.CookieRequireSSL = false;

        // Display CookieSlidingExpiration property.
        Console.WriteLine("CookieSlidingExpiration: {0}",
          configSection.CookieSlidingExpiration);

        // Set CookieSlidingExpiration property.
        configSection.CookieSlidingExpiration = true;

        // Display CookieTimeout property.
        Console.WriteLine("CookieTimeout: {0}", configSection.CookieTimeout);

        // Set CookieTimeout property.
        configSection.CookieTimeout = TimeSpan.FromMinutes(30);

        // Display CreatePersistentCookie property.
        Console.WriteLine("CreatePersistentCookie: {0}",
          configSection.CreatePersistentCookie);

        // Set CreatePersistentCookie property.
        configSection.CreatePersistentCookie = false;

        // Display DefaultProvider property.
        Console.WriteLine("DefaultProvider: {0}",
          configSection.DefaultProvider);

        // Set DefaultProvider property.
        configSection.DefaultProvider = "AspNetSqlRoleProvider";

        // Display Domain property.
        Console.WriteLine("Domain: {0}", configSection.Domain);

        // Set Domain property.
        configSection.Domain = "";

        // Display Enabled property.
        Console.WriteLine("Enabled: {0}", configSection.Enabled);

        // Set Enabled property.
        configSection.Enabled = false;

        // Display the number of Providers
        Console.WriteLine("Providers Collection Count: {0}",
          configSection.Providers.Count);

        // Display elements of the Providers collection property.
        foreach (ProviderSettings providerItem in configSection.Providers)
        {
          Console.WriteLine();
          Console.WriteLine("Provider Details:");
          Console.WriteLine("Name: {0}", providerItem.Name);
          Console.WriteLine("Type: {0}", providerItem.Type);
        }

        // Update if not locked.
        if (!configSection.SectionInformation.IsLocked)
        {
          config.Save();
          Console.WriteLine("** Configuration updated.");
        }
        else
        {
          Console.WriteLine("** Could not update, section is locked.");
        }
      }

      catch (Exception e)
      {
        // Unknown error.
        Console.WriteLine(e.ToString());
      }

      // Display and wait
      Console.ReadLine();
    }
  }
}
Imports System.Collections.Generic
Imports System.Text
Imports System.Configuration
Imports System.Web
Imports System.Web.Configuration

Namespace Samples.Aspnet.SystemWebConfiguration
  Class UsingRoleManagerSection
    Public Shared Sub Main()
      Try
        ' Set the path of the config file.
        Dim configPath As String = ""

        ' Get the Web application configuration object.
        Dim config As System.Configuration.Configuration = _
         System.Web.Configuration.WebConfigurationManager.OpenWebConfiguration(configPath)

        ' Get the section related object.
        Dim configSection As System.Web.Configuration.RoleManagerSection = _
         CType(config.GetSection("system.web/roleManager"), _
         System.Web.Configuration.RoleManagerSection)

        ' Display title and info.
        Console.WriteLine("ASP.NET Configuration Info")
        Console.WriteLine()

        ' Display Config details.
        Console.WriteLine("File Path: {0}", config.FilePath)
        Console.WriteLine("Section Path: {0}", configSection.SectionInformation.Name)

        ' Display CacheRolesInCookie property.
        Console.WriteLine("CacheRolesInCookie: {0}", _
         configSection.CacheRolesInCookie)

        ' Set CacheRolesInCookie property.
        configSection.CacheRolesInCookie = False

        ' Display CookieName property.
        Console.WriteLine("CookieName: {0}", configSection.CookieName)

        ' Set CookieName property.
        configSection.CookieName = ".ASPXROLES"

        ' Display CookiePath property.
        Console.WriteLine("CookiePath: {0}", configSection.CookiePath)

        ' Set CookiePath property.
        configSection.CookiePath = "/"

        ' Display CookieProtection property.
        Console.WriteLine("CookieProtection: {0}", _
         configSection.CookieProtection)

        ' Set CookieProtection property.
        configSection.CookieProtection = _
         System.Web.Security.CookieProtection.All

        ' Display CookieRequireSSL property.
        Console.WriteLine("CookieRequireSSL: {0}", _
         configSection.CookieRequireSSL)

        ' Set CookieRequireSSL property.
        configSection.CookieRequireSSL = False

        ' Display CookieSlidingExpiration property.
        Console.WriteLine("CookieSlidingExpiration: {0}", _
         configSection.CookieSlidingExpiration)

        ' Set CookieSlidingExpiration property.
        configSection.CookieSlidingExpiration = True

        ' Display CookieTimeout property.
        Console.WriteLine("CookieTimeout: {0}", configSection.CookieTimeout)

        ' Set CookieTimeout property.
        configSection.CookieTimeout = TimeSpan.FromMinutes(30)

        ' Display CreatePersistentCookie property.
        Console.WriteLine("CreatePersistentCookie: {0}", _
         configSection.CreatePersistentCookie)

        ' Set CreatePersistentCookie property.
        configSection.CreatePersistentCookie = False

        ' Display DefaultProvider property.
        Console.WriteLine("DefaultProvider: {0}", _
         configSection.DefaultProvider)

        ' Set DefaultProvider property.
        configSection.DefaultProvider = "AspNetSqlRoleProvider"

        ' Display Domain property.
        Console.WriteLine("Domain: {0}", configSection.Domain)

        ' Set Domain property.
        configSection.Domain = ""

        ' Display Enabled property.
        Console.WriteLine("Enabled: {0}", configSection.Enabled)

        ' Set CookieName property.
        configSection.Enabled = False

        ' Display the number of Providers
        Console.WriteLine("Providers Collection Count: {0}", _
         configSection.Providers.Count)

        ' Display elements of the Providers collection property.
        For Each providerItem As ProviderSettings In configSection.Providers()
          Console.WriteLine()
          Console.WriteLine("Provider Details:")
          Console.WriteLine("Name: {0}", providerItem.Name)
          Console.WriteLine("Type: {0}", providerItem.Type)
        Next

        ' Update if not locked.
        If Not configSection.SectionInformation.IsLocked Then
          config.Save()
          Console.WriteLine("** Configuration updated.")
        Else
          Console.WriteLine("** Could not update, section is locked.")
        End If

      Catch e As Exception
        ' Unknown error.
        Console.WriteLine(e.ToString())
      End Try

      ' Display and wait
      Console.ReadLine()
    End Sub
  End Class
End Namespace

Comentarios

La RoleManagerSection clase proporciona una manera de obtener acceso mediante programación y modificar el contenido de la roleManager sección del archivo de configuración.

Constructores

Nombre Description
RoleManagerSection()

Inicializa una nueva instancia de la RoleManagerSection clase mediante la configuración predeterminada.

Propiedades

Nombre Description
CacheRolesInCookie

Obtiene o establece un valor que indica si los roles del usuario actual se almacenan en caché en una cookie.

CookieName

Obtiene o establece el nombre de la cookie que se usa para almacenar en caché los nombres de rol.

CookiePath

Obtiene o establece la ruta de acceso virtual de la cookie que se usa para almacenar en caché los nombres de roles.

CookieProtection

Obtiene o establece el tipo de seguridad que se usa para proteger la cookie que almacena en caché los nombres de roles.

CookieRequireSSL

Obtiene o establece un valor que indica si la cookie que se usa para almacenar en caché los nombres de rol requiere una conexión capa de sockets seguros (SSL) para devolverse al servidor.

CookieSlidingExpiration

Obtiene o establece un valor que indica si la cookie que se usa para almacenar en caché los nombres de roles se restablecerá periódicamente.

CookieTimeout

Obtiene o establece el número de minutos antes de que expire la cookie que se usa para almacenar en caché los nombres de roles.

CreatePersistentCookie

Indica si se usa una cookie basada en sesión o una cookie persistente para almacenar en caché los nombres de roles.

CurrentConfiguration

Obtiene una referencia a la instancia de nivel Configuration superior que representa la jerarquía de configuración a la que pertenece la instancia actual ConfigurationElement .

(Heredado de ConfigurationElement)
DefaultProvider

Obtiene o establece el nombre del proveedor predeterminado que se usa para administrar roles.

Domain

Obtiene o establece el nombre del dominio asociado a la cookie que se usa para almacenar en caché los nombres de roles.

ElementInformation

Obtiene un ElementInformation objeto que contiene la información y la funcionalidad no personalizables del ConfigurationElement objeto .

(Heredado de ConfigurationElement)
ElementProperty

Obtiene el ConfigurationElementProperty objeto que representa el ConfigurationElement propio objeto.

(Heredado de ConfigurationElement)
Enabled

Obtiene o establece un valor que indica si la característica de administración de roles de ASP.NET está habilitada.

EvaluationContext

Obtiene el objeto ContextInformation para el objeto ConfigurationElement.

(Heredado de ConfigurationElement)
HasContext

Obtiene un valor que indica si la CurrentConfiguration propiedad es null.

(Heredado de ConfigurationElement)
Item[ConfigurationProperty]

Obtiene o establece una propiedad o atributo de este elemento de configuración.

(Heredado de ConfigurationElement)
Item[String]

Obtiene o establece una propiedad, un atributo o un elemento secundario de este elemento de configuración.

(Heredado de ConfigurationElement)
LockAllAttributesExcept

Obtiene la colección de atributos bloqueados.

(Heredado de ConfigurationElement)
LockAllElementsExcept

Obtiene la colección de elementos bloqueados.

(Heredado de ConfigurationElement)
LockAttributes

Obtiene la colección de atributos bloqueados.

(Heredado de ConfigurationElement)
LockElements

Obtiene la colección de elementos bloqueados.

(Heredado de ConfigurationElement)
LockItem

Obtiene o establece un valor que indica si el elemento está bloqueado.

(Heredado de ConfigurationElement)
MaxCachedResults

Obtiene o establece el número máximo de roles que ASP.NET almacena en caché en la cookie de roles.

Properties

Obtiene la colección de propiedades.

(Heredado de ConfigurationElement)
Providers

Obtiene un ProviderSettingsCollection objeto de ProviderSettings elementos.

SectionInformation

Obtiene un SectionInformation objeto que contiene la información y la funcionalidad no personalizables del ConfigurationSection objeto .

(Heredado de ConfigurationSection)

Métodos

Nombre Description
DeserializeElement(XmlReader, Boolean)

Lee XML del archivo de configuración.

(Heredado de ConfigurationElement)
DeserializeSection(XmlReader)

Lee XML del archivo de configuración.

(Heredado de ConfigurationSection)
Equals(Object)

Compara la instancia actual ConfigurationElement con el objeto especificado.

(Heredado de ConfigurationElement)
GetHashCode()

Obtiene un valor único que representa la instancia actual ConfigurationElement .

(Heredado de ConfigurationElement)
GetRuntimeObject()

Devuelve un objeto personalizado cuando se invalida en una clase derivada.

(Heredado de ConfigurationSection)
GetTransformedAssemblyString(String)

Devuelve la versión transformada del nombre de ensamblado especificado.

(Heredado de ConfigurationElement)
GetTransformedTypeString(String)

Devuelve la versión transformada del nombre de tipo especificado.

(Heredado de ConfigurationElement)
GetType()

Obtiene el Type de la instancia actual.

(Heredado de Object)
Init()

Establece el ConfigurationElement objeto en su estado inicial.

(Heredado de ConfigurationElement)
InitializeDefault()

Se usa para inicializar un conjunto predeterminado de valores para el ConfigurationElement objeto .

(Heredado de ConfigurationElement)
IsModified()

Indica si este elemento de configuración se ha modificado desde que se guardó o cargó por última vez cuando se implementó en una clase derivada.

(Heredado de ConfigurationSection)
IsReadOnly()

Obtiene un valor que indica si el ConfigurationElement objeto es de solo lectura.

(Heredado de ConfigurationElement)
ListErrors(IList)

Agrega los errores de propiedad no válida en este ConfigurationElement objeto y, en todos los subelementos, a la lista pasada.

(Heredado de ConfigurationElement)
MemberwiseClone()

Crea una copia superficial del Objectactual.

(Heredado de Object)
OnDeserializeUnrecognizedAttribute(String, String)

Obtiene un valor que indica si se encuentra un atributo desconocido durante la deserialización.

(Heredado de ConfigurationElement)
OnDeserializeUnrecognizedElement(String, XmlReader)

Obtiene un valor que indica si se encuentra un elemento desconocido durante la deserialización.

(Heredado de ConfigurationElement)
OnRequiredPropertyNotFound(String)

Produce una excepción cuando no se encuentra una propiedad necesaria.

(Heredado de ConfigurationElement)
PostDeserialize()

Se llama después de la deserialización.

(Heredado de ConfigurationElement)
PreSerialize(XmlWriter)

Se llama antes de la serialización.

(Heredado de ConfigurationElement)
Reset(ConfigurationElement)

Restablece el estado interno del ConfigurationElement objeto, incluidos los bloqueos y las colecciones de propiedades.

(Heredado de ConfigurationElement)
ResetModified()

Restablece el valor del IsModified() método a false cuando se implementa en una clase derivada.

(Heredado de ConfigurationSection)
SerializeElement(XmlWriter, Boolean)

Escribe el contenido de este elemento de configuración en el archivo de configuración cuando se implementa en una clase derivada.

(Heredado de ConfigurationElement)
SerializeSection(ConfigurationElement, String, ConfigurationSaveMode)

Crea una cadena XML que contiene una vista no combinada del ConfigurationSection objeto como una sola sección para escribir en un archivo.

(Heredado de ConfigurationSection)
SerializeToXmlElement(XmlWriter, String)

Escribe las etiquetas externas de este elemento de configuración en el archivo de configuración cuando se implementa en una clase derivada.

(Heredado de ConfigurationElement)
SetPropertyValue(ConfigurationProperty, Object, Boolean)

Establece una propiedad en el valor especificado.

(Heredado de ConfigurationElement)
SetReadOnly()

Establece la IsReadOnly() propiedad para el ConfigurationElement objeto y todos los subelementos.

(Heredado de ConfigurationElement)
ShouldSerializeElementInTargetVersion(ConfigurationElement, String, FrameworkName)

Indica si el elemento especificado se debe serializar cuando la jerarquía de objetos de configuración se serializa para la versión de destino especificada de .NET Framework.

(Heredado de ConfigurationSection)
ShouldSerializePropertyInTargetVersion(ConfigurationProperty, String, FrameworkName, ConfigurationElement)

Indica si la propiedad especificada se debe serializar cuando la jerarquía de objetos de configuración se serializa para la versión de destino especificada de .NET Framework.

(Heredado de ConfigurationSection)
ShouldSerializeSectionInTargetVersion(FrameworkName)

Indica si se debe serializar la instancia de ConfigurationSection actual cuando la jerarquía de objetos de configuración se serializa para la versión de destino especificada de .NET Framework.

(Heredado de ConfigurationSection)
ToString()

Devuelve una cadena que representa el objeto actual.

(Heredado de Object)
Unmerge(ConfigurationElement, ConfigurationElement, ConfigurationSaveMode)

Modifica el ConfigurationElement objeto para quitar todos los valores que no se deben guardar.

(Heredado de ConfigurationElement)

Se aplica a

Consulte también