WebAuthenticationFailureAuditEvent 类
定义
提供有关 ASP.NET 身份验证失败的信息。Provides information about ASP.NET authentication failures.
public ref class WebAuthenticationFailureAuditEvent : System::Web::Management::WebFailureAuditEvent
public class WebAuthenticationFailureAuditEvent : System.Web.Management.WebFailureAuditEvent
type WebAuthenticationFailureAuditEvent = class
inherit WebFailureAuditEvent
Public Class WebAuthenticationFailureAuditEvent
Inherits WebFailureAuditEvent
- 继承
-
WebAuthenticationFailureAuditEvent
示例
下面的代码示例演示如何使用 WebAuthenticationFailureAuditEvent 类。The following code example shows how to use the WebAuthenticationFailureAuditEvent class.
using System;
using System.Text;
using System.Web;
using System.Web.Management;
namespace SamplesAspNet
{
// Implements a custom WebAuthenticationFailureAuditEvent class.
public class SampleWebAuthenticationFailureAuditEvent :
System.Web.Management.WebAuthenticationFailureAuditEvent
{
private string customCreatedMsg, customRaisedMsg;
// Invoked in case of events identified only by
// their event code.
public SampleWebAuthenticationFailureAuditEvent(
string msg, object eventSource,
int eventCode, string userName):
base(msg, eventSource, eventCode, userName)
{
// 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 SampleWebAuthenticationFailureAuditEvent(
string msg, object eventSource,
int eventCode, int detailedCode, string userName):
base(msg, eventSource, eventCode, detailedCode, userName)
{
// Perform custom initialization.
customCreatedMsg =
string.Format("Event created at: {0}",
DateTime.Now.TimeOfDay.ToString());
}
// Raises the SampleWebAuthenticationFailureAuditEvent.
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(
"* SampleWebAuthenticationFailureAuditEvent 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(
"* SampleWebAuthenticationFailureAuditEvent End *");
formatter.IndentationLevel -= 1;
}
}
}
Imports System.Text
Imports System.Web
Imports System.Web.Management
' Implements a custom WebAuthenticationFailureAuditEvent class.
Public Class SampleWebAuthenticationFailureAuditEvent
Inherits System.Web.Management.WebAuthenticationFailureAuditEvent
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, _
ByVal userName As String)
MyBase.New(msg, eventSource, eventCode, userName)
' 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, _
ByVal userName As String)
MyBase.New(msg, eventSource, eventCode, _
detailedCode, userName)
' Perform custom initialization.
customCreatedMsg = _
String.Format( _
"Event created at: {0}", DateTime.Now.TimeOfDay.ToString())
End Sub
' Raises the SampleWebAuthenticationFailureAuditEvent.
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( _
"* SampleWebAuthenticationFailureAuditEvent 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( _
"* SampleWebAuthenticationFailureAuditEvent End *")
formatter.IndentationLevel -= 1
End Sub
End Class
注解
以下列表描述了 WebAuthenticationFailureAuditEvent ASP.NET 默认情况下引发事件的功能。The following list describes the features for which WebAuthenticationFailureAuditEvent events are raised by default by ASP.NET.
备注
默认情况下,ASP.NET 配置为仅记录审核失败条件,因为记录成功条件会严重地消耗系统资源。By default ASP.NET is configured to log audit failure conditions only, as logging success conditions can severely strain system resources. 始终可以将系统配置为记录成功情况。You can always configure the system to log the success conditions.
Forms 身份验证。Forms Authentication. 成功审核包括已进行身份验证的用户名;失败审核不包括用户名,因为它们通常是通过解密或验证失败的票证导致的。While success audits include the user name that was authenticated; failure audits do not include the user name, since they typically result from a ticket that failed decryption or validation. 两者都包含客户端 IP 地址。Both contain the client IP address. 相关事件审核代码为 AuditFormsAuthenticationFailure 。The related event audit code is AuditFormsAuthenticationFailure.
成员身份.Membership. 成功和失败审核都包含尝试的用户名。Both success and failure audits contain the username that was attempted. 这两种形式的审核均不包含所尝试的密码,因为这会在日志中保留有效密码。Neither form of audit will contain the password that was attempted, because that would risk persisting a valid password in the log. 相关事件审核代码为 AuditMembershipAuthenticationFailure 。The related event audit code is AuditMembershipAuthenticationFailure.
如果 WebAuthenticationFailureAuditEvent 引发了,则默认情况下,它会更新 "引发的审核身份验证失败事件" 性能计数器。When a WebAuthenticationFailureAuditEvent is raised, by default it updates the Audit Authentication Failure Events Raised performance counter. 若要在系统监视器中查看此性能计数器 (PerfMon) ,请在 " 添加计数器 " 窗口中选择 " ASP.NET 性能 对象" 下拉列表,选择 " 引发的身份验证失败事件 " 性能计数器,然后单击 " 添加 " 按钮。To view this performance counter in System Monitor (PerfMon), in the Add Counters window select ASP.NET in the Performance object drop-down list, select the Authentication Failure Events Raised performance counter, and click the Add button. 有关详细信息,请参阅 将系统监视器 (PerfMon) 与 ASP.NET 应用程序配合使用。For more information, see Using the System Monitor (PerfMon) with ASP.NET Applications.
备注
在大多数情况下,你将能够使用已实现的 ASP.NET health 监视类型,并且将通过在 "配置" 部分中指定值来控制运行状况监视系统 healthMonitoring 。In most cases you will be able to use the ASP.NET health-monitoring types as implemented, and you will control the health-monitoring system by specifying values in the healthMonitoring configuration section. 还可以从运行状况监视类型派生,以创建自己的自定义事件和提供程序。You can also derive from the health-monitoring types to create your own custom events and providers. 有关从类派生的示例 WebAuthenticationFailureAuditEvent ,请参阅本主题中提供的示例。For an example of deriving from the WebAuthenticationFailureAuditEvent class, see the example provided in this topic.
构造函数
| WebAuthenticationFailureAuditEvent(String, Object, Int32, Int32, String) |
使用指定的事件参数对 WebAuthenticationFailureAuditEvent 类的新实例进行初始化。Initializes a new instance of the WebAuthenticationFailureAuditEvent class with the specified event parameters. |
| WebAuthenticationFailureAuditEvent(String, Object, Int32, String) |
使用指定的事件参数对 WebAuthenticationFailureAuditEvent 类的新实例进行初始化。Initializes a new instance of the WebAuthenticationFailureAuditEvent class with the specified event parameters. |
属性
| EventCode |
获取与该事件关联的代码值。Gets the code value associated with the event. (继承自 WebBaseEvent) |
| EventDetailCode |
获取事件详细信息代码。Gets the event detail code. (继承自 WebBaseEvent) |
| EventID |
获取与事件关联的标识符。Gets the identifier associated with the event. (继承自 WebBaseEvent) |
| EventOccurrence |
获取表示事件发生次数的计数器。Gets a counter that represents the number of times the event has occurred. (继承自 WebBaseEvent) |
| EventSequence |
获取应用程序已引发事件的次数。Gets the number of times the event has been raised by the application. (继承自 WebBaseEvent) |
| EventSource |
获取引发事件的对象。Gets the object that raises the event. (继承自 WebBaseEvent) |
| EventTime |
获取引发事件的时间。Gets the time when the event was raised. (继承自 WebBaseEvent) |
| EventTimeUtc |
获取引发事件的时间。Gets the time when the event was raised. (继承自 WebBaseEvent) |
| Message |
获取描述事件的消息。Gets the message that describes the event. (继承自 WebBaseEvent) |
| NameToAuthenticate |
获取要验证的用户名。Gets the name of the user to authenticate. |
| ProcessInformation |
获取有关 ASP.NET 应用程序承载进程的信息。Gets information about the ASP.NET application-hosting process. (继承自 WebManagementEvent) |
| RequestInformation |
获取与该 Web 请求关联的信息。Get the information associated with the Web request. (继承自 WebAuditEvent) |
方法
| Equals(Object) |
确定指定对象是否等于当前对象。Determines whether the specified object is equal to the current object. (继承自 Object) |
| FormatCustomEventDetails(WebEventFormatter) |
提供事件信息的标准格式设置。Provides standard formatting of the event information. (继承自 WebBaseEvent) |
| GetHashCode() |
作为默认哈希函数。Serves as the default hash function. (继承自 Object) |
| GetType() |
获取当前实例的 Type。Gets the Type of the current instance. (继承自 Object) |
| IncrementPerfCounters() |
递增“引发的审核失败事件”性能计数器。Increments the Audit Failure Events Raised performance counter. (继承自 WebFailureAuditEvent) |
| MemberwiseClone() |
创建当前 Object 的浅表副本。Creates a shallow copy of the current Object. (继承自 Object) |
| Raise() |
通过将事件已发生这一情况通知任何已配置的提供程序来引发事件。Raises an event by notifying any configured provider that the event has occurred. (继承自 WebBaseEvent) |
| ToString() |
为显示而对事件信息进行格式化。Formats event information for display purposes. (继承自 WebBaseEvent) |
| ToString(Boolean, Boolean) |
为显示而对事件信息进行格式化。Formats event information for display purposes. (继承自 WebBaseEvent) |