SectionInformation.ProtectSection(String) 메서드
정의
중요
일부 정보는 릴리스되기 전에 상당 부분 수정될 수 있는 시험판 제품과 관련이 있습니다. Microsoft는 여기에 제공된 정보에 대해 어떠한 명시적이거나 묵시적인 보증도 하지 않습니다.
보호를 위해 구성 섹션에 표시합니다.
public:
void ProtectSection(System::String ^ protectionProvider);
public void ProtectSection(string protectionProvider);
member this.ProtectSection : string -> unit
Public Sub ProtectSection (protectionProvider As String)
매개 변수
- protectionProvider
- String
사용할 보호 공급자의 이름입니다.
예외
예제
다음 예제에서는 ProtectSection 메서드를 사용하는 방법을 보여 줍니다.
static public void ProtectSection()
{
// Get the current configuration file.
System.Configuration.Configuration config =
ConfigurationManager.OpenExeConfiguration(
ConfigurationUserLevel.None);
// Get the section.
UrlsSection section =
(UrlsSection)config.GetSection("MyUrls");
// Protect (encrypt)the section.
section.SectionInformation.ProtectSection(
"RsaProtectedConfigurationProvider");
// Save the encrypted section.
section.SectionInformation.ForceSave = true;
config.Save(ConfigurationSaveMode.Full);
// Display decrypted configuration
// section. Note, the system
// uses the Rsa provider to decrypt
// the section transparently.
string sectionXml =
section.SectionInformation.GetRawXml();
Console.WriteLine("Decrypted section:");
Console.WriteLine(sectionXml);
}
Public Shared Sub ProtectSection()
' Get the current configuration file.
Dim config _
As System.Configuration.Configuration = _
ConfigurationManager.OpenExeConfiguration( _
ConfigurationUserLevel.None)
' Get the section.
Dim section As UrlsSection = _
CType(config.GetSection("MyUrls"), UrlsSection)
' Protect (encrypt)the section.
section.SectionInformation.ProtectSection( _
"RsaProtectedConfigurationProvider")
' Save the encrypted section.
section.SectionInformation.ForceSave = True
config.Save(ConfigurationSaveMode.Full)
' Display decrypted configuration
' section. Note, the system
' uses the Rsa provider to decrypt
' the section transparently.
Dim sectionXml As String = _
section.SectionInformation.GetRawXml()
Console.WriteLine("Decrypted section:")
Console.WriteLine(sectionXml)
End Sub
설명
메서드는 ProtectSection 암호화 섹션을 표시하므로 디스크에서 암호화된 형식으로 작성됩니다.
기본적으로 다음 보호 공급자가 포함됩니다.
DpapiProtectedConfigurationProvider
RsaProtectedConfigurationProvider
참고
매개 변수 또는 빈 문자열 RsaProtectedConfigurationProvider 을 사용하여 메서드를 null
호출 ProtectSection 하는 경우 클래스는 보호 공급자로 사용됩니다.
보호된 구성 섹션에 대한 자세한 내용은 보호된 구성을 사용하여 구성 정보 암호화를 참조하세요.