AuthenticationSection クラス
アセンブリ: System.Web (system.web.dll 内)


AuthenticationSection クラスを使用すると、構成ファイルの authentication セクションにプログラムからアクセスして変更できます。
![]() |
---|
AuthenticationSection は、値が MachineToApplication のセクション プロパティ AllowDefinition で定義される制限に従って構成ファイルの関連するセクションに情報を書き込むことができます。階層構造の許可されていないレベルで構成ファイルに書き込みを行おうとした場合、パーサーによってエラー メッセージが生成されます。ただし、このクラスを使用して、階層構造の任意のレベルに構成情報を読み込むことができます。安全性とスケーラビリティを高めるため、データベースなど、外部のリポジトリを使用して、ユーザーの資格情報を維持することをお勧めします。 |

このセクションには、2 つのコード例が用意されています。最初の例では、authentication セクションの複数の属性に対して、宣言によって値を指定する方法を示しています。これらの属性には、AuthenticationSection クラスのメンバとしてもアクセスできます。2 番目の例では、AuthenticationSection クラスの使用方法を示しています。
次の構成ファイルの例では、authentication セクションに対して、宣言によって値を指定する方法を示しています。
![]() |
---|
credentials セクションを使用する場合は、「ASP.NET の認証」に説明されているガイドラインに従う必要があります。スケーラビリティとセキュリティを高めるため、外部のデータベースを使用して、ユーザーの資格情報を保管することをお勧めします。安全な ASP.NET アプリケーションを構築する方法の詳細については、Microsoft MSDN Web サイト (http://msdn.microsoft.com) で、「Securing Your ASP.NET Application」や「Building Secure ASP.NET Applications: Authentication, Authorization, and Secure Communication」を参照してください。 |
<authentication mode="Forms"> <forms name="MyAppCookieName" loginUrl="login.aspx"> <credentials passwordFormat="SHA1"> <user name="Kim" password="07B7F3EE06F278DB966BE960E7CBBD103DF30CA6"/> <user name="John" password="BA56E5E0366D003E98EA1C7F04ABF8FCB3753889"/> </credentials> </forms> </authentication>
AuthenticationSection クラスを使用する方法を次のコード例に示します。
' Get the Web application configuration. Dim configuration _ As System.Configuration.Configuration = _ System.Web.Configuration.WebConfigurationManager.OpenWebConfiguration( _ "/aspnetTest") ' Get the section. Dim authenticationSection _ As AuthenticationSection = _ CType(configuration.GetSection( _ "system.web/authentication"), AuthenticationSection)
// Get the Web application configuration. System.Configuration.Configuration configuration = System.Web.Configuration.WebConfigurationManager.OpenWebConfiguration( "/aspnetTest"); // Get the section. AuthenticationSection authenticationSection = (AuthenticationSection)configuration.GetSection( "system.web/authentication");

System.Configuration.ConfigurationElement
System.Configuration.ConfigurationSection
System.Web.Configuration.AuthenticationSection


Windows 98, Windows 2000 SP4, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


- AuthenticationSection クラスのページへのリンク