次の方法で共有


OnFailure プロパティ

監査が失敗したときに実行されるアクションを取得または設定します。

名前空間:  Microsoft.SqlServer.Management.Smo
アセンブリ:  Microsoft.SqlServer.Smo (Microsoft.SqlServer.Smo.dll)

構文

'宣言
<SfcPropertyAttribute(SfcPropertyFlags.Standalone)> _
Public Property OnFailure As OnFailureAction
    Get
    Set
'使用
Dim instance As Audit
Dim value As OnFailureAction

value = instance.OnFailure

instance.OnFailure = value
[SfcPropertyAttribute(SfcPropertyFlags.Standalone)]
public OnFailureAction OnFailure { get; set; }
[SfcPropertyAttribute(SfcPropertyFlags::Standalone)]
public:
property OnFailureAction OnFailure {
    OnFailureAction get ();
    void set (OnFailureAction value);
}
[<SfcPropertyAttribute(SfcPropertyFlags.Standalone)>]
member OnFailure : OnFailureAction with get, set
function get OnFailure () : OnFailureAction
function set OnFailure (value : OnFailureAction)

プロパティ値

型: Microsoft.SqlServer.Management.Smo. . :: . .OnFailureAction
監査が失敗したときに実行するアクションの種類 (処理を続行する、システムをシャットダウンするなど) を示す OnFailureAction 値。

使用例

次のコード例では、監査が失敗した後でシステムがシャットダウンするよう構成する方法を示します。

C#

using System;
using Microsoft.SqlServer.Management.Smo;

namespace samples
{
    class Program
    {
        static void Main(string[] args)
        {
            //Create the audit
            Server dbServer = new Server("(local)");
            Audit dbAudit = new Audit(dbServer, "Test Audit");
            dbAudit.DestinationType = AuditDestinationType.File;
            dbAudit.FilePath = "C:\\AuditDirectory";
            dbAudit.Create();
             
            //Set the system to shut down if the audit fails
            dbAudit.OnFailure = OnFailureAction.Shutdown;
        }
    }
}

Powershell

#Create the audit 
$dbServer = new-Object Microsoft.SqlServer.Management.Smo.Server("(local)")
$dbAudit = New-Object Microsoft.SqlServer.Management.Smo.Audit($dbServer, "Test Audit")
$dbAudit.DestinationType = [Microsoft.SqlServer.Management.Smo.AuditDestinationType]'File'
$dbAudit.FilePath = "C:\AuditDirectory"
$dbAudit.Create()

#Set the system to shut down if the audit fails
$dbAudit.OnFailure = [Microsoft.SqlServer.Management.Smo.OnFailureAction]'Shutdown'