다음을 통해 공유


FileSystemAccessRule 생성자

정의

FileSystemAccessRule 클래스의 새 인스턴스를 초기화합니다.

오버로드

FileSystemAccessRule(IdentityReference, FileSystemRights, AccessControlType)

사용자 계정에 대한 참조, 액세스 규칙과 관련된 작업 형식을 지정하는 값 및 작업의 허용 여부를 지정하는 값을 사용하여 FileSystemAccessRule 클래스의 새 인스턴스를 만듭니다.

FileSystemAccessRule(String, FileSystemRights, AccessControlType)

사용자 계정의 이름, 액세스 규칙과 관련된 작업 형식을 지정하는 값 및 작업의 허용 여부를 설명하는 값을 사용하여 FileSystemAccessRule 클래스의 새 인스턴스를 만듭니다.

FileSystemAccessRule(IdentityReference, FileSystemRights, InheritanceFlags, PropagationFlags, AccessControlType)

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

FileSystemAccessRule(String, FileSystemRights, InheritanceFlags, PropagationFlags, AccessControlType)

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

FileSystemAccessRule(IdentityReference, FileSystemRights, AccessControlType)

사용자 계정에 대한 참조, 액세스 규칙과 관련된 작업 형식을 지정하는 값 및 작업의 허용 여부를 지정하는 값을 사용하여 FileSystemAccessRule 클래스의 새 인스턴스를 만듭니다.

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

매개 변수

identity
IdentityReference

사용자 계정에 대한 참조를 캡슐화하는 IdentityReference 개체입니다.

fileSystemRights
FileSystemRights

액세스 규칙과 관련된 작업 형식을 지정하는 FileSystemRights 값 중 하나입니다.

type
AccessControlType

작업의 허용 여부를 지정하는 AccessControlType 값 중 하나입니다.

예외

identity 매개 변수가 IdentityReference 개체가 아닌 경우

identity 매개 변수가 null인 경우

잘못된 열거형이 type 매개 변수에 전달된 경우

설명

이 생성자를 사용하여 또는 DirectorySecurity 클래스를 사용하여 FileSecurity 유지할 수 있는 액세스 제어 규칙을 만듭니다. 액세스 제어 규칙은 Microsoft Windows를 실행하는 컴퓨터에서 허용되거나 허용되지 않는 작업을 결정하는 사용자 계정 권한을 정의합니다.

적용 대상

FileSystemAccessRule(String, FileSystemRights, AccessControlType)

사용자 계정의 이름, 액세스 규칙과 관련된 작업 형식을 지정하는 값 및 작업의 허용 여부를 설명하는 값을 사용하여 FileSystemAccessRule 클래스의 새 인스턴스를 만듭니다.

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

매개 변수

identity
String

사용자 계정의 이름입니다.

fileSystemRights
FileSystemRights

액세스 규칙과 관련된 작업 형식을 지정하는 FileSystemRights 값 중 하나입니다.

type
AccessControlType

작업의 허용 여부를 지정하는 AccessControlType 값 중 하나입니다.

예외

identity 매개 변수가 null인 경우

잘못된 열거형이 type 매개 변수에 전달된 경우

예제

다음 코드 예제에서는 클래스를 FileSecurity 추가 하 고 파일에서 ACE (액세스 제어 항목)를 제거 합니다. 이 예제를 실행하려면 유효한 사용자 또는 그룹 계정을 제공해야 합니다.

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

설명

이 생성자를 사용하여 또는 DirectorySecurity 클래스를 사용하여 FileSecurity 유지할 수 있는 액세스 제어 규칙을 만듭니다. 액세스 제어 규칙은 Microsoft Windows를 실행하는 컴퓨터에서 허용되거나 허용되지 않는 작업을 결정하는 사용자 계정 권한을 정의합니다.

매개 변수는 identity 현재 컴퓨터 또는 도메인에서 유효한 계정을 식별해야 합니다. 문자열은 다음 형식을 사용합니다. 여기서 DOMAIN 는 유효한 도메인 또는 컴퓨터 이름의 이름이고 account 는 도메인 또는 컴퓨터 DOMAIN\account에서 유효한 사용자 계정의 이름입니다.

적용 대상

FileSystemAccessRule(IdentityReference, FileSystemRights, InheritanceFlags, PropagationFlags, AccessControlType)

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

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

매개 변수

identity
IdentityReference

사용자 계정에 대한 참조를 캡슐화하는 IdentityReference 개체입니다.

fileSystemRights
FileSystemRights

액세스 규칙과 관련된 작업 형식을 지정하는 FileSystemRights 값 중 하나입니다.

inheritanceFlags
InheritanceFlags

자식 개체에 액세스 마스크가 전파되는 방법을 지정하는 InheritanceFlags 값 중 하나입니다.

propagationFlags
PropagationFlags

자식 개체에 ACE(액세스 제어 항목)가 전파되는 방법을 지정하는 PropagationFlags 값 중 하나입니다.

type
AccessControlType

작업의 허용 여부를 지정하는 AccessControlType 값 중 하나입니다.

예외

identity 매개 변수가 IdentityReference 개체가 아닌 경우

identity 매개 변수가 null인 경우

잘못된 열거형이 type 매개 변수에 전달된 경우

또는

잘못된 열거형이 inheritanceFlags 매개 변수에 전달된 경우

또는

잘못된 열거형이 propagationFlags 매개 변수에 전달된 경우

설명

이 생성자를 사용하여 또는 DirectorySecurity 클래스를 사용하여 FileSecurity 유지할 수 있는 액세스 제어 규칙을 만듭니다. 액세스 제어 규칙은 Microsoft Windows를 실행하는 컴퓨터에서 허용되거나 허용되지 않는 작업을 결정하는 사용자 계정 권한을 정의합니다.

적용 대상

FileSystemAccessRule(String, FileSystemRights, InheritanceFlags, PropagationFlags, AccessControlType)

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

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

매개 변수

identity
String

사용자 계정의 이름입니다.

fileSystemRights
FileSystemRights

액세스 규칙과 관련된 작업 형식을 지정하는 FileSystemRights 값 중 하나입니다.

inheritanceFlags
InheritanceFlags

자식 개체에 액세스 마스크가 전파되는 방법을 지정하는 InheritanceFlags 값 중 하나입니다.

propagationFlags
PropagationFlags

자식 개체에 ACE(액세스 제어 항목)가 전파되는 방법을 지정하는 PropagationFlags 값 중 하나입니다.

type
AccessControlType

작업의 허용 여부를 지정하는 AccessControlType 값 중 하나입니다.

예외

identity 매개 변수가 null인 경우

잘못된 열거형이 type 매개 변수에 전달된 경우

또는

잘못된 열거형이 inheritanceFlags 매개 변수에 전달된 경우

또는

잘못된 열거형이 propagationFlags 매개 변수에 전달된 경우

설명

이 생성자를 사용하여 또는 DirectorySecurity 클래스를 사용하여 FileSecurity 유지할 수 있는 액세스 제어 규칙을 만듭니다. 액세스 제어 규칙은 Microsoft Windows를 실행하는 컴퓨터에서 허용되거나 허용되지 않는 작업을 결정하는 사용자 계정 권한을 정의합니다.

매개 변수는 identity 현재 컴퓨터 또는 도메인에서 유효한 계정을 식별해야 합니다. 문자열은 다음 형식을 사용합니다. 여기서 DOMAIN 는 유효한 도메인 또는 컴퓨터 이름의 이름이고 account 는 도메인 또는 컴퓨터 DOMAIN\account에서 유효한 사용자 계정의 이름입니다.

적용 대상