ProtectedConfigurationSection クラス

定義

configProtectedData構成セクションへのプログラムによるアクセスを提供します。 このクラスは継承できません。

public ref class ProtectedConfigurationSection sealed : System::Configuration::ConfigurationSection
public sealed class ProtectedConfigurationSection : System.Configuration.ConfigurationSection
type ProtectedConfigurationSection = class
    inherit ConfigurationSection
Public NotInheritable Class ProtectedConfigurationSection
Inherits ConfigurationSection
継承
ProtectedConfigurationSection

次の構成ファイルの抜粋は、保護されたデータ プロバイダーを宣言によって指定する方法を示しています。

<configProtectedData defaultProvider="RsaProtectedConfigurationProvider">
  <providers>
    <clear />
      <add keyContainerName="NetFrameworkConfigurationKey" cspProviderName="" useMachineContainer="true" useOAEP="false" description="Uses RsaCryptoServiceProvider to encrypt and decrypt" name="RsaProtectedConfigurationProvider" type="System.Configuration.RsaProtectedConfigurationProvider,System.Configuration, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />

      <add useMachineProtection="true" description="Uses CryptProtectData and CryptUnProtectData Windows APIs to encrypt and decrypt" keyEntropy="" name="DataProtectionConfigurationProvider" type="System.Configuration.DpapiProtectedConfigurationProvider,System.Configuration, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />

  </providers>
</configProtectedData>

次のコード例は、 ProtectedConfigurationSection クラスを使用して、 configProtectedData 構成ファイル セクションの値にプログラムでアクセスする方法を示しています。

using System;
using System.IO;
using System.Configuration;

namespace Samples.Aspnet
{
    // Shows how to use ProtectedConfigurationSection.
    class UsingProtectedConfigurationSection
    {

        static void GetDefaultProvider()
        {
            try
            {
                // Get the application configuration.
                Configuration config =
                    ConfigurationManager.OpenExeConfiguration(
                    ConfigurationUserLevel.None);

                // Get the protected configuration section.
                ProtectedConfigurationSection pcSection =
                    (System.Configuration.ProtectedConfigurationSection)
                    config.GetSection("configProtectedData");

                // Get the current DefaultProvider.
                Console.WriteLine(
                    "Protected configuration section default provider:");
                Console.WriteLine("  {0}", pcSection.DefaultProvider);
            }
            catch (ConfigurationErrorsException e)
            {
                Console.WriteLine(e.ToString());
            }
        }

        static void GetProviderCollection()
        {

            try
            {
                // Get the application configuration.
                Configuration config =
                    ConfigurationManager.OpenExeConfiguration(
                    ConfigurationUserLevel.None);

                // Get the protected configuration section.
                ProtectedConfigurationSection pcSection =
                    (System.Configuration.ProtectedConfigurationSection)
                    config.GetSection("configProtectedData");

                Console.WriteLine(
               "Protected configuration section providers:");
                foreach (ProviderSettings ps in
                pcSection.Providers)
                {
                    Console.WriteLine("  {0}", ps.Name);
                }
            }
            catch (ConfigurationErrorsException e)
            {
                Console.WriteLine(e.ToString());
            }
        }

        public static void Main()
        {
            GetDefaultProvider();
            GetProviderCollection();
        }
    }
}
Imports System.IO
Imports System.Configuration


' Shows how to use ProtectedConfigurationSection.

Class UsingProtectedConfigurationSection
    
    
    Shared Sub GetDefaultProvider() 
        Try
            ' Get the application configuration.
            Dim config As Configuration = _
            ConfigurationManager.OpenExeConfiguration( _
            ConfigurationUserLevel.None)
            
            ' Get the protected configuration section.
            Dim pcSection _
            As ProtectedConfigurationSection = _
            CType(config.GetSection( _
            "configProtectedData"), _
            System.Configuration.ProtectedConfigurationSection)
            
            ' Get the current DefaultProvider.
            Console.WriteLine( _
            "Protected configuration section default provider:")
            Console.WriteLine("{0}", _
            pcSection.DefaultProvider)
        
        Catch e As ConfigurationErrorsException
            Console.WriteLine(e.ToString())
        End Try
    
    End Sub
     
    
    Shared Sub GetProviderCollection() 
        
        Try
            ' Get the application configuration.
            Dim config As Configuration = _
            ConfigurationManager.OpenExeConfiguration( _
            ConfigurationUserLevel.None)

            ' Get the protected configuration section.
            Dim pcSection _
            As ProtectedConfigurationSection = _
            CType(config.GetSection( _
            "configProtectedData"), _
            System.Configuration.ProtectedConfigurationSection)

            Console.WriteLine( _
            "Protected configuration section providers:")
            Dim ps As ProviderSettings
            For Each ps In  pcSection.Providers
                Console.WriteLine("  {0}", ps.Name)
            Next ps
        
        Catch e As ConfigurationErrorsException
            Console.WriteLine(e.ToString())
        End Try
    
    End Sub
     

    Public Shared Sub Main() 
        GetDefaultProvider()
        GetProviderCollection()
    
    End Sub
End Class

注釈

configProtectedData構成ファイル セクションには、保護されたデータ プロバイダーのコレクションがproviders要素に含まれています。

Aspnet_regiis.exe ツールを使用して、構成セクションの暗号化と暗号化解除を行うことができます。

コンストラクター

名前 説明
ProtectedConfigurationSection()

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

プロパティ

名前 説明
CurrentConfiguration

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

(継承元 ConfigurationElement)
DefaultProvider

ProtectedConfigurationProvider コレクション プロパティの既定のProviders オブジェクトの名前を取得または設定します。

ElementInformation

ElementInformation オブジェクトのカスタマイズ不可能な情報と機能を含む ConfigurationElement オブジェクトを取得します。

(継承元 ConfigurationElement)
ElementProperty

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

(継承元 ConfigurationElement)
EvaluationContext

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

(継承元 ConfigurationElement)
HasContext

CurrentConfiguration プロパティが nullされているかどうかを示す値を取得します。

(継承元 ConfigurationElement)
Item[ConfigurationProperty]

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

(継承元 ConfigurationElement)
Item[String]

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

(継承元 ConfigurationElement)
LockAllAttributesExcept

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

(継承元 ConfigurationElement)
LockAllElementsExcept

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

(継承元 ConfigurationElement)
LockAttributes

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

(継承元 ConfigurationElement)
LockElements

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

(継承元 ConfigurationElement)
LockItem

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

(継承元 ConfigurationElement)
Properties

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

(継承元 ConfigurationElement)
Providers

参加しているすべての構成ファイル内のすべてのProviderSettingsCollection オブジェクトのProtectedConfigurationProvider コレクションを取得します。

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)

ファイルに書き込む単一のセクションとして、 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)

適用対象

こちらもご覧ください