AuthenticationSection クラス
アセンブリ: System.Web (system.web.dll 内)
![構文](http://weblio.hs.llnwd.net/e7/img/dict/msdnc/minus.gif)
![解説](http://weblio.hs.llnwd.net/e7/img/dict/msdnc/minus.gif)
AuthenticationSection クラスを使用すると、構成ファイルの authentication セクションにプログラムからアクセスして変更できます。
![]() |
---|
AuthenticationSection は、値が MachineToApplication のセクション プロパティ AllowDefinition で定義される制限に従って構成ファイルの関連するセクションに情報を書き込むことができます。階層構造の許可されていないレベルで構成ファイルに書き込みを行おうとした場合、パーサーによってエラー メッセージが生成されます。ただし、このクラスを使用して、階層構造の任意のレベルに構成情報を読み込むことができます。安全性とスケーラビリティを高めるため、データベースなど、外部のリポジトリを使用して、ユーザーの資格情報を維持することをお勧めします。 |
![使用例](http://weblio.hs.llnwd.net/e7/img/dict/msdnc/minus.gif)
このセクションには、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");
![継承階層](http://weblio.hs.llnwd.net/e7/img/dict/msdnc/minus.gif)
System.Configuration.ConfigurationElement
System.Configuration.ConfigurationSection
System.Web.Configuration.AuthenticationSection
![スレッド セーフ](http://weblio.hs.llnwd.net/e7/img/dict/msdnc/minus.gif)
![プラットフォーム](http://weblio.hs.llnwd.net/e7/img/dict/msdnc/minus.gif)
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 によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。
![バージョン情報](http://weblio.hs.llnwd.net/e7/img/dict/msdnc/minus.gif)
![参照](http://weblio.hs.llnwd.net/e7/img/dict/msdnc/minus.gif)
- AuthenticationSection クラスのページへのリンク