FormsAuthenticationModule クラスとは? わかりやすく解説

Weblio 辞書 > コンピュータ > .NET Framework クラス ライブラリ リファレンス > FormsAuthenticationModule クラスの意味・解説 

FormsAuthenticationModule クラス

フォーム認証有効な場合ASP.NET アプリケーションに対してユーザーID設定します。このクラス継承できません。

名前空間: System.Web.Security
アセンブリ: System.Web (system.web.dll 内)
構文構文

Public NotInheritable Class
 FormsAuthenticationModule
    Implements IHttpModule
Dim instance As FormsAuthenticationModule
public sealed class FormsAuthenticationModule
 : IHttpModule
public ref class FormsAuthenticationModule
 sealed : IHttpModule
public final class FormsAuthenticationModule
 implements IHttpModule
public final class FormsAuthenticationModule
 implements IHttpModule
解説解説

アプリケーション構成ファイルauthentication 要素 (ASP.NET 設定スキーマ) 要素認証 ModeForms設定されている場合FormsAuthenticationModule は、HttpContext.User プロパティを、現在の要求対すユーザー ID を表す IPrincipal オブジェクト設定します

FormsAuthenticationModule は Authenticate イベント公開します。このイベントにより、現在の HttpContext の User プロパティカスタム IPrincipal オブジェクト設定できますAuthenticate イベントには、ASP.NET アプリケーションの Global.asax ファイルに、FormsAuthentication_OnAuthenticate というサブルーチン指定することによってアクセスます。

使用例使用例

FormsAuthentication_OnAuthenticate イベント使用して現在の HttpContextUser プロパティカスタム IPrincipal オブジェクト設定するコード例次に示します

Public Sub FormsAuthentication_OnAuthenticate(sender
 As Object, _
                                              args As FormsAuthenticationEventArgs)
  If FormsAuthentication.CookiesSupported Then
    If Not Request.Cookies(FormsAuthentication.FormsCookieName)
 Is Nothing Then
      Try
        Dim ticket As FormsAuthenticationTicket
 = FormsAuthentication.Decrypt( _
          Request.Cookies(FormsAuthentication.FormsCookieName).Value)
        
        args.User = New System.Security.Principal.GenericPrincipal(
 _
          New Samples.AspNet.Security.MyFormsIdentity(ticket),
 _
          New String(0) {})
      Catch e As HttpException
        ' Decrypt method failed.
      End Try
    End If
  Else
      Throw New Exception("Cookieless
 Forms Authentication is not " & _
                            "supported for this application.")
  End If
End Sub
public void FormsAuthentication_OnAuthenticate(object
 sender, FormsAuthenticationEventArgs args)
{
  if (FormsAuthentication.CookiesSupported)
  {
    if (Request.Cookies[FormsAuthentication.FormsCookieName] !=
 null)
    {
      try
      {
        FormsAuthenticationTicket ticket = FormsAuthentication.Decrypt(
          Request.Cookies[FormsAuthentication.FormsCookieName].Value);
        
        args.User = new System.Security.Principal.GenericPrincipal(
          new Samples.AspNet.Security.MyFormsIdentity(ticket)
,
          new string[0]);
      }
      catch (Exception e)
      {
        // Decrypt method failed.
      }
    }
  }
  else
  {
    throw new HttpException("Cookieless Forms Authentication
 is not " +
                            "supported for this
 application.");
  }
}
.NET Framework のセキュリティ.NET Frameworkセキュリティ
継承階層継承階層
System.Object
  System.Web.Security.FormsAuthenticationModule
スレッド セーフスレッド セーフ
この型の public static (Visual Basic では Shared) メンバはすべて、スレッド セーフです。インスタンス メンバ場合は、スレッド セーフであるとは限りません。
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照



英和和英テキスト翻訳>> Weblio翻訳
英語⇒日本語日本語⇒英語
  

辞書ショートカット

すべての辞書の索引

「FormsAuthenticationModule クラス」の関連用語

FormsAuthenticationModule クラスのお隣キーワード
検索ランキング

   

英語⇒日本語
日本語⇒英語
   



FormsAuthenticationModule クラスのページの著作権
Weblio 辞書 情報提供元は 参加元一覧 にて確認できます。

   
日本マイクロソフト株式会社日本マイクロソフト株式会社
© 2025 Microsoft.All rights reserved.

©2025 GRAS Group, Inc.RSS