Share via


FormsAuthenticationConfiguration クラス

定義

AuthenticationMode フォーム認証方式を使用するように ASP.NET アプリケーションを構成します。

public ref class FormsAuthenticationConfiguration sealed : System::Configuration::ConfigurationElement
public sealed class FormsAuthenticationConfiguration : System.Configuration.ConfigurationElement
type FormsAuthenticationConfiguration = class
    inherit ConfigurationElement
Public NotInheritable Class FormsAuthenticationConfiguration
Inherits ConfigurationElement
継承
FormsAuthenticationConfiguration

次のコード例は、既存の Web アプリケーションの FormsAuthenticationConfiguration 構成ファイルからオブジェクトを取得する方法を示しています。 このオブジェクトを使用して、そのメンバーにアクセスできます。 構成ファイルには、次のようなセットアップが含まれます。

メモ このセクションを使用するcredentials場合は、「ASP.NET 認証」で説明されているガイドラインに従ってください。 スケーラビリティとセキュリティを向上させるために、外部データベースを使用してユーザーの資格情報を格納することをお勧めします。 セキュリティで保護された ASP.NET アプリケーションの構築の詳細については、「ASP.NET アプリケーションのセキュリティ保護セキュリティで保護された ASP.NET アプリケーションの構築: 認証、承認、およびセキュリティで保護された通信」を参照してください。

この例では、SHA1 を使用します。 SHA1 との競合問題のため、Microsoft では SHA256 を推奨しています。

<authentication mode="Forms">
  <forms name="MyAppCookie" loginUrl="login.aspx"
    defaultUrl="default.aspx"
    protection="Encryption" timeout="5" path="aspnetTest"
    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.
System.Configuration.Configuration configuration = 
    WebConfigurationManager.OpenWebConfiguration("/aspnetTest");

// Get the external Authentication section.
AuthenticationSection authenticationSection = 
    (AuthenticationSection)configuration.GetSection(
    "system.web/authentication");

// Get the external Forms section .
FormsAuthenticationConfiguration formsAuthentication =
    authenticationSection.Forms;
' Get the Web application configuration.
  Dim configuration As System.Configuration.Configuration = _
  WebConfigurationManager.OpenWebConfiguration( _
  "/aspnetTest")

' Get the external Authentication section.
  Dim authenticationSection _
  As AuthenticationSection = _
  CType(configuration.GetSection( _
  "system.web/authentication"), AuthenticationSection)

' Get the external Forms section .
  Dim formsAuthentication _
  As FormsAuthenticationConfiguration = _
  authenticationSection.Forms

注釈

このクラスはFormsAuthenticationConfiguration、構成authenticationセクションの要素にプログラムでアクセスして変更するforms方法を提供します。

この型は、型をFormsAuthenticationCredentialsFormsAuthenticationUserCollection含むグループのFormsAuthenticationUser一部です。 コレクション型以外の型は、基になる構成タグに直接影響します。

注意

構成FormsAuthenticationConfigurationファイルの関連セクションに情報を書き込むことができます。値がMachineToApplicationセクション プロパティAllowDefinitionによって定義されている制限に従います。 階層内で許可されていないレベルで構成ファイルに書き込もうとすると、パーサーによってエラー メッセージが生成されます。 ただし、このクラスを使用して、階層内の任意のレベルで構成情報を読み取ることができます。 安全性とスケーラビリティを確保するために、データベースなどの外部リポジトリを使用して、ユーザーの資格情報を保持することをお勧めします。

コンストラクター

FormsAuthenticationConfiguration()

FormsAuthenticationConfiguration クラスの新しいインスタンスを初期化します。

プロパティ

Cookieless

フォーム ベース認証がクッキーを使用するかどうかを示す値を取得または設定します。

CookieSameSite

Cookie の SameSite 属性の値を取得または設定します。

Credentials

ユーザー名とパスワードの FormsAuthenticationCredentials コレクションを取得します。

CurrentConfiguration

現在の Configuration インスタンスが属している構成階層を表す最上位の ConfigurationElement インスタンスへの参照を取得します。

(継承元 ConfigurationElement)
DefaultUrl

既定の URL を取得または設定します。

Domain

フォーム認証クッキーで送信されるドメイン名を取得または設定します。

ElementInformation

ElementInformation オブジェクトのカスタマイズできない情報と機能を格納する ConfigurationElement オブジェクトを取得します。

(継承元 ConfigurationElement)
ElementProperty

ConfigurationElementProperty オブジェクト自体を表す ConfigurationElement オブジェクトを取得します。

(継承元 ConfigurationElement)
EnableCrossAppRedirects

認証されたユーザーを他のアプリケーション内の URL にリダイレクトできるかどうかを示す値を取得または設定します。

EvaluationContext

ContextInformation オブジェクトの ConfigurationElement オブジェクトを取得します。

(継承元 ConfigurationElement)
HasContext

CurrentConfiguration プロパティが null であるかどうかを示す値を取得します。

(継承元 ConfigurationElement)
Item[ConfigurationProperty]

この構成要素のプロパティまたは属性を取得または設定します。

(継承元 ConfigurationElement)
Item[String]

この構成要素のプロパティ、属性、または子要素を取得または設定します。

(継承元 ConfigurationElement)
LockAllAttributesExcept

ロックされている属性のコレクションを取得します。

(継承元 ConfigurationElement)
LockAllElementsExcept

ロックされている要素のコレクションを取得します。

(継承元 ConfigurationElement)
LockAttributes

ロックされている属性のコレクションを取得します。

(継承元 ConfigurationElement)
LockElements

ロックされている要素のコレクションを取得します。

(継承元 ConfigurationElement)
LockItem

要素がロックされているかどうかを示す値を取得または設定します。

(継承元 ConfigurationElement)
LoginUrl

要求に対するリダイレクト URL を取得または設定します。

Name

クッキー名を取得または設定します。

Path

クッキーのパスを取得または設定します。

Properties

プロパティのコレクションを取得します。

(継承元 ConfigurationElement)
Protection

クッキーの暗号化に使用される暗号化タイプを取得または設定します。

RequireSSL

認証情報の送信に SSL (Secure Sockets Layer) 接続が必要であるかどうかを示す値を取得または設定します。

SlidingExpiration

認証のスライド式有効期限を取得または設定します。

TicketCompatibilityMode

チケットの有効期限に関して世界協定時刻 (UTC: Coordinated Universal Time) と現地時間のどちらを使用するかを示す値を取得または設定します。

Timeout

認証タイムアウト期間を取得または設定します。

メソッド

DeserializeElement(XmlReader, Boolean)

構成ファイルから XML を読み取ります。

(継承元 ConfigurationElement)
Equals(Object)

現在の ConfigurationElement インスタンスを、指定したオブジェクトと比較します。

(継承元 ConfigurationElement)
GetHashCode()

現在の ConfigurationElement インスタンスを表す一意の値を取得します。

(継承元 ConfigurationElement)
GetTransformedAssemblyString(String)

指定されたアセンブリ名を変換して返します。

(継承元 ConfigurationElement)
GetTransformedTypeString(String)

指定された型名を変換して返します。

(継承元 ConfigurationElement)
GetType()

現在のインスタンスの Type を取得します。

(継承元 Object)
Init()

ConfigurationElement オブジェクトを初期状態に設定します。

(継承元 ConfigurationElement)
InitializeDefault()

ConfigurationElement オブジェクトの既定の値セットを初期化するために使用します。

(継承元 ConfigurationElement)
IsModified()

派生クラスに実装された場合、この構成要素が最後の保存または読み込み以降に変更されたかどうかを示します。

(継承元 ConfigurationElement)
IsReadOnly()

ConfigurationElement オブジェクトが読み取り専用かどうかを示す値を取得します。

(継承元 ConfigurationElement)
ListErrors(IList)

この ConfigurationElement オブジェクトおよびすべてのサブ要素の無効なプロパティのエラーを、渡されたリストに追加します。

(継承元 ConfigurationElement)
MemberwiseClone()

現在の Object の簡易コピーを作成します。

(継承元 Object)
OnDeserializeUnrecognizedAttribute(String, String)

逆シリカル化中に不明な属性が発生したかどうかを示す値を取得します。

(継承元 ConfigurationElement)
OnDeserializeUnrecognizedElement(String, XmlReader)

逆シリカル化中に不明な要素が発生したかどうかを示す値を取得します。

(継承元 ConfigurationElement)
OnRequiredPropertyNotFound(String)

必要なプロパティが見つからないと例外がスローされます。

(継承元 ConfigurationElement)
PostDeserialize()

逆シリアル化後に呼び出されます。

(継承元 ConfigurationElement)
PreSerialize(XmlWriter)

シリアル化前に呼び出されます。

(継承元 ConfigurationElement)
Reset(ConfigurationElement)

ConfigurationElement オブジェクトの内部状態 (ロックやプロパティ コレクションなど) をリセットします。

(継承元 ConfigurationElement)
ResetModified()

IsModified() メソッドの値が派生クラスに実装されたときに、false にリセットします。

(継承元 ConfigurationElement)
SerializeElement(XmlWriter, Boolean)

派生クラスに実装されている場合、この構成要素の内容を構成ファイルに書き込みます。

(継承元 ConfigurationElement)
SerializeToXmlElement(XmlWriter, String)

派生クラスに実装されている場合、この構成要素の外側のタグを構成ファイルに書き込みます。

(継承元 ConfigurationElement)
SetPropertyValue(ConfigurationProperty, Object, Boolean)

プロパティを指定した値に設定します。

(継承元 ConfigurationElement)
SetReadOnly()

IsReadOnly() オブジェクトおよびすべてのサブ要素に ConfigurationElement プロパティを設定します。

(継承元 ConfigurationElement)
ToString()

現在のオブジェクトを表す文字列を返します。

(継承元 Object)
Unmerge(ConfigurationElement, ConfigurationElement, ConfigurationSaveMode)

保存しないすべての値を削除するには、ConfigurationElement オブジェクトを変更します。

(継承元 ConfigurationElement)

適用対象

こちらもご覧ください