ServiceSecurityAuditBehavior Class
Assembly: System.ServiceModel (in system.servicemodel.dll)
'Declaration Public NotInheritable Class ServiceSecurityAuditBehavior Implements IServiceBehavior 'Usage Dim instance As ServiceSecurityAuditBehavior
public final class ServiceSecurityAuditBehavior implements IServiceBehavior
public final class ServiceSecurityAuditBehavior implements IServiceBehavior
Not applicable.
The ServiceSecurityAuditBehavior class is used to audit Windows Communication Foundation (WCF) authentication events. When auditing is enabled, either successful or failed authentication attempts (or both) can be audited. The events are written to one of three event logs: application, security, or the default log for the operating system version. The event logs can all be viewed using the Windows Event viewer.
Use this class to specify which event log is written to, as well as kinds of authentication events to write. You can also specify whether to suppress audit failures by setting the SuppressAuditFailure property to false (the default is true).
For more information about auditing security events for WCF applications, see Auditing Security Events.
To specify audit behavior in configuration, use the <serviceSecurityAudit> element.
The following code creates an instance of the ServiceHost class and adds a new ServiceSecurityAuditBehavior to its collection of behaviors.
Public Shared Sub Main() ' Get base address from appsettings in configuration. Dim baseAddress As New Uri(ConfigurationManager.AppSettings("baseAddress")) ' Create a ServiceHost for the CalculatorService type ' and provide the base address. Dim serviceHost As New ServiceHost(GetType(CalculatorService), baseAddress) Try ' Create a new auditing behavior and set the log location. Dim newAudit As New ServiceSecurityAuditBehavior() newAudit.AuditLogLocation = AuditLogLocation.Application newAudit.MessageAuthenticationAuditLevel = _ AuditLevel.SuccessOrFailure newAudit.ServiceAuthorizationAuditLevel = _ AuditLevel.SuccessOrFailure newAudit.SuppressAuditFailure = False ' Remove the old behavior and add the new. serviceHost.Description.Behaviors.Remove(Of ServiceSecurityAuditBehavior) serviceHost.Description.Behaviors.Add(newAudit) ' Open the ServiceHostBase to create listeners ' and start listening for messages. serviceHost.Open() ' The service can now be accessed. Console.WriteLine("The service is ready.") Console.WriteLine("Press <ENTER> to terminate service.") Console.WriteLine() Console.ReadLine() ' Close the ServiceHostBase to shutdown the service. serviceHost.Close() Finally End Try End Sub
Windows 98, Windows Server 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.