WebSuccessAuditEvent クラス
アセンブリ: System.Web (system.web.dll 内)
構文
解説
運用および操作の担当者は、ASP.NET Health Monitoring を使用して、配置されている Web アプリケーションを管理できます。System.Web.Management 名前空間には、アプリケーションの状態データをパッケージ化する状態イベント型、およびそのデータを処理するプロバイダ型が含まれます。また、状態イベント管理を支援するサポート型も含まれます。
WebSuccessAuditEvent クラスは、セキュリティ関連の操作が正常であるとき使用されます。たとえば、Web 要求に対する URL 承認が正常である場合です。
次の一覧に、ASP.NET によって生成される WebSuccessAuditEvent 型のイベントの機能を示します。
-
ファイルの承認。正常と承認するための条件が監査されます。ファイルの承認は、Windows ID が要求に関連付けられている場合に ASP.NET だけが実施します。関連するイベント監査コードは AuditFileAuthorizationSuccess です。
-
URL の承認。承認された URL リソースへのアクセスを示します。正常と承認するための条件が監査されます。関連するイベント監査コードは AuditUrlAuthorizationSuccess です。
-
その他のセキュリティ条件。次の一覧に、関連するイベント コードを示します。
-
AuditFormsAuthenticationSuccess
-
AuditMembershipAuthenticationSuccess
-
WebSuccessAuditEvent が発生すると、ASP.NET Health Monitoring は関連する Audit Success Events Raised パフォーマンス カウンタをインクリメントし、healthMonitoring 構成をチェックしてそのイベントをサブスクライブするプロバイダがあるかどうかを確認します。このイベントをサブスクライブするプロバイダがある場合、ASP.NET はそのイベントをディスパッチして処理させます。
メモ Audit Success Event Raised パフォーマンス カウンタをシステム モニタ (PerfMon) に表示するには、[カウンタの追加] ウィンドウで [パフォーマンス オブジェクト] ドロップダウンリストの [ASP.NET] をクリックし、Audit Success Event Raised パフォーマンス カウンタを選択して、[追加] ボタンをクリックします。詳細については、MSDN の「Using the System Monitor (PerfMon) with ASP.NET Applications」を参照してください。
監査の正常終了は予期された条件であることを表すので、サブスクライブは不要です。サイトのアクセス監査を提供する場合はサブスクライブできます。
メモ |
---|
ほとんどの場合、ASP.NET 状態監視型は実装のまま使用でき、healthMonitoring 構成セクションに値を指定して ASP.NET Health Monitoring system を制御できます。状態監視型の派生として独自のイベントおよびプロバイダを作成することもできます。WebSuccessAuditEvent クラスの派生の例については、このトピックの例を参照してください。 |
WebSuccessAuditEvent クラスの派生としてカスタム監査イベントを作成する方法を次のコード例に示します。
また、ASP.NET Health Monitoring でそのイベントを使用できるようにする構成ファイルの抜粋も示します。
Imports System Imports System.Text Imports System.Web Imports System.Web.Management ' Implements a custom WebSuccessAuditEvent class. Public Class SampleWebSuccessAuditEvent Inherits System.Web.Management.WebSuccessAuditEvent 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 'New ' 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 'New ' Raises the SampleWebSuccessAuditEvent. 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 'Raise ' Obtains the current thread information. Public Function GetRequestInformation() As WebRequestInformation ' No customization 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("**SampleWebSuccessAuditEvent 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("** SampleWebSuccessAuditEvent End **") formatter.IndentationLevel -= 1 End Sub 'FormatCustomEventDetails End Class 'SampleWebSuccessAuditEvent
using System; using System.Text; using System.Web; using System.Web.Management; namespace SamplesAspNet { // Implements a custom WebSuccessAuditEvent class. public class SampleWebSuccessAuditEvent : System.Web.Management.WebSuccessAuditEvent { private string customCreatedMsg, customRaisedMsg; // Invoked in case of events identified only by their event code. public SampleWebSuccessAuditEvent(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 SampleWebSuccessAuditEvent(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 SampleWebSuccessAuditEvent. 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 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( "******** SampleWebSuccessAuditEvent 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( "******** SampleWebSuccessAuditEvent End ********"); formatter.IndentationLevel -= 1; } } }
<healthMonitoring
..enabled="true" ..heartBeatInterval="0">
<providers>
<eventMappings>
<rules>
</healthMonitoring>
System.Web.Management.WebBaseEvent
System.Web.Management.WebManagementEvent
System.Web.Management.WebAuditEvent
System.Web.Management.WebSuccessAuditEvent
System.Web.Management.WebAuthenticationSuccessAuditEvent
プラットフォーム
Windows 98, Windows 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。
参照
- WebSuccessAuditEvent クラスのページへのリンク