RoleManagerSection クラス

定義

Web アプリケーションのロール管理インフラストラクチャをサポートするために使用される構成設定を定義します。 このクラスは継承できません。

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
継承

このセクションでは、2 つのコード例を示します。 1 つ目は、 クラスのいくつかのプロパティの値を宣言的に指定する方法を RoleManagerSection 示しています。 2 つ目は、 型の使用方法を RoleManagerSection 示しています。

次の構成ファイルの例は、 クラスのいくつかのプロパティの値を宣言的に指定する方法を RoleManagerSection 示しています。

<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>  

次のコード例では、 型の使用方法を RoleManagerSection 示します。

#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

注釈

クラスは RoleManagerSection 、構成ファイルの セクションの roleManager 内容にプログラムでアクセスして変更する方法を提供します。

コンストラクター

RoleManagerSection()

既定の設定を使用して RoleManagerSection クラスの新しいインスタンスを初期化します。

プロパティ

CacheRolesInCookie

現在のユーザーのロールがクッキーにキャッシュされているかどうかを示す値を取得または設定します。

CookieName

ロール名をキャッシュするために使用されるクッキーの名前を取得または設定します。

CookiePath

ロール名をキャッシュするために使用されるクッキーの仮想パスを取得または設定します。

CookieProtection

ロール名をキャッシュするクッキーを保護するために使用されるセキュリティの種類を取得または設定します。

CookieRequireSSL

ロール名をキャッシュするために使用するクッキーをサーバーに返すために、SSL (Secure Sockets Layer) 接続が必要かどうかを示す値を取得または設定します。

CookieSlidingExpiration

ロール名をキャッシュするために使用されるクッキーを定期的にリセットするかどうかを指定する値を取得または設定します。

CookieTimeout

ロール名をキャッシュするために使用されるクッキーの有効期限が切れるまでの時間 (分) を取得または設定します。

CreatePersistentCookie

ロール名をキャッシュするために、セッションベースのクッキー、または永続的なクッキーのどちらを使用するのかを示します。

CurrentConfiguration

現在の Configuration インスタンスが属している構成階層を表す最上位の ConfigurationElement インスタンスへの参照を取得します。

(継承元 ConfigurationElement)
DefaultProvider

ロールを管理するために使用される既定のプロバイダーの名前を取得または設定します。

Domain

ロール名をキャッシュするために使用されるクッキーに関連付けられるドメインの名前を取得または設定します。

ElementInformation

ElementInformation オブジェクトのカスタマイズできない情報と機能を格納する ConfigurationElement オブジェクトを取得します。

(継承元 ConfigurationElement)
ElementProperty

ConfigurationElementProperty オブジェクト自体を表す ConfigurationElement オブジェクトを取得します。

(継承元 ConfigurationElement)
Enabled

ASP.NET のロール管理機能が有効かどうかを示す値を取得または設定します。

EvaluationContext

ContextInformation オブジェクトの ConfigurationElement オブジェクトを取得します。

(継承元 ConfigurationElement)
HasContext

CurrentConfiguration プロパティが null であるかどうかを示す値を取得します。

(継承元 ConfigurationElement)
Item[ConfigurationProperty]

この構成要素のプロパティまたは属性を取得または設定します。

(継承元 ConfigurationElement)
Item[String]

この構成要素のプロパティ、属性、または子要素を取得または設定します。

(継承元 ConfigurationElement)
LockAllAttributesExcept

ロックされている属性のコレクションを取得します。

(継承元 ConfigurationElement)
LockAllElementsExcept

ロックされている要素のコレクションを取得します。

(継承元 ConfigurationElement)
LockAttributes

ロックされている属性のコレクションを取得します。

(継承元 ConfigurationElement)
LockElements

ロックされている要素のコレクションを取得します。

(継承元 ConfigurationElement)
LockItem

要素がロックされているかどうかを示す値を取得または設定します。

(継承元 ConfigurationElement)
MaxCachedResults

ASP.NET がロールのクッキーにキャッシュするロールの最大数を取得または設定します。

Properties

プロパティのコレクションを取得します。

(継承元 ConfigurationElement)
Providers

ProviderSettingsCollection 要素の ProviderSettings オブジェクトを取得します。

SectionInformation

SectionInformation オブジェクトのカスタマイズできない情報と機能を格納する ConfigurationSection オブジェクトを取得します。

(継承元 ConfigurationSection)

メソッド

DeserializeElement(XmlReader, Boolean)

構成ファイルから XML を読み取ります。

(継承元 ConfigurationElement)
DeserializeSection(XmlReader)

構成ファイルから XML を読み取ります。

(継承元 ConfigurationSection)
Equals(Object)

現在の ConfigurationElement インスタンスを、指定したオブジェクトと比較します。

(継承元 ConfigurationElement)
GetHashCode()

現在の ConfigurationElement インスタンスを表す一意の値を取得します。

(継承元 ConfigurationElement)
GetRuntimeObject()

派生クラスでオーバーライドされると、カスタム オブジェクトを返します。

(継承元 ConfigurationSection)
GetTransformedAssemblyString(String)

指定されたアセンブリ名を変換して返します。

(継承元 ConfigurationElement)
GetTransformedTypeString(String)

指定された型名を変換して返します。

(継承元 ConfigurationElement)
GetType()

現在のインスタンスの Type を取得します。

(継承元 Object)
Init()

ConfigurationElement オブジェクトを初期状態に設定します。

(継承元 ConfigurationElement)
InitializeDefault()

ConfigurationElement オブジェクトの既定の値セットを初期化するために使用します。

(継承元 ConfigurationElement)
IsModified()

派生クラスに実装された場合、この構成要素が最後の保存または読み込み以降に変更されたかどうかを示します。

(継承元 ConfigurationSection)
IsReadOnly()

ConfigurationElement オブジェクトが読み取り専用かどうかを示す値を取得します。

(継承元 ConfigurationElement)
ListErrors(IList)

この ConfigurationElement オブジェクトおよびすべてのサブ要素の無効なプロパティのエラーを、渡されたリストに追加します。

(継承元 ConfigurationElement)
MemberwiseClone()

現在の Object の簡易コピーを作成します。

(継承元 Object)
OnDeserializeUnrecognizedAttribute(String, String)

逆シリカル化中に不明な属性が発生したかどうかを示す値を取得します。

(継承元 ConfigurationElement)
OnDeserializeUnrecognizedElement(String, XmlReader)

逆シリカル化中に不明な要素が発生したかどうかを示す値を取得します。

(継承元 ConfigurationElement)
OnRequiredPropertyNotFound(String)

必要なプロパティが見つからないと例外がスローされます。

(継承元 ConfigurationElement)
PostDeserialize()

逆シリアル化後に呼び出されます。

(継承元 ConfigurationElement)
PreSerialize(XmlWriter)

シリアル化前に呼び出されます。

(継承元 ConfigurationElement)
Reset(ConfigurationElement)

ConfigurationElement オブジェクトの内部状態 (ロックやプロパティ コレクションなど) をリセットします。

(継承元 ConfigurationElement)
ResetModified()

IsModified() メソッドの値が派生クラスに実装されたときに、false にリセットします。

(継承元 ConfigurationSection)
SerializeElement(XmlWriter, Boolean)

派生クラスに実装されている場合、この構成要素の内容を構成ファイルに書き込みます。

(継承元 ConfigurationElement)
SerializeSection(ConfigurationElement, String, ConfigurationSaveMode)

ファイルに書き込む 1 つのセクションとして、ConfigurationSection オブジェクトのアンマージされたビューを含む XML 文字列を作成します。

(継承元 ConfigurationSection)
SerializeToXmlElement(XmlWriter, String)

派生クラスに実装されている場合、この構成要素の外側のタグを構成ファイルに書き込みます。

(継承元 ConfigurationElement)
SetPropertyValue(ConfigurationProperty, Object, Boolean)

プロパティを指定した値に設定します。

(継承元 ConfigurationElement)
SetReadOnly()

IsReadOnly() オブジェクトおよびすべてのサブ要素に ConfigurationElement プロパティを設定します。

(継承元 ConfigurationElement)
ShouldSerializeElementInTargetVersion(ConfigurationElement, String, FrameworkName)

指定したターゲット バージョンの.NET Frameworkに対して構成オブジェクト階層をシリアル化するときに、指定した要素をシリアル化する必要があるかどうかを示します。

(継承元 ConfigurationSection)
ShouldSerializePropertyInTargetVersion(ConfigurationProperty, String, FrameworkName, ConfigurationElement)

指定したターゲット バージョンの.NET Frameworkに対して構成オブジェクト階層をシリアル化するときに、指定したプロパティをシリアル化する必要があるかどうかを示します。

(継承元 ConfigurationSection)
ShouldSerializeSectionInTargetVersion(FrameworkName)

指定したターゲット バージョンの.NET Frameworkに対して構成オブジェクト階層をシリアル化するときに、現在ConfigurationSectionのインスタンスをシリアル化する必要があるかどうかを示します。

(継承元 ConfigurationSection)
ToString()

現在のオブジェクトを表す文字列を返します。

(継承元 Object)
Unmerge(ConfigurationElement, ConfigurationElement, ConfigurationSaveMode)

保存しないすべての値を削除するには、ConfigurationElement オブジェクトを変更します。

(継承元 ConfigurationElement)

適用対象

こちらもご覧ください