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 パラメーターに渡されました。

注釈

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

適用対象

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

注釈

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

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 値の 1 つ。

propagationFlags
PropagationFlags

Access Control エントリ (ACE) を子オブジェクトに伝達する方法を指定する PropagationFlags 値の 1 つ。

flags
AuditFlags

監査を実行するタイミングを指定する AuditFlags 値の 1 つ。

例外

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

identity パラメーターはnull

正しくない列挙が flags パラメーターに渡されました。

-又は-

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

注釈

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

適用対象

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 値の 1 つ。

propagationFlags
PropagationFlags

Access Control エントリ (ACE) を子オブジェクトに伝達する方法を指定する PropagationFlags 値の 1 つ。

flags
AuditFlags

監査を実行するタイミングを指定する AuditFlags 値の 1 つ。

注釈

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

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

適用対象