FileSystemAuditRule コンストラクター

定義

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

オーバーロード

FileSystemAuditRule(IdentityReference, FileSystemRights, AuditFlags)

ユーザー アカウントへの参照、監査規則に関連付けられた操作の種類を指定する値、およびいつ監査を実行するのかを指定する値を使用して、FileSystemAuditRule クラスの新しいインスタンスを初期化します。

FileSystemAuditRule(String, FileSystemRights, AuditFlags)

ユーザー アカウント名、監査規則に関連付けられた操作の種類を指定する値、およびいつ監査を実行するのかを指定する値を使用して、FileSystemAuditRule クラスの新しいインスタンスを初期化します。

FileSystemAuditRule(IdentityReference, FileSystemRights, InheritanceFlags, PropagationFlags, AuditFlags)

ユーザー アカウントへの参照の名前、監査規則に関連付けられた操作の種類を指定する値、権限の継承方法を決定する値、権限の反映方法を決定する値、およびいつ監査を実行するのかを指定する値を使用して、FileSystemAuditRule クラスの新しいインスタンスを初期化します。

FileSystemAuditRule(String, FileSystemRights, InheritanceFlags, PropagationFlags, AuditFlags)

ユーザー アカウント名、監査規則に関連付けられた操作の種類を指定する値、権限の継承方法を決定する値、権限の反映方法を決定する値、およびいつ監査を実行するのかを指定する値を使用して、FileSystemAuditRule クラスの新しいインスタンスを初期化します。

FileSystemAuditRule(IdentityReference, FileSystemRights, AuditFlags)

ユーザー アカウントへの参照、監査規則に関連付けられた操作の種類を指定する値、およびいつ監査を実行するのかを指定する値を使用して、FileSystemAuditRule クラスの新しいインスタンスを初期化します。

public:
 FileSystemAuditRule(System::Security::Principal::IdentityReference ^ identity, System::Security::AccessControl::FileSystemRights fileSystemRights, System::Security::AccessControl::AuditFlags flags);
public FileSystemAuditRule (System.Security.Principal.IdentityReference identity, System.Security.AccessControl.FileSystemRights fileSystemRights, System.Security.AccessControl.AuditFlags flags);
new System.Security.AccessControl.FileSystemAuditRule : System.Security.Principal.IdentityReference * System.Security.AccessControl.FileSystemRights * System.Security.AccessControl.AuditFlags -> System.Security.AccessControl.FileSystemAuditRule
Public Sub New (identity As IdentityReference, fileSystemRights As FileSystemRights, flags As AuditFlags)

パラメーター

identity
IdentityReference

ユーザー アカウントへの参照をカプセル化する IdentityReference オブジェクト。

fileSystemRights
FileSystemRights

監査規則に関連付けられた操作の種類を指定する FileSystemRights 値の 1 つ。

flags
AuditFlags

いつ監査を実行するのかを指定する AuditFlags 値の 1 つ。

例外

identity パラメーターが IdentityReference オブジェクトではありません。

identity パラメーターが null です。

flags パラメーターに誤った列挙体が渡されました。

- または -

None 値が flags パラメーターに渡されました。

注釈

このコンストラクターを使用して、 クラスまたは DirectorySecurity クラスを使用して永続化できる監査規則をFileSecurity作成します。 監査ルールは、ファイルやフォルダーなどのシステム オブジェクトに対して実行されたアクションをいつどのようにログに記録するかを決定します。

適用対象

FileSystemAuditRule(String, FileSystemRights, AuditFlags)

ユーザー アカウント名、監査規則に関連付けられた操作の種類を指定する値、およびいつ監査を実行するのかを指定する値を使用して、FileSystemAuditRule クラスの新しいインスタンスを初期化します。

public:
 FileSystemAuditRule(System::String ^ identity, System::Security::AccessControl::FileSystemRights fileSystemRights, System::Security::AccessControl::AuditFlags flags);
public FileSystemAuditRule (string identity, System.Security.AccessControl.FileSystemRights fileSystemRights, System.Security.AccessControl.AuditFlags flags);
new System.Security.AccessControl.FileSystemAuditRule : string * System.Security.AccessControl.FileSystemRights * System.Security.AccessControl.AuditFlags -> System.Security.AccessControl.FileSystemAuditRule
Public Sub New (identity As String, fileSystemRights As FileSystemRights, flags As AuditFlags)

パラメーター

identity
String

ユーザー アカウント名。

fileSystemRights
FileSystemRights

監査規則に関連付けられた操作の種類を指定する FileSystemRights 値の 1 つ。

flags
AuditFlags

いつ監査を実行するのかを指定する AuditFlags 値の 1 つ。

例外

flags パラメーターに誤った列挙体が渡されました。

- または -

None 値が flags パラメーターに渡されました。

次のコード例では、 クラスを FileSystemAuditRule 使用して、ファイルに対する監査規則の追加と削除を行います。 この例を実行するには、有効なユーザーまたはグループ アカウントを指定する必要があります。

using System;
using System.IO;
using System.Security.AccessControl;

namespace FileSystemExample
{
    class FileExample
    {
        public static void Main()
        {
            try
            {
                string FileName = "test.xml";

                Console.WriteLine("Adding access control entry for " + FileName);

                // Add the access control entry to the file.
                AddFileAuditRule(FileName, @"MYDOMAIN\MyAccount", FileSystemRights.ReadData, AuditFlags.Failure);

                Console.WriteLine("Removing access control entry from " + FileName);

                // Remove the access control entry from the file.
                RemoveFileAuditRule(FileName, @"MYDOMAIN\MyAccount", FileSystemRights.ReadData, AuditFlags.Failure);

                Console.WriteLine("Done.");
            }
            catch (IOException e)
            {
                Console.WriteLine("Unable to open the file: " + e.Message);
            }
            catch (PrivilegeNotHeldException e)
            {
                Console.WriteLine("The current account does not have the correct privileges: " + e.Message);
            }

            Console.ReadLine();
        }

        // Adds an ACL entry on the specified file for the specified account.
        public static void AddFileAuditRule(string FileName, string Account, FileSystemRights Rights, AuditFlags AuditRule)
        {

            // Get a FileSecurity object that represents the
            // current security settings.
            FileSecurity fSecurity = File.GetAccessControl(FileName);

            // Add the FileSystemAuditRule to the security settings.
            fSecurity.AddAuditRule(new FileSystemAuditRule(Account,
                                                            Rights,
                                                            AuditRule));

            // Set the new access settings.
            File.SetAccessControl(FileName, fSecurity);
        }

        // Removes an ACL entry on the specified file for the specified account.
        public static void RemoveFileAuditRule(string FileName, string Account, FileSystemRights Rights, AuditFlags AuditRule)
        {

            // Get a FileSecurity object that represents the
            // current security settings.
            FileSecurity fSecurity = File.GetAccessControl(FileName);

            // Add the FileSystemAuditRule to the security settings.
            fSecurity.RemoveAuditRule(new FileSystemAuditRule(Account,
                                                            Rights,
                                                            AuditRule));

            // Set the new access settings.
            File.SetAccessControl(FileName, fSecurity);
        }
    }
}
Imports System.IO
Imports System.Security.AccessControl



Module FileExample

    Sub Main()
        Try
            Dim FileName As String = "test.xml"

            Console.WriteLine("Adding access control entry for " + FileName)

            ' Add the access control entry to the file.
            AddFileAuditRule(FileName, "MYDOMAIN\MyAccount", FileSystemRights.ReadData, AuditFlags.Failure)

            Console.WriteLine("Removing access control entry from " + FileName)

            ' Remove the access control entry from the file.
            RemoveFileAuditRule(FileName, "MYDOMAIN\MyAccount", FileSystemRights.ReadData, AuditFlags.Failure)

            Console.WriteLine("Done.")
        Catch e As IOException
            Console.WriteLine("Unable to open the file: " & e.Message)
        Catch e As PrivilegeNotHeldException
            Console.WriteLine("The current account does not have the correct privileges: " & e.Message)
        End Try

        Console.ReadLine()

    End Sub


    ' Adds an ACL entry on the specified file for the specified account.
    Sub AddFileAuditRule(ByVal FileName As String, ByVal Account As String, ByVal Rights As FileSystemRights, ByVal AuditRule As AuditFlags)


        ' Get a FileSecurity object that represents the 
        ' current security settings.
        Dim fSecurity As FileSecurity = File.GetAccessControl(FileName)

        ' Add the FileSystemAuditRule to the security settings. 
        fSecurity.AddAuditRule(New FileSystemAuditRule(Account, Rights, AuditRule))

        ' Set the new access settings.
        File.SetAccessControl(FileName, fSecurity)

    End Sub


    ' Removes an ACL entry on the specified file for the specified account.
    Sub RemoveFileAuditRule(ByVal FileName As String, ByVal Account As String, ByVal Rights As FileSystemRights, ByVal AuditRule As AuditFlags)

        ' Get a FileSecurity object that represents the 
        ' current security settings.
        Dim fSecurity As FileSecurity = File.GetAccessControl(FileName)

        ' Add the FileSystemAuditRule to the security settings. 
        fSecurity.RemoveAuditRule(New FileSystemAuditRule(Account, Rights, AuditRule))

        ' Set the new access settings.
        File.SetAccessControl(FileName, fSecurity)

    End Sub
End Module

注釈

このコンストラクターを使用して、 クラスまたは DirectorySecurity クラスを使用して永続化できる監査規則をFileSecurity作成します。 監査ルールは、ファイルやフォルダーなどのシステム オブジェクトに対して実行されたアクションをいつどのようにログに記録するかを決定します。

パラメーターは identity 、現在のコンピューターまたはドメイン上の有効なアカウントを識別する必要があります。 文字列は次の形式になります。ここでDOMAIN、 は有効なドメインまたはコンピューター名の名前で、accountドメインまたはコンピューター上の有効なユーザー アカウントの名前です。 DOMAIN\account

適用対象

FileSystemAuditRule(IdentityReference, FileSystemRights, InheritanceFlags, PropagationFlags, AuditFlags)

ユーザー アカウントへの参照の名前、監査規則に関連付けられた操作の種類を指定する値、権限の継承方法を決定する値、権限の反映方法を決定する値、およびいつ監査を実行するのかを指定する値を使用して、FileSystemAuditRule クラスの新しいインスタンスを初期化します。

public:
 FileSystemAuditRule(System::Security::Principal::IdentityReference ^ identity, System::Security::AccessControl::FileSystemRights fileSystemRights, System::Security::AccessControl::InheritanceFlags inheritanceFlags, System::Security::AccessControl::PropagationFlags propagationFlags, System::Security::AccessControl::AuditFlags flags);
public FileSystemAuditRule (System.Security.Principal.IdentityReference identity, System.Security.AccessControl.FileSystemRights fileSystemRights, System.Security.AccessControl.InheritanceFlags inheritanceFlags, System.Security.AccessControl.PropagationFlags propagationFlags, System.Security.AccessControl.AuditFlags flags);
new System.Security.AccessControl.FileSystemAuditRule : System.Security.Principal.IdentityReference * System.Security.AccessControl.FileSystemRights * System.Security.AccessControl.InheritanceFlags * System.Security.AccessControl.PropagationFlags * System.Security.AccessControl.AuditFlags -> System.Security.AccessControl.FileSystemAuditRule
Public Sub New (identity As IdentityReference, fileSystemRights As FileSystemRights, inheritanceFlags As InheritanceFlags, propagationFlags As PropagationFlags, flags As AuditFlags)

パラメーター

identity
IdentityReference

ユーザー アカウントへの参照をカプセル化する IdentityReference オブジェクト。

fileSystemRights
FileSystemRights

監査規則に関連付けられた操作の種類を指定する FileSystemRights 値の 1 つ。

inheritanceFlags
InheritanceFlags

子オブジェクトにアクセス マスクを反映する方法を指定する InheritanceFlags 値のいずれか。

propagationFlags
PropagationFlags

子オブジェクトにアクセス制御エントリ (ACE) を反映する方法を指定する PropagationFlags 値のいずれか。

flags
AuditFlags

いつ監査を実行するのかを指定する AuditFlags 値の 1 つ。

例外

identity パラメーターが IdentityReference オブジェクトではありません。

identity パラメーターが null です。

flags パラメーターに誤った列挙体が渡されました。

- または -

None 値が flags パラメーターに渡されました。

注釈

このコンストラクターを使用して、 クラスまたは DirectorySecurity クラスを使用して永続化できる監査規則をFileSecurity作成します。 監査ルールは、ファイルやフォルダーなどのシステム オブジェクトに対して実行されたアクションをいつどのようにログに記録するかを決定します。

適用対象

FileSystemAuditRule(String, FileSystemRights, InheritanceFlags, PropagationFlags, AuditFlags)

ユーザー アカウント名、監査規則に関連付けられた操作の種類を指定する値、権限の継承方法を決定する値、権限の反映方法を決定する値、およびいつ監査を実行するのかを指定する値を使用して、FileSystemAuditRule クラスの新しいインスタンスを初期化します。

public:
 FileSystemAuditRule(System::String ^ identity, System::Security::AccessControl::FileSystemRights fileSystemRights, System::Security::AccessControl::InheritanceFlags inheritanceFlags, System::Security::AccessControl::PropagationFlags propagationFlags, System::Security::AccessControl::AuditFlags flags);
public FileSystemAuditRule (string identity, System.Security.AccessControl.FileSystemRights fileSystemRights, System.Security.AccessControl.InheritanceFlags inheritanceFlags, System.Security.AccessControl.PropagationFlags propagationFlags, System.Security.AccessControl.AuditFlags flags);
new System.Security.AccessControl.FileSystemAuditRule : string * System.Security.AccessControl.FileSystemRights * System.Security.AccessControl.InheritanceFlags * System.Security.AccessControl.PropagationFlags * System.Security.AccessControl.AuditFlags -> System.Security.AccessControl.FileSystemAuditRule
Public Sub New (identity As String, fileSystemRights As FileSystemRights, inheritanceFlags As InheritanceFlags, propagationFlags As PropagationFlags, flags As AuditFlags)

パラメーター

identity
String

ユーザー アカウント名。

fileSystemRights
FileSystemRights

監査規則に関連付けられた操作の種類を指定する FileSystemRights 値の 1 つ。

inheritanceFlags
InheritanceFlags

子オブジェクトにアクセス マスクを反映する方法を指定する InheritanceFlags 値のいずれか。

propagationFlags
PropagationFlags

子オブジェクトにアクセス制御エントリ (ACE) を反映する方法を指定する PropagationFlags 値のいずれか。

flags
AuditFlags

いつ監査を実行するのかを指定する AuditFlags 値の 1 つ。

注釈

このコンストラクターを使用して、 クラスまたは DirectorySecurity クラスを使用して永続化できる監査規則をFileSecurity作成します。 監査ルールは、ファイルやフォルダーなどのシステム オブジェクトに対して実行されたアクションをいつどのようにログに記録するかを決定します。

パラメーターは identity 、現在のコンピューターまたはドメイン上の有効なアカウントを識別する必要があります。 文字列は次の形式になります。ここでDOMAIN、 は有効なドメインまたはコンピューター名の名前で、accountドメインまたはコンピューター上の有効なユーザー アカウントの名前です。 DOMAIN\account

適用対象