ServiceSecurityAuditBehavior クラス

定義

セキュリティ イベントの監査動作を指定します。 セキュリティ イベントは通常、トランスポート認証、メッセージ認証、ネゴシエート認証などの認証イベントと承認イベントで構成されます。 詳細については、「ServiceAuthorizationManager」を参照してください。

public ref class ServiceSecurityAuditBehavior sealed : System::ServiceModel::Description::IServiceBehavior
public sealed class ServiceSecurityAuditBehavior : System.ServiceModel.Description.IServiceBehavior
type ServiceSecurityAuditBehavior = class
    interface IServiceBehavior
Public NotInheritable Class ServiceSecurityAuditBehavior
Implements IServiceBehavior
継承
ServiceSecurityAuditBehavior
実装

ServiceHost クラスのインスタンスを作成し、新しい ServiceSecurityAuditBehavior をその動作のコレクションに追加するコード例を次に示します。

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

注釈

クラスは ServiceSecurityAuditBehavior 、Windows Communication Foundation (WCF) 認証イベントを監査するために使用されます。 監査を有効にすると、成功した認証、失敗した認証、またはその両方を監査できます。 イベントは、3 種類のイベント ログ (アプリケーション ログ、セキュリティ ログ、およびオペレーティング システムのバージョンに対する既定のログ) のいずれかに書き込まれます。 イベント ログはすべて、Windows イベント ビューアーを使用して表示できます。

このクラスを使用して、書き込み先のイベント ログと書き込む認証イベントの種類を指定します。 また、SuppressAuditFailure プロパティ (既定値は false) を true に設定することにより、監査エラーを非表示にするかどうかを指定することもできます。

WCF アプリケーションのセキュリティ イベントの監査の詳細については、「 監査」を参照してください。

構成で監査動作を指定するには、serviceSecurityAudit> を使用します<

コンストラクター

ServiceSecurityAuditBehavior()

ServiceSecurityAuditBehavior クラスの新しいインスタンスを初期化します。

プロパティ

AuditLogLocation

セキュリティ関連のイベント ログが書き込まれる場所を取得または設定します。

MessageAuthenticationAuditLevel

メッセージ レベルで監査する認証イベントの種類を取得または設定します。

ServiceAuthorizationAuditLevel

サービス レベルで監査する承認イベントの種類を取得または設定します。

SuppressAuditFailure

監査の失敗がアプリケーションに影響を及ぼすかどうかを示す値を取得または設定します。

メソッド

Equals(Object)

指定されたオブジェクトが現在のオブジェクトと等しいかどうかを判断します。

(継承元 Object)
GetHashCode()

既定のハッシュ関数として機能します。

(継承元 Object)
GetType()

現在のインスタンスの Type を取得します。

(継承元 Object)
MemberwiseClone()

現在の Object の簡易コピーを作成します。

(継承元 Object)
ToString()

現在のオブジェクトを表す文字列を返します。

(継承元 Object)

明示的なインターフェイスの実装

IServiceBehavior.AddBindingParameters(ServiceDescription, ServiceHostBase, Collection<ServiceEndpoint>, BindingParameterCollection)

コントラクトの実装をサポートするカスタム データをバインド要素に渡します。

IServiceBehavior.ApplyDispatchBehavior(ServiceDescription, ServiceHostBase)

ランタイム プロパティの値を変更したり、エラー ハンドラー、メッセージ インターセプター、パラメーター インターセプター、セキュリティ拡張などのカスタム拡張オブジェクトを挿入したりできるようにします。

IServiceBehavior.Validate(ServiceDescription, ServiceHostBase)

実装されていません。

適用対象