Instrument for user management events

J.D. Meier, Jason Taylor, Prashant Bansode, Carlos Farre, Madhu Sundararajan, Steve Gregersen.

Use ASP.NET health monitoring to Instrument your application and monitor user management events around authentication and authorization.
Doing this helps you to detect and react to potentially suspicious behavior. It also enables you to gather operations data; for example, to track who is accessing your application and when user account passwords need to be reset.
The following steps show how to instrument your application for user management events
  1. Create a Custom user management web event, by creating a class library and then create a class that inherits from WebAuditEvent.
using System.Web.Management;

public class MyEvent : WebAuditEvent
{

   public MyEvent(string msg, object eventSource, int eventCode): base(msg, eventSource, eventCode)
   {
   }

   public MyEvent(string msg, object eventSource, int eventCode, int eventDetailCode): base(msg, eventSource, eventCode, eventDetailCode)
   {
   }
   public override void FormatCustomEventDetails(WebEventFormatter formatter)
   {
      base.FormatCustomEventDetails(formatter);

      // Display some custom event message
      formatter.AppendLine("Some Critical Event Fired");
}
  1. Configure your WCF Service for Health Monitoring
…
<system.web>
	<healthMonitoring>
		<eventMappings>
			<add name="Some Custom Event" type="MyEventLibrary.MyEvent, MyEventLibrary"/>
		</eventMappings>
		<rules>
			<add name="Custom event" eventName="Some Custom Event" provider="EventLogProvider" minInterval="00:00:01"/>
		</rules>
	</healthMonitoring>
</system.web>
…
  1. Instrument the WCF Service by raising the custom event in a service contract.
[OperationContract]
string InvokeCriticalEvent();
public string InvokeCriticalEvent()
{
    MyEvent obj = new MyEvent("Invoking Some Custom Event", this, WebEventCodes.WebExtendedBase + 1);
    obj.Raise();
    return "Critical event invoked";
}
  1. Verify the Service Events in the Event Log after calling the service method from a Test client.

Last edited Apr 24, 2008 at 12:12 AM by prashantbansode, version 2

Comments

No comments yet.