AuditLevel Enum
Definisi
Penting
Beberapa informasi terkait produk prarilis yang dapat diubah secara signifikan sebelum dirilis. Microsoft tidak memberikan jaminan, tersirat maupun tersurat, sehubungan dengan informasi yang diberikan di sini.
Menentukan kapan harus mengaudit peristiwa keamanan.
public enum class AuditLevel
public enum AuditLevel
type AuditLevel =
Public Enum AuditLevel
- Warisan
Bidang
| Nama | Nilai | Deskripsi |
|---|---|---|
| None | 0 | Tidak ada peristiwa yang akan direkam. Ini adalah default. |
| Success | 1 | Hanya peristiwa terkait keamanan yang berhasil yang akan direkam. |
| Failure | 2 | Hanya peristiwa terkait keamanan yang gagal yang akan direkam. |
| SuccessOrFailure | 3 | Peristiwa terkait keamanan yang gagal dan berhasil akan direkam. |
Contoh
Contoh berikut mengatur MessageAuthenticationAuditLevel properti dan ServiceAuthorizationAuditLevel ke salah AuditLevel satu nilai.
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
Keterangan
Saat membuat aplikasi Windows Communication Foundation (WCF) yang memerlukan autentikasi dan/atau otorisasi pemanggil, Anda dapat menentukan bahwa peristiwa yang terkait dengan keamanan dicatat untuk keberhasilan, kegagalan, atau keduanya. Tingkat audit ditentukan oleh enumerasi ini.
Lokasi log audit ditentukan dengan mengatur AuditLogLocation properti ServiceSecurityAuditBehavior kelas ke salah AuditLogLocation satu nilai.
Untuk informasi selengkapnya tentang audit, lihat Audit.
Anda juga dapat menentukan perilaku audit menggunakan <pengikatan serviceSecurityAudit> .