FormsAuthenticationUser クラス
アセンブリ: System.Web (system.web.dll 内)
構文
FormsAuthenticationUser クラスを使用すると、構成ファイルの user セクションにプログラムからアクセスして変更できます。
この型は、FormsAuthenticationCredentials 型、FormsAuthenticationUserCollection 型、FormsAuthenticationConfiguration 型を含むグループの一部です。コレクション型以外の型は、基になる構成タグに直接影響を与えます。
メモ |
---|
FormsAuthenticationUser は、マシン レベル、サイト レベル、またはアプリケーション レベルのみで、構成ファイルの関連するセクションに情報を書き込むことができます。階層構造の異なるレベルで構成ファイルに書き込みを行おうとした場合、パーサーによってエラー メッセージが生成されます。ただし、このクラスを使用して、階層構造の任意のレベルに構成情報を読み込むことができます。安全性とスケーラビリティを高めるため、データベースなど、外部のリポジトリを使用して、ユーザーの資格情報を維持することをお勧めします。 |
既存の Web アプリケーションの FormsAuthenticationUser オブジェクトにアクセスするために FormsAuthenticationUserCollection を取得する方法を次のコード例に示します。構成ファイルには、次のようなセットアップが格納されます。
メモ |
---|
authentication の forms の credentials 要素 (ASP.NET 設定スキーマ) セクションを使用する場合は、「ASP.NET の認証」に説明されているガイドラインに従う必要があります。スケーラビリティとセキュリティを高めるため、外部のデータベースを使用して、ユーザーの資格情報を保管することをお勧めします。安全な ASP.NET アプリケーションを構築する方法の詳細については、Microsoft MSDN Web サイト (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"> defaultUrl="formsdefault.aspx" protection="Encryption" timeout="5" path="aspnet" slidingExpiration="false" cookieless="UseCookies" domain="domainName"> <credentials passwordFormat="SHA1"> <user name="aspnetuser1" password="5BAA61E4C9B93F3F0682250B6CF8331B7EE68FD8"/> <user name="aspnetuser2" password="E38AD214943DAAD1D64C102FAEC29DE4AFE9DA3D"/> </credentials> </forms> </authentication>
' Get the Web application configuration. Dim configuration _ As System.Configuration.Configuration = _ WebConfigurationManager.OpenWebConfiguration( _ "/aspnet") ' Get the section. Dim authenticationSection _ As AuthenticationSection = _ CType(configuration.GetSection( _ "system.web/authentication"), AuthenticationSection) ' Get the users collection. Dim formsAuthenticationUsers _ As FormsAuthenticationUserCollection = _ authenticationSection.Forms.Credentials.Users
// Get the Web application configuration. System.Configuration.Configuration configuration = WebConfigurationManager.OpenWebConfiguration( "/aspnet"); // Get the section. AuthenticationSection authenticationSection = (AuthenticationSection)configuration.GetSection( "system.web/authentication"); // Get the users collection. FormsAuthenticationUserCollection formsAuthenticationUsers = authenticationSection.Forms.Credentials.Users;
System.Configuration.ConfigurationElement
System.Web.Configuration.FormsAuthenticationUser
プラットフォーム
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 によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。
参照
Weblioに収録されているすべての辞書からFormsAuthenticationUser クラスを検索する場合は、下記のリンクをクリックしてください。
全ての辞書からFormsAuthenticationUser クラスを検索
- FormsAuthenticationUser クラスのページへのリンク