AuditLogLocation 列舉

定義

指定寫入安全性相關事件記錄的位置。

public enum class AuditLogLocation
public enum AuditLogLocation
type AuditLogLocation = 
Public Enum AuditLogLocation
繼承
AuditLogLocation

欄位

Application 1

指定事件記錄檔中的應用程式記錄。

Default 0

指定作業系統所決定的預設位置。 如果支援 (寫入安全性記錄檔,例如 Windows Vista 和 Windows Server 2003 和更新版本平臺) ,則預設記錄檔位置為安全性記錄檔。 否則, (例如Windows XP SP2) 中,預設記錄檔位置為應用程式記錄檔。

Security 2

指定事件記錄檔中的安全性記錄。 呼叫的執行緒必須具備 SeAuditPrivilege 才能寫入安全性記錄檔。

範例

下列範例會將 ServiceSecurityAuditBehavior.AuditLogLocation 屬性設定為其中 AuditLogLocation 一個值:

public static void Main()
{
    // Get base address from appsettings in configuration.
    Uri baseAddress = new Uri(ConfigurationManager.
        AppSettings["baseAddress"]);

    // Create a ServiceHost for the CalculatorService type
    // and provide the base address.
    using (ServiceHost serviceHost = new
        ServiceHost(typeof(CalculatorService), baseAddress))
    {
        // Create a new auditing behavior and set the log location.
        ServiceSecurityAuditBehavior newAudit =
            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<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();
    }
}
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 Communication Foundation (WCF) 需要驗證和/或呼叫端授權的應用程式時,您可以指定針對成功、失敗或兩者記錄與安全性相關的事件。 記錄的位置是由此列舉所決定。

您可以將 MessageAuthenticationAuditLevelServiceAuthorizationAuditLevel 類別的 ServiceSecurityAuditBehavior 屬性設為其中一個 AuditLevel 值來指定稽核記錄的層級。

您也可以使用serviceSecurityAudit > 系 < 結來指定稽核行為。

重要

AuditLogLocation如果 屬性設定為 [安全性],且 Audit Object Access 未在 中 Local Security Policy 設定 ,則不會將稽核事件寫入安全性記錄檔。 這時不會傳回任何失敗,但是稽核項目也不會寫入安全性記錄檔中。 此外,呼叫的執行緒必須具備 SeAuditPrivilege 才能寫入安全性記錄檔。

預設值視作業系統而定

將 屬性設定為預設值時,作業系統會決定實際寫入哪一個記錄檔。 如需詳細資訊,請參閱 稽核

適用於

另請參閱