FileSystemAuditRule 클래스

정의

파일이나 디렉터리에 대한 감사 규칙을 정의하는 ACE(액세스 제어 항목)를 추상적으로 나타낸 클래스입니다. 이 클래스는 상속될 수 없습니다.

public ref class FileSystemAuditRule sealed : System::Security::AccessControl::AuditRule
public sealed class FileSystemAuditRule : System.Security.AccessControl.AuditRule
[System.Security.SecurityCritical]
public sealed class FileSystemAuditRule : System.Security.AccessControl.AuditRule
type FileSystemAuditRule = class
    inherit AuditRule
[<System.Security.SecurityCritical>]
type FileSystemAuditRule = class
    inherit AuditRule
Public NotInheritable Class FileSystemAuditRule
Inherits AuditRule
상속
FileSystemAuditRule
특성

예제

다음 코드 예제에서는 클래스를 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

설명

FileSystemAuditRule 클래스 액세스 (읽기, 쓰기 및 등)를 제공 하려면 유형의 사용자 계정을 지정 하는 기본 액세스 제어 항목 (ACE)를 추상적 및 감사를 수행할 것인지 합니다. 이 클래스는 감사 규칙이 개체에서 상속되고 개체로 전파되는 방법을 지정할 수도 있습니다.

Windows NT 이상에서 파일 및 디렉터리 감사를 허용하려면 컴퓨터에서 감사 액세스 보안 정책을 사용하도록 설정해야 합니다. 기본적으로 이 정책은 감사 없음으로 설정됩니다.

액세스 보안 감사 정책을 사용 하려면 다음 단계를 수행 합니다.

  1. 관리 도구 폴더에 있는 로컬 보안 설정 MMC(Microsoft Management Console) 스냅인을 엽니다.

  2. 로컬 정책 폴더를 확장하고 감사 정책 폴더를 마우스 왼쪽 단추로 클릭합니다.

  3. MMC 스냅인의 오른쪽 창에서 감사 개체 액세스 항목을 두 번 클릭하거나 마우스 오른쪽 단추를 클릭하고 [속성]을 선택하여 [감사 개체 액세스 속성 ] 대화 상자를 표시합니다.

  4. 성공 또는 실패 확인란을 선택하여 성공 또는 실패를 기록합니다.

사용자 계정에 대 한 감사 규칙을 한다는 동일한 사용자 계정에 대 한 해당 액세스 규칙을 참고 합니다.

사용 된 FileSystemAuditRule 새 감사 규칙을 만드는 클래스입니다. 또는 DirectorySecurity 클래스를 FileSecurity 사용하여 이 규칙을 유지할 수 있습니다.

생성자

FileSystemAuditRule(IdentityReference, FileSystemRights, AuditFlags)

사용자 계정에 대한 참조, 감사 규칙과 관련된 작업 형식을 지정하는 값 및 감사를 수행할 시점을 지정하는 값을 사용하여 FileSystemAuditRule 클래스의 새 인스턴스를 초기화합니다.

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

사용자 계정에 대한 참조 이름, 감사 규칙과 관련된 작업 형식을 지정하는 값, 권한이 상속되는 방법을 결정하는 값, 권한이 전파되는 방법을 결정하는 값 및 감사를 수행할 시점을 지정하는 값을 사용하여 FileSystemAuditRule 클래스의 새 인스턴스를 초기화합니다.

FileSystemAuditRule(String, FileSystemRights, AuditFlags)

사용자 계정 이름, 감사 규칙과 관련된 작업 형식을 지정하는 값 및 감사를 수행할 시점을 지정하는 값을 사용하여 FileSystemAuditRule 클래스의 새 인스턴스를 초기화합니다.

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

사용자 계정의 이름, 감사 규칙과 관련된 작업 형식을 지정하는 값, 권한이 상속되는 방법을 결정하는 값, 권한이 전파되는 방법을 결정하는 값 및 감사를 수행할 시점을 지정하는 값을 사용하여 FileSystemAuditRule 클래스의 새 인스턴스를 초기화합니다.

속성

AccessMask

이 규칙의 액세스 마스크를 가져옵니다.

(다음에서 상속됨 AuthorizationRule)
AuditFlags

이 감사 규칙의 감사 플래그를 가져옵니다.

(다음에서 상속됨 AuditRule)
FileSystemRights

현재 FileSystemRights 개체와 관련된 FileSystemAuditRule 플래그를 가져옵니다.

IdentityReference

이 규칙이 적용되는 IdentityReference를 가져옵니다.

(다음에서 상속됨 AuthorizationRule)
InheritanceFlags

이 규칙이 자식 개체에서 상속되는 방식을 결정하는 플래그 값을 가져옵니다.

(다음에서 상속됨 AuthorizationRule)
IsInherited

이 규칙이 명시적으로 설정되는지 아니면 부모 컨테이너 개체에서 상속되는지 여부를 나타내는 값을 가져옵니다.

(다음에서 상속됨 AuthorizationRule)
PropagationFlags

이 규칙의 상속이 자식 개체에 전파되는 방법을 결정하는 전파 플래그의 값을 가져옵니다. 이 속성은 InheritanceFlags 열거형의 값이 None이 아닐 때만 중요합니다.

(다음에서 상속됨 AuthorizationRule)

메서드

Equals(Object)

지정된 개체가 현재 개체와 같은지 확인합니다.

(다음에서 상속됨 Object)
GetHashCode()

기본 해시 함수로 작동합니다.

(다음에서 상속됨 Object)
GetType()

현재 인스턴스의 Type을 가져옵니다.

(다음에서 상속됨 Object)
MemberwiseClone()

현재 Object의 단순 복사본을 만듭니다.

(다음에서 상속됨 Object)
ToString()

현재 개체를 나타내는 문자열을 반환합니다.

(다음에서 상속됨 Object)

적용 대상