FileSystemRights 열거형

정의

액세스 및 감사 규칙을 만들 때 사용할 액세스 권한을 정의합니다.

이 열거형은 멤버 값의 비트 조합을 지원합니다.

public enum class FileSystemRights
[System.Flags]
public enum FileSystemRights
[System.Flags]
[System.Security.SecurityCritical]
public enum FileSystemRights
[<System.Flags>]
type FileSystemRights = 
[<System.Flags>]
[<System.Security.SecurityCritical>]
type FileSystemRights = 
Public Enum FileSystemRights
상속
FileSystemRights
특성

필드

AppendData 4

파일 끝에 데이터를 추가할 수 있는 권한을 지정합니다.

ChangePermissions 262144

파일이나 폴더와 관련된 보안 및 감사 규칙을 변경할 수 있는 권한을 지정합니다.

CreateDirectories 4

폴더를 만들 수 있는 권한을 지정합니다. 이 권한에는 동기화 값이 필요합니다.

CreateFiles 2

파일을 만들 수 있는 권한을 지정합니다. 이 권한에는 동기화 값이 필요합니다.

Delete 65536

폴더나 파일을 삭제할 수 있는 권한을 지정합니다.

DeleteSubdirectoriesAndFiles 64

폴더와 해당 폴더 안에 포함된 모든 파일을 삭제할 수 있는 권한을 지정합니다.

ExecuteFile 32

애플리케이션 파일을 실행할 수 있는 권한을 지정합니다.

FullControl 2032127

폴더나 파일을 완전하게 제어하고 액세스 제어 및 감사 규칙을 수정할 수 있는 권한을 지정합니다. 이 값은 파일에 대해 모든 작업을 할 수 있는 권한을 나타내며 이 열거형의 모든 권한을 조합한 것입니다.

ListDirectory 1

디렉터리의 내용을 읽을 수 있는 권한을 지정합니다.

Modify 197055

폴더의 내용을 읽고, 쓰고, 나열하고, 폴더와 파일을 삭제하고, 애플리케이션 파일을 실행할 수 있는 권한을 지정합니다. 이 권한에는 ReadAndExecute, WriteDelete 권한이 포함됩니다.

Read 131209

폴더나 파일을 읽기 전용으로 열고 복사할 수 있는 권한을 지정합니다. 이 권한에는 ReadData,ReadExtendedAttributes, ReadAttributesReadPermissions 권한이 포함됩니다.

ReadAndExecute 131241

폴더나 파일을 읽기 전용으로 열고 복사하고, 애플리케이션 파일을 실행할 수 있는 권한을 지정합니다. 이 권한에는 ReadExecuteFile 권한이 포함됩니다.

ReadAttributes 128

폴더나 파일에서 파일 시스템 특성을 열고 복사할 수 있는 권한을 지정합니다. 예를 들어, 이 값은 파일을 만들거나 수정한 날짜를 볼 수 있는 권한을 지정합니다. 여기에는 데이터, 확장된 파일 시스템 특성 또는 액세스 규칙과 감사 규칙을 읽을 수 있는 권한이 포함되지 않습니다.

ReadData 1

파일이나 폴더를 열고 복사할 수 있는 권한을 지정합니다. 여기에는 파일 시스템 특성, 확장된 파일 시스템 특성 또는 액세스 규칙과 감사 규칙을 읽을 수 있는 권한이 포함되지 않습니다.

ReadExtendedAttributes 8

폴더나 파일에서 확장된 파일 시스템 특성을 열고 복사할 수 있는 권한을 지정합니다. 예를 들어, 이 값은 작성자 및 내용 정보를 볼 수 있는 권한을 지정합니다. 여기에는 데이터, 파일 시스템 특성 또는 액세스 규칙과 감사 규칙을 읽을 수 있는 권한이 포함되지 않습니다.

ReadPermissions 131072

폴더나 파일에서 액세스 및 감사 규칙을 열고 복사할 수 있는 권한을 지정합니다. 여기에는 데이터, 파일 시스템 특성 및 확장된 파일 시스템 특성을 읽을 수 있는 권한이 포함되지 않습니다.

Synchronize 1048576

애플리케이션에서 파일 핸들이 I/O 작업 완료와 동기화될 때까지 기다릴 수 있는지 여부를 지정합니다. 이 값은 액세스를 허용하는 경우 자동으로 설정되고, 액세스를 거부하는 경우 자동으로 제외됩니다.

TakeOwnership 524288

폴더나 파일의 소유자를 변경할 수 있는 권한을 지정합니다. 리소스의 소유자는 해당 리소스에 대한 모든 권한을 갖습니다.

Traverse 32

폴더의 내용을 나열하고 해당 폴더에 포함된 애플리케이션을 실행할 수 있는 권한을 지정합니다.

Write 278

폴더와 파일을 만들고 파일에서 데이터를 추가하고 제거할 수 있는 권한을 지정합니다. 이 권한에는 WriteData,AppendData, WriteExtendedAttributesWriteAttributes 권한이 포함됩니다.

WriteAttributes 256

폴더나 파일에서 파일 시스템 특성을 열고 쓸 수 있는 권한을 지정합니다. 여기에는 데이터, 확장된 특성 또는 액세스 규칙과 감사 규칙을 쓸 수 있는 권한이 포함되지 않습니다.

WriteData 2

파일이나 폴더를 열고 쓸 수 있는 권한을 지정합니다. 여기에는 파일 시스템 특성, 확장된 파일 시스템 특성 또는 액세스 규칙과 감사 규칙을 열고 쓸 수 있는 권한이 포함되지 않습니다.

WriteExtendedAttributes 16

폴더나 파일에서 확장된 파일 시스템 특성을 열고 쓸 수 있는 권한을 지정합니다. 여기에는 데이터, 특성 또는 액세스 규칙과 감사 규칙을 쓸 수 있는 권한이 포함되지 않습니다.

예제

다음 예제에서는 열거형을 FileSystemRights 사용하여 액세스 규칙을 지정한 다음 파일에서 액세스 규칙을 제거합니다. 이 예제를 실행하려면 유효한 사용자 또는 그룹 계정을 제공해야 합니다.

using namespace System;
using namespace System::IO;
using namespace System::Security::AccessControl;

// Adds an ACL entry on the specified file for the specified account.

void AddFileSecurity(String^ fileName, String^ account, 
                        FileSystemRights rights, AccessControlType controlType)
{
    // Get a FileSecurity object that represents the 
    // current security settings.
    FileSecurity^ fSecurity = File::GetAccessControl(fileName);

    // Add the FileSystemAccessRule to the security settings. 
    fSecurity->AddAccessRule(gcnew FileSystemAccessRule
                                   (account,rights, controlType));

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

// Removes an ACL entry on the specified file for the specified account.

void RemoveFileSecurity(String^ fileName, String^ account, 
                        FileSystemRights rights, AccessControlType controlType)
{

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

    // Remove the FileSystemAccessRule from the security settings. 
    fSecurity->RemoveAccessRule(gcnew FileSystemAccessRule
                                      (account,rights, controlType));

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

int main()
{
    try
    {
        String^ fileName = "test.xml";

        Console::WriteLine("Adding access control entry for " + fileName);

        // Add the access control entry to the file.
        AddFileSecurity(fileName, "MYDOMAIN\\MyAccount", 
            FileSystemRights::ReadData, AccessControlType::Allow);

        Console::WriteLine("Removing access control entry from " + fileName);

        // Remove the access control entry from the file.
        RemoveFileSecurity(fileName, "MYDOMAIN\\MyAccount", 
            FileSystemRights::ReadData, AccessControlType::Allow);

        Console::WriteLine("Done.");
    }
    catch (Exception^ ex)
    {
        Console::WriteLine(ex->Message);
    }
}
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.
                AddFileSecurity(fileName, @"DomainName\AccountName",
                    FileSystemRights.ReadData, AccessControlType.Allow);

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

                // Remove the access control entry from the file.
                RemoveFileSecurity(fileName, @"DomainName\AccountName",
                    FileSystemRights.ReadData, AccessControlType.Allow);

                Console.WriteLine("Done.");
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }
        }

        // Adds an ACL entry on the specified file for the specified account.
        public static void AddFileSecurity(string fileName, string account,
            FileSystemRights rights, AccessControlType controlType)
        {

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

            // Add the FileSystemAccessRule to the security settings.
            fSecurity.AddAccessRule(new FileSystemAccessRule(account,
                rights, controlType));

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

        // Removes an ACL entry on the specified file for the specified account.
        public static void RemoveFileSecurity(string fileName, string account,
            FileSystemRights rights, AccessControlType controlType)
        {

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

            // Remove the FileSystemAccessRule from the security settings.
            fSecurity.RemoveAccessRule(new FileSystemAccessRule(account,
                rights, controlType));

            // 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.
            AddFileSecurity(fileName, "DomainName\AccountName", _
                FileSystemRights.ReadData, AccessControlType.Allow)

            Console.WriteLine("Removing access control entry from " & fileName)

            ' Remove the access control entry from the file.
            RemoveFileSecurity(fileName, "DomainName\AccountName", _
                FileSystemRights.ReadData, AccessControlType.Allow)

            Console.WriteLine("Done.")
        Catch e As Exception
            Console.WriteLine(e)
        End Try

    End Sub


    ' Adds an ACL entry on the specified file for the specified account.
    Sub AddFileSecurity(ByVal fileName As String, ByVal account As String, _
        ByVal rights As FileSystemRights, ByVal controlType As AccessControlType)
  
        ' Get a FileSecurity object that represents the 
        ' current security settings.
        Dim fSecurity As FileSecurity = File.GetAccessControl(fileName)

        ' Add the FileSystemAccessRule to the security settings. 
        Dim accessRule As FileSystemAccessRule = _
            New FileSystemAccessRule(account, rights, controlType)

        fSecurity.AddAccessRule(accessRule)

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

    End Sub


    ' Removes an ACL entry on the specified file for the specified account.
    Sub RemoveFileSecurity(ByVal fileName As String, ByVal account As String, _
        ByVal rights As FileSystemRights, ByVal controlType As AccessControlType)

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

        ' Remove the FileSystemAccessRule from the security settings. 
        fSecurity.RemoveAccessRule(New FileSystemAccessRule(account, _
            rights, controlType))

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

    End Sub
End Module

설명

열거형은 FileSystemRights 특정 사용자 계정에 대해 허용되는 파일 시스템 작업과 특정 사용자 계정에 대해 감사되는 파일 시스템 작업을 지정합니다.

클래스를 사용하여 FileSystemRights 액세스 규칙을 만들거나 클래스를 FileSystemAccessRule 사용하여 감사 규칙을 만들 때 열거형을 FileSystemAuditRule 사용합니다.

이 열거형에는 여러 세분화된 시스템 권한 값과 이러한 세분화된 값의 조합인 여러 값이 포함됩니다. 각 구성 요소 값을 FullControl별도로 지정하는 대신 , ReadWrite등의 조합 값을 사용하는 것이 더 쉽습니다.

권한과 CreateFiles 권리는 CreateDirectories 권리가 필요합니다Synchronize. 파일 또는 디렉터리를 만들 때 값을 명시적으로 설정 Synchronize 하지 않으면 자동으로 설정됩니다.

적용 대상