服務稽核行為
這個範例會示範如何使用 ServiceSecurityAuditBehavior 以啟用稽核服務作業期間的安全性事件。此範例是以使用者入門範例為基礎。服務與用戶端已使用 wsHttpBinding Element完成設定。Security element的 mode 屬性已經設定為 Message,而 clientCredentialType 已經設定為 Windows。在這個範例中,用戶端是主控台應用程式 (.exe),而服務則是由網際網路資訊服務 (IIS) 所裝載。
![]() |
---|
此範例的安裝程序與建置指示位於本主題的結尾。 |
服務組態檔會使用 serviceSecurityAudit 項目設定稽核。
<behaviors>
<serviceBehaviors>
<behavior name="CalculatorServiceBehavior">
...
<!-- serviceSecurityAudit allows specification of audit location and whether to audit success, failure or both. This service logs success and failure of messageAuthentication to the default location -->
<serviceSecurityAudit auditLogLocation ="Default" messageAuthenticationAuditLevel = "SuccessOrFailure" />
</behavior>
</serviceBehaviors>
</behaviors>
當您執行範例時,作業要求和回應會顯示在用戶端主控台視窗中。在主控台視窗中按 ENTER 鍵,即可關閉用戶端。
執行事件檢視器可看到結果稽核記錄。根據預設,在 Windows XP 中,您可以在應用程式記錄檔中查看稽核事件,在 Windows Server 2003 和 Windows Vista 中,則可以在安全性記錄檔中查看稽核事件。將 auditLogLocation 屬性設定為 'Application' 或 'Security',即可指定稽核事件的位置。如需詳細資訊,請參閱 How To: Audit Security Events。如果事件要寫入安全性記錄檔,則 LocalSecurityPolicy-> Enable Object Access 應設為 "Success" 和 "Failure"。
在查看事件記錄檔時,稽核事件的來源為 "ServiceModel Audit 3.0.0.0"。訊息驗證稽核記錄的分類為 "MessageAuthentication",而服務驗證稽核記錄的分類則為 'ServiceAuthorization'。
訊息驗證稽核事件的涵蓋範圍包括訊息是否遭人竄改、訊息是否已過期,以及用戶端是否可驗證服務。這些事件可提供驗證是否成功或失敗、以及用戶端的身分識别、訊息傳送的目的端點,以及與訊息關聯的動作等相關訊息。
服務授權稽核事件的涵蓋範圍則是服務授權管理員決定的授權。這些事件提供的訊息是關於授權是否成功或失敗以及用戶端的身分識别、訊息傳送的目的端點、與訊息相關聯的動作、由傳入訊息產生的授權內容識別碼,以及做出存取決策的授權管理員類型。
若要設定、建置及執行範例
若要建置方案的 C# 或 Visual Basic .NET 版本,請遵循建置 Windows Communication Foundation 範例中的指示。
若要在單一或跨電腦的組態中執行本範例,請遵循執行 Windows Communication Foundation 範例中的指示。
請參閱
其他資源
Auditing
How To: Audit Security Events
Send comments about this topic to Microsoft.
© 2007 Microsoft Corporation. All rights reserved.