FileSystemAuditRule クラス
アセンブリ: mscorlib (mscorlib.dll 内)


FileSystemAuditRule クラスは、ユーザー アカウント、提供するアクセスの種類 (読み取り、書き込みなど)、および監査を実行するかどうかなどを指定する、基になるアクセス制御エントリ (ACE) の抽象化を表します。このクラスでは、オブジェクトからの監査規則の継承方法およびオブジェクトへの監査規則の反映方法も指定できます。
Microsoft Windows NT 以降でファイル監査とディレクトリ監査を実行するには、使用しているマシンで Audit Access Security ポリシーを有効にする必要があります。既定では、このポリシーは No Auditing に設定されます。
Audit Access Security ポリシーを有効にするには、次の手順を実行します。
-
Administrative Tools フォルダにある Local Security Settings Microsoft 管理コンソール (MMC: Microsoft Management Console) スナップインを開きます。
-
MMC スナップインの右ペインで Audit object access エントリをダブルクリックするか、または右クリックで表示されるプロパティのオプションをクリックして Audit object access Properties dialog を表示します。
ユーザー アカウントの監査規則には、同じユーザー アカウントの対応するアクセス規則が必要です。
FileSystemAuditRule クラスを使用して、新しい監査規則を作成します。FileSecurity クラスまたは DirectorySecurity クラスを使用して、この規則を永続化できます。

FileSystemAuditRule クラスを使用して、ファイルに監査規則を追加し、次にファイルから監査規則を削除するコード例を次に示します。この例を実行するには、有効なユーザー アカウントまたはグループ アカウントを指定する必要があります。
Imports System 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 Exception Console.WriteLine(e) 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
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 (Exception e) { Console.WriteLine(e); } 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); } } }

System.Security.AccessControl.AuthorizationRule
System.Security.AccessControl.AuditRule
System.Security.AccessControl.FileSystemAuditRule


Windows 98, Windows 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


FileSystemAuditRule コンストラクタ (String, FileSystemRights, InheritanceFlags, PropagationFlags, AuditFlags)
アセンブリ: mscorlib (mscorlib.dll 内)

Public Sub New ( _ identity As String, _ fileSystemRights As FileSystemRights, _ inheritanceFlags As InheritanceFlags, _ propagationFlags As PropagationFlags, _ flags As AuditFlags _ )
Dim identity As String Dim fileSystemRights As FileSystemRights Dim inheritanceFlags As InheritanceFlags Dim propagationFlags As PropagationFlags Dim flags As AuditFlags Dim instance As New FileSystemAuditRule(identity, fileSystemRights, inheritanceFlags, propagationFlags, flags)
public FileSystemAuditRule ( string identity, FileSystemRights fileSystemRights, InheritanceFlags inheritanceFlags, PropagationFlags propagationFlags, AuditFlags flags )
public: FileSystemAuditRule ( String^ identity, FileSystemRights fileSystemRights, InheritanceFlags inheritanceFlags, PropagationFlags propagationFlags, AuditFlags flags )
public FileSystemAuditRule ( String identity, FileSystemRights fileSystemRights, InheritanceFlags inheritanceFlags, PropagationFlags propagationFlags, AuditFlags flags )
public function FileSystemAuditRule ( identity : String, fileSystemRights : FileSystemRights, inheritanceFlags : InheritanceFlags, propagationFlags : PropagationFlags, flags : AuditFlags )

このコンストラクタを使用して、FileSecurity クラスまたは DirectorySecurity クラスを使用して永続化できる監査規則を作成します。監査規則は、ファイルやフォルダなどのシステム オブジェクトに対して実行されるアクションがいつ、どのようにログに記録されるかを決定します。
identity パラメータでは、現在のコンピュータまたはドメイン上の有効なアカウントを識別する必要があります。文字列は DOMAIN\account という形式になります。DOMAIN は有効なドメイン名またはコンピュータ名で、account はドメインまたはコンピュータ上の有効なユーザー アカウント名です。


Windows 98, Windows 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


FileSystemAuditRule コンストラクタ (String, FileSystemRights, AuditFlags)
アセンブリ: mscorlib (mscorlib.dll 内)

Public Sub New ( _ identity As String, _ fileSystemRights As FileSystemRights, _ flags As AuditFlags _ )
Dim identity As String Dim fileSystemRights As FileSystemRights Dim flags As AuditFlags Dim instance As New FileSystemAuditRule(identity, fileSystemRights, flags)
public: FileSystemAuditRule ( String^ identity, FileSystemRights fileSystemRights, AuditFlags flags )
public function FileSystemAuditRule ( identity : String, fileSystemRights : FileSystemRights, flags : AuditFlags )


このコンストラクタを使用して、FileSecurity クラスまたは DirectorySecurity クラスを使用して永続化できる監査規則を作成します。監査規則は、ファイルやフォルダなどのシステム オブジェクトに対して実行されるアクションがいつ、どのようにログに記録されるかを決定します。
identity パラメータでは、現在のコンピュータまたはドメイン上の有効なアカウントを識別する必要があります。文字列は DOMAIN\account という形式になります。DOMAIN は有効なドメイン名またはコンピュータ名で、account はドメインまたはコンピュータ上の有効なユーザー アカウント名です。

FileSystemAuditRule クラスを使用して、ファイルに監査規則を追加し、次にファイルから監査規則を削除するコード例を次に示します。この例を実行するには、有効なユーザー アカウントまたはグループ アカウントを指定する必要があります。
Imports System 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 Exception Console.WriteLine(e) 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
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 (Exception e) { Console.WriteLine(e); } 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); } } }

Windows 98, Windows 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


FileSystemAuditRule コンストラクタ (IdentityReference, FileSystemRights, AuditFlags)
アセンブリ: mscorlib (mscorlib.dll 内)

Public Sub New ( _ identity As IdentityReference, _ fileSystemRights As FileSystemRights, _ flags As AuditFlags _ )
Dim identity As IdentityReference Dim fileSystemRights As FileSystemRights Dim flags As AuditFlags Dim instance As New FileSystemAuditRule(identity, fileSystemRights, flags)
public FileSystemAuditRule ( IdentityReference identity, FileSystemRights fileSystemRights, AuditFlags flags )
public: FileSystemAuditRule ( IdentityReference^ identity, FileSystemRights fileSystemRights, AuditFlags flags )
public FileSystemAuditRule ( IdentityReference identity, FileSystemRights fileSystemRights, AuditFlags flags )
public function FileSystemAuditRule ( identity : IdentityReference, fileSystemRights : FileSystemRights, flags : AuditFlags )
- identity
ユーザー アカウントへの参照をカプセル化する IdentityReference オブジェクト。


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

Windows 98, Windows 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


FileSystemAuditRule コンストラクタ (IdentityReference, FileSystemRights, InheritanceFlags, PropagationFlags, AuditFlags)
アセンブリ: mscorlib (mscorlib.dll 内)

Public Sub New ( _ identity As IdentityReference, _ fileSystemRights As FileSystemRights, _ inheritanceFlags As InheritanceFlags, _ propagationFlags As PropagationFlags, _ flags As AuditFlags _ )
Dim identity As IdentityReference Dim fileSystemRights As FileSystemRights Dim inheritanceFlags As InheritanceFlags Dim propagationFlags As PropagationFlags Dim flags As AuditFlags Dim instance As New FileSystemAuditRule(identity, fileSystemRights, inheritanceFlags, propagationFlags, flags)
public FileSystemAuditRule ( IdentityReference identity, FileSystemRights fileSystemRights, InheritanceFlags inheritanceFlags, PropagationFlags propagationFlags, AuditFlags flags )
public: FileSystemAuditRule ( IdentityReference^ identity, FileSystemRights fileSystemRights, InheritanceFlags inheritanceFlags, PropagationFlags propagationFlags, AuditFlags flags )
public FileSystemAuditRule ( IdentityReference identity, FileSystemRights fileSystemRights, InheritanceFlags inheritanceFlags, PropagationFlags propagationFlags, AuditFlags flags )
public function FileSystemAuditRule ( identity : IdentityReference, fileSystemRights : FileSystemRights, inheritanceFlags : InheritanceFlags, propagationFlags : PropagationFlags, flags : AuditFlags )
- identity
ユーザー アカウントへの参照をカプセル化する IdentityReference オブジェクト。


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

Windows 98, Windows 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


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 プロパティ

名前 | 説明 | |
---|---|---|
![]() | AuditFlags | この監査規則の監査フラグを取得します。 ( AuditRule から継承されます。) |
![]() | FileSystemRights | 現在の FileSystemAuditRule オブジェクトに関連付けられている FileSystemRights フラグを取得します。 |
![]() | IdentityReference | この規則を適用する IdentityReference を取得します。 ( AuthorizationRule から継承されます。) |
![]() | InheritanceFlags | この規則を子オブジェクトが継承する方法を決定するフラグの値を取得します。 ( AuthorizationRule から継承されます。) |
![]() | IsInherited | この規則を明示的に設定するか、または親コンテナ オブジェクトから継承するかを指定する値を取得します。 ( AuthorizationRule から継承されます。) |
![]() | PropagationFlags | 反映フラグの値を取得します。このフラグから、この規則を子オブジェクトに反映させる方法を判断します。このプロパティが重要なのは、InheritanceFlags 列挙体の値が None でない場合だけです。 ( AuthorizationRule から継承されます。) |

FileSystemAuditRule メソッド

名前 | 説明 | |
---|---|---|
![]() | Equals | オーバーロードされます。 2 つの Object インスタンスが等しいかどうかを判断します。 ( Object から継承されます。) |
![]() | GetHashCode | 特定の型のハッシュ関数として機能します。GetHashCode は、ハッシュ アルゴリズムや、ハッシュ テーブルのようなデータ構造での使用に適しています。 ( Object から継承されます。) |
![]() | GetType | 現在のインスタンスの Type を取得します。 ( Object から継承されます。) |
![]() | ReferenceEquals | 指定した複数の Object インスタンスが同一かどうかを判断します。 ( Object から継承されます。) |
![]() | ToString | 現在の Object を表す String を返します。 ( Object から継承されます。) |

FileSystemAuditRule メンバ
ファイルまたはディレクトリの監査規則を定義するアクセス制御エントリ (ACE: Access Control Entry) の抽象化を表します。このクラスは継承できません。
FileSystemAuditRule データ型で公開されるメンバを以下の表に示します。


名前 | 説明 | |
---|---|---|
![]() | AuditFlags | この監査規則の監査フラグを取得します。(AuditRule から継承されます。) |
![]() | FileSystemRights | 現在の FileSystemAuditRule オブジェクトに関連付けられている FileSystemRights フラグを取得します。 |
![]() | IdentityReference | この規則を適用する IdentityReference を取得します。(AuthorizationRule から継承されます。) |
![]() | InheritanceFlags | この規則を子オブジェクトが継承する方法を決定するフラグの値を取得します。(AuthorizationRule から継承されます。) |
![]() | IsInherited | この規則を明示的に設定するか、または親コンテナ オブジェクトから継承するかを指定する値を取得します。(AuthorizationRule から継承されます。) |
![]() | PropagationFlags | 反映フラグの値を取得します。このフラグから、この規則を子オブジェクトに反映させる方法を判断します。このプロパティが重要なのは、InheritanceFlags 列挙体の値が None でない場合だけです。(AuthorizationRule から継承されます。) |

名前 | 説明 | |
---|---|---|
![]() | Equals | オーバーロードされます。 2 つの Object インスタンスが等しいかどうかを判断します。 (Object から継承されます。) |
![]() | GetHashCode | 特定の型のハッシュ関数として機能します。GetHashCode は、ハッシュ アルゴリズムや、ハッシュ テーブルのようなデータ構造での使用に適しています。 (Object から継承されます。) |
![]() | GetType | 現在のインスタンスの Type を取得します。 (Object から継承されます。) |
![]() | ReferenceEquals | 指定した複数の Object インスタンスが同一かどうかを判断します。 (Object から継承されます。) |
![]() | ToString | 現在の Object を表す String を返します。 (Object から継承されます。) |

- FileSystemAuditRuleのページへのリンク