Share via


WebFailureAuditEvent クラス

定義

セキュリティ障害に関する情報を提供します。

public ref class WebFailureAuditEvent : System::Web::Management::WebAuditEvent
public class WebFailureAuditEvent : System.Web.Management.WebAuditEvent
type WebFailureAuditEvent = class
    inherit WebAuditEvent
Public Class WebFailureAuditEvent
Inherits WebAuditEvent
継承
派生

次のコード例では、 クラスから WebFailureAuditEvent 派生してカスタム監査イベントを作成する方法を示します。


using System;
using System.Text;
using System.Web;
using System.Web.Management;

namespace SamplesAspNet
{
    // Implements a custom WebFailureAuditEvent class. 
    public class SampleWebFailureAuditEvent : 
        System.Web.Management.WebFailureAuditEvent
    {
        private string customCreatedMsg, customRaisedMsg;

        // Invoked in case of events identified only by their event code.
        public SampleWebFailureAuditEvent(string msg, object eventSource,
            int eventCode):
        base(msg, eventSource, eventCode)
        {
            // Perform custom initialization.
            customCreatedMsg =
                string.Format("Event created at: {0}",
                DateTime.Now.TimeOfDay.ToString());
        }

        // Invoked in case of events identified by their event code and 
        // event detailed code.
        public SampleWebFailureAuditEvent(string msg, object eventSource,
            int eventCode, int detailedCode):
        base(msg, eventSource, eventCode, detailedCode)
        {
            // Perform custom initialization.
            customCreatedMsg =
            string.Format("Event created at: {0}",
                DateTime.Now.TimeOfDay.ToString());
        }


        // Raises the SampleWebFailureAuditEvent.
        public override void Raise()
        {
            // Perform custom processing.
            customRaisedMsg =
                string.Format("Event raised at: {0}", 
                DateTime.Now.TimeOfDay.ToString());

            // Raise the event.
            WebBaseEvent.Raise(this);
        }

        // Obtains the current thread information.
        public WebRequestInformation GetRequestInformation()
        {
            // No customization is allowed.
            return RequestInformation;
        }

        //Formats Web request event information.
        //This method is invoked indirectly by the provider 
        //using one of the overloaded ToString methods.
        public override void FormatCustomEventDetails(WebEventFormatter formatter)
        {
            base.FormatCustomEventDetails(formatter);

            // Add custom data.
            formatter.AppendLine("");

            formatter.IndentationLevel += 1;
            formatter.AppendLine(
                "******** SampleWebFailureAuditEvent Start ********");
            formatter.AppendLine(string.Format("Request path: {0}",
                RequestInformation.RequestPath));
            formatter.AppendLine(string.Format("Request Url: {0}",
                RequestInformation.RequestUrl));

            // Display custom event timing.
            formatter.AppendLine(customCreatedMsg);
            formatter.AppendLine(customRaisedMsg);

            formatter.AppendLine(
                "******** SampleWebFailureAuditEvent End ********");

            formatter.IndentationLevel -= 1;
        }
    }
}
Imports System.Text
Imports System.Web
Imports System.Web.Management


' Implements a custom WebFailureAuditEvent class. 

Public Class SampleWebFailureAuditEvent
    Inherits System.Web.Management.WebFailureAuditEvent
    Private customCreatedMsg, customRaisedMsg As String
    
    
    
    ' Invoked in case of events identified only by their event code.
    Public Sub New(ByVal msg As String, _
    ByVal eventSource As Object, ByVal eventCode As Integer)
        MyBase.New(msg, eventSource, eventCode)
        ' Perform custom initialization.
        customCreatedMsg = String.Format("Event created at: {0}", _
        DateTime.Now.TimeOfDay.ToString())

    End Sub
    
    
    ' Invoked in case of events identified by their event code and 
    ' event detailed code.
    Public Sub New(ByVal msg As String, ByVal eventSource As Object, _
    ByVal eventCode As Integer, ByVal detailedCode As Integer)
        MyBase.New(msg, eventSource, eventCode, detailedCode)
        ' Perform custom initialization.
        customCreatedMsg = String.Format("Event created at: {0}", _
        DateTime.Now.TimeOfDay.ToString())

    End Sub
    
    
    
    ' Raises the SampleWebFailureAuditEvent.
    Public Overrides Sub Raise() 
        ' Perform custom processing.
        customRaisedMsg = String.Format("Event raised at: {0}", _
        DateTime.Now.TimeOfDay.ToString())
        
        ' Raise the event.
        WebBaseEvent.Raise(Me)
    
    End Sub
    
    
    ' Obtains the current thread information.
    Public Function GetRequestInformation() As WebRequestInformation 
        ' No customization is allowed.
        Return RequestInformation
    
    End Function 'GetRequestInformation
    
    
    'Formats Web request event information.
    'This method is invoked indirectly by the provider 
    'using one of the overloaded ToString methods.
    Public Overrides Sub FormatCustomEventDetails(ByVal formatter _
    As WebEventFormatter)
        MyBase.FormatCustomEventDetails(formatter)

        ' Add custom data.
        formatter.AppendLine("")

        formatter.IndentationLevel += 1
        formatter.AppendLine("******** SampleWebFailureAuditEvent Start ********")
        formatter.AppendLine(String.Format("Request path: {0}", _
        RequestInformation.RequestPath))
        formatter.AppendLine(String.Format("Request Url: {0}", _
        RequestInformation.RequestUrl))

        ' Display custom event timing.
        formatter.AppendLine(customCreatedMsg)
        formatter.AppendLine(customRaisedMsg)

        formatter.AppendLine("******** SampleWebFailureAuditEvent End ********")

        formatter.IndentationLevel -= 1

    End Sub

End Class

次の構成の抜粋は、ASP.NET で イベントを使用できるようにする方法を WebFailureAuditEvent 示しています。

<healthMonitoring
enabled="true"
heartBeatInterval="0">
<providers>
<add name="EventLogProvider"
type="System.Web.Management.EventLogWebEventProvider,
System.Web,Version=2.0.3600.0,Culture=neutral,
PublicKeyToken=b03f5f7f11d50a3a"/>
</providers>

<eventMappings>
<add  name="SampleWebFailureAuditEvent"
type="SamplesAspNet.SampleWebFailureAuditEvent,
webfailureauditevent,Version=1.0.1663.31140,
Culture=neutral,
PublicKeyToken=0d1fa0f69d94de96,
processorArchitecture=MSIL"/>
</eventMappings>

<rules>
<add name="Custom Failure Audit Default"
eventName=" SampleWebFailureAuditEvent "
provider="EventLogProvider"
profile="Default"/>
</rules>

</healthMonitoring>

注釈

ASP.NET 正常性の監視により、運用スタッフと運用スタッフはデプロイされた Web アプリケーションを管理できます。 System.Web.Management名前空間には、アプリケーションの正常性状態データのパッケージ化を担当する正常性イベントの種類と、このデータの処理を担当するプロバイダーの種類が含まれています。 また、正常性イベントの管理中に役立つサポート型も含まれています。

クラスは WebFailureAuditEvent 、セキュリティ操作が失敗したときに使用されます。 この例は、Web 要求の URL 承認に失敗した場合です。

既定では、ASP.NET は次の機能のイベントを WebFailureAuditEvent 発生するように構成されています。

イベントが WebFailureAuditEvent 発生すると、ASP.NET 正常性監視によって、関連する Audit Failure Events Raised パフォーマンス カウンターがインクリメントされ、構成セクションがチェック healthMonitoring され、プロバイダーがイベントをサブスクライブするかどうかを判断します。 プロバイダーがイベントをサブスクライブする場合、ASP.NET は処理のためにイベントをディスパッチします。

Note

システム モニター (PerfMon) で [Audit Failure Events Raised performance counter]\(失敗イベント発生の監査\) パフォーマンス カウンターを表示するには、[カウンターの追加] ウィンドウで、[パフォーマンス オブジェクト] ドロップダウン リストから [ASP.NET] を選択し、[Audit Failure Events Raised]\(失敗イベント発生の監査\) パフォーマンス カウンターを選択し、[追加] ボタンをクリックします。

Note

ほとんどの場合、実装されている ASP.NET の正常性監視の種類を使用でき、構成セクションで値を指定して正常性監視システムを healthMonitoring 制御します。 正常性監視の種類から派生して、独自のカスタム イベントとプロバイダーを作成することもできます。 クラスからの WebFailureAuditEvent 派生の例については、「例」セクションを参照してください。

注意 (継承者)

カスタム イベント情報を表示用に書式設定する場合は、 メソッドではなく メソッドをToStringオーバーライドFormatCustomEventDetails(WebEventFormatter)します。 これにより、機密性の高いシステム情報の上書きや改ざんを回避できます。

コンストラクター

WebFailureAuditEvent(String, Object, Int32)

指定されたパラメーターを使用して、WebFailureAuditEvent クラスの新しいインスタンスを初期化します。

WebFailureAuditEvent(String, Object, Int32, Int32)

指定されたパラメーターを使用して、WebFailureAuditEvent クラスの新しいインスタンスを初期化します。

プロパティ

EventCode

イベントに関連付けられているコード値を取得します。

(継承元 WebBaseEvent)
EventDetailCode

イベント詳細コードを取得します。

(継承元 WebBaseEvent)
EventID

イベントに関連付けられた識別子を取得します。

(継承元 WebBaseEvent)
EventOccurrence

イベントが発生した回数を表すカウンターを取得します。

(継承元 WebBaseEvent)
EventSequence

アプリケーションによるイベントの発生回数を取得します。

(継承元 WebBaseEvent)
EventSource

イベントを発生させるオブジェクトを取得します。

(継承元 WebBaseEvent)
EventTime

イベントが発生した時刻を取得します。

(継承元 WebBaseEvent)
EventTimeUtc

イベントが発生した時刻を取得します。

(継承元 WebBaseEvent)
Message

イベントを説明するメッセージを取得します。

(継承元 WebBaseEvent)
ProcessInformation

ASP.NET アプリケーション ホスト プロセスに関する情報を取得します。

(継承元 WebManagementEvent)
RequestInformation

Web 要求に関連付けられた情報を取得します。

(継承元 WebAuditEvent)

メソッド

Equals(Object)

指定されたオブジェクトが現在のオブジェクトと等しいかどうかを判断します。

(継承元 Object)
FormatCustomEventDetails(WebEventFormatter)

イベント情報の標準的な形式を提供します。

(継承元 WebBaseEvent)
GetHashCode()

既定のハッシュ関数として機能します。

(継承元 Object)
GetType()

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

(継承元 Object)
IncrementPerfCounters()

Audit Failure Events Raised パフォーマンス カウンターをインクリメントします。

MemberwiseClone()

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

(継承元 Object)
Raise()

イベントを発生させ、構成されているプロバイダーにそのイベントが発生したことを通知します。

(継承元 WebBaseEvent)
ToString()

イベント情報を表示用に書式設定します。

(継承元 WebBaseEvent)
ToString(Boolean, Boolean)

イベント情報を表示用に書式設定します。

(継承元 WebBaseEvent)

適用対象

こちらもご覧ください