다음을 통해 공유


RegistryAccessRule 생성자

정의

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

오버로드

RegistryAccessRule(IdentityReference, RegistryRights, AccessControlType)

RegistryAccessRule 클래스의 새 인스턴스를 초기화하여 규칙을 적용할 사용자 또는 그룹, 액세스 권한 및 지정된 액세스 권한의 허용 또는 거부를 지정합니다.

RegistryAccessRule(String, RegistryRights, AccessControlType)

RegistryAccessRule 클래스의 새 인스턴스를 초기화하여 규칙을 적용할 사용자 또는 그룹의 이름, 액세스 권한 및 지정된 액세스 권한의 허용 또는 거부 여부를 지정합니다.

RegistryAccessRule(IdentityReference, RegistryRights, InheritanceFlags, PropagationFlags, AccessControlType)

규칙을 적용할 사용자 또는 그룹, 액세스 권한, 상속 플래그, 전파 플래그 및 지정된 액세스 권한의 허용 여부를 지정하여 RegistryAccessRule 클래스의 새 인스턴스를 초기화합니다.

RegistryAccessRule(String, RegistryRights, InheritanceFlags, PropagationFlags, AccessControlType)

RegistryAccessRule 클래스의 새 인스턴스를 초기화하여 규칙을 적용할 사용자 또는 그룹의 이름, 액세스 권한, 상속 플래그, 전파 플래그 및 지정된 액세스 권한의 허용 또는 거부 여부를 지정합니다.

RegistryAccessRule(IdentityReference, RegistryRights, AccessControlType)

Source:
RegistrySecurity.cs

RegistryAccessRule 클래스의 새 인스턴스를 초기화하여 규칙을 적용할 사용자 또는 그룹, 액세스 권한 및 지정된 액세스 권한의 허용 또는 거부를 지정합니다.

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

매개 변수

identity
IdentityReference

규칙을 적용할 사용자나 그룹입니다. 이 값은 SecurityIdentifier 형식이거나 NTAccount와 같이 SecurityIdentifier 형식으로 변환할 수 있는 형식이어야 합니다.

registryRights
RegistryRights

허용 또는 거부 권한을 나타내는 RegistryRights 값의 비트 조합입니다.

type
AccessControlType

권한 허용 여부를 나타내는 AccessControlType 값 중 하나입니다.

예외

registryRights가 잘못된 값을 지정하는 경우

또는

type가 잘못된 값을 지정하는 경우

identity이(가) null인 경우

또는

eventRights가 0입니다.

identity의 형식이 SecurityIdentifier도 아니고 NTAccount와 같이 SecurityIdentifier 형식으로 변환할 수 있는 형식도 아닌 경우

설명

이 생성자는 기본 전파 및 상속을 지정합니다. 즉, InheritanceFlags.NonePropagationFlags.None입니다.

적용 대상

RegistryAccessRule(String, RegistryRights, AccessControlType)

Source:
RegistrySecurity.cs

RegistryAccessRule 클래스의 새 인스턴스를 초기화하여 규칙을 적용할 사용자 또는 그룹의 이름, 액세스 권한 및 지정된 액세스 권한의 허용 또는 거부 여부를 지정합니다.

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

매개 변수

identity
String

규칙을 적용할 사용자나 그룹의 이름입니다.

registryRights
RegistryRights

허용 또는 거부 권한을 나타내는 RegistryRights 값의 비트 조합입니다.

type
AccessControlType

권한 허용 여부를 나타내는 AccessControlType 값 중 하나입니다.

예외

registryRights가 잘못된 값을 지정하는 경우

또는

type가 잘못된 값을 지정하는 경우

registryRights가 0입니다.

identity이(가) null인 경우

또는

identity이 빈 문자열입니다.

또는

identity이 512자보다 깁니다.

예제

다음 코드 예제에서는 레지스트리 액세스 규칙을 만들고 개체에 RegistrySecurity 추가하여 권한을 허용 및 거부하는 규칙이 분리된 상태로 유지되는 반면, 동일한 종류의 호환되는 규칙이 병합되는 방식을 보여 주며,

using System;
using Microsoft.Win32;
using System.Security.AccessControl;
using System.Security.Principal;

public class Example
{
    public static void Main()
    {
        // Create a string representing the current user.
        string user = Environment.UserDomainName + "\\"
            + Environment.UserName;

        // Create a security object that grants no access.
        RegistrySecurity mSec = new RegistrySecurity();

        // Add a rule that grants the current user the 
        // right to read the key.
        RegistryAccessRule rule = new RegistryAccessRule(user, 
            RegistryRights.ReadKey, 
            AccessControlType.Allow);
        mSec.AddAccessRule(rule);

        // Add a rule that denies the current user the 
        // right to change permissions on the Registry.
        rule = new RegistryAccessRule(user, 
            RegistryRights.ChangePermissions, 
            AccessControlType.Deny);
        mSec.AddAccessRule(rule);

        // Display the rules in the security object.
        ShowSecurity(mSec);

        // Add a rule that allows the current user the 
        // right to read permissions on the Registry. This 
        // rule is merged with the existing Allow rule.
        rule = new RegistryAccessRule(user, 
            RegistryRights.WriteKey, 
            AccessControlType.Allow);
        mSec.AddAccessRule(rule);

        ShowSecurity(mSec);
    }

    private static void ShowSecurity(RegistrySecurity security)
    {
        Console.WriteLine("\r\nCurrent access rules:\r\n");

        foreach( RegistryAccessRule ar in 
            security.GetAccessRules(true, true, typeof(NTAccount)) )
        {
            Console.WriteLine("        User: {0}", ar.IdentityReference);
            Console.WriteLine("        Type: {0}", ar.AccessControlType);
            Console.WriteLine("      Rights: {0}", ar.RegistryRights);
            Console.WriteLine();
        }
    }
}

/* This code example produces output similar to following:

Current access rules:

        User: TestDomain\TestUser
        Type: Deny
      Rights: ChangePermissions

        User: TestDomain\TestUser
        Type: Allow
      Rights: ReadKey


Current access rules:

        User: TestDomain\TestUser
        Type: Deny
      Rights: ChangePermissions

        User: TestDomain\TestUser
        Type: Allow
      Rights: SetValue, CreateSubKey, ReadKey
 */
Imports Microsoft.Win32
Imports System.Security.AccessControl
Imports System.Security.Principal

Public Class Example

    Public Shared Sub Main()

        ' Create a string representing the current user.
        Dim user As String = Environment.UserDomainName _ 
            & "\" & Environment.UserName

        ' Create a security object that grants no access.
        Dim mSec As New RegistrySecurity()

        ' Add a rule that grants the current user the 
        ' right to read the key.
        Dim rule As New RegistryAccessRule(user, _
            RegistryRights.ReadKey, _
            AccessControlType.Allow)
        mSec.AddAccessRule(rule)

        ' Add a rule that denies the current user the 
        ' right to change permissions on the Registry.
        rule = New RegistryAccessRule(user, _
            RegistryRights.ChangePermissions, _
            AccessControlType.Deny)
        mSec.AddAccessRule(rule)

        ' Display the rules in the security object.
        ShowSecurity(mSec)

        ' Add a rule that allows the current user the 
        ' right to read permissions on the Registry. This 
        ' rule is merged with the existing Allow rule.
        rule = New RegistryAccessRule(user, _
            RegistryRights.WriteKey, _
            AccessControlType.Allow)
        mSec.AddAccessRule(rule)

        ShowSecurity(mSec)

    End Sub 

    Private Shared Sub ShowSecurity(ByVal security As RegistrySecurity)
        Console.WriteLine(vbCrLf & "Current access rules:" & vbCrLf)

        For Each ar As RegistryAccessRule In _
            security.GetAccessRules(True, True, GetType(NTAccount))

            Console.WriteLine("        User: {0}", ar.IdentityReference)
            Console.WriteLine("        Type: {0}", ar.AccessControlType)
            Console.WriteLine("      Rights: {0}", ar.RegistryRights)
            Console.WriteLine()
        Next

    End Sub
End Class 

'This code example produces output similar to following:
'
'Current access rules:
'
'        User: TestDomain\TestUser
'        Type: Deny
'      Rights: ChangePermissions
'
'        User: TestDomain\TestUser
'        Type: Allow
'      Rights: ReadKey
'
'
'Current access rules:
'
'        User: TestDomain\TestUser
'        Type: Deny
'      Rights: ChangePermissions
'
'        User: TestDomain\TestUser
'        Type: Allow
'      Rights: SetValue, CreateSubKey, ReadKey

설명

이 생성자는 기본 전파 및 상속을 지정합니다. 즉, InheritanceFlags.NonePropagationFlags.None입니다.

이 생성자는 생성자에 전달 identity 하고 새로 만든 개체를 NTAccount.NTAccount(String) 생성자에 전달하여 개체를 만드는 NTAccountNTAccount 것과 RegistryAccessRule(IdentityReference, RegistryRights, AccessControlType) 같습니다.

적용 대상

RegistryAccessRule(IdentityReference, RegistryRights, InheritanceFlags, PropagationFlags, AccessControlType)

Source:
RegistrySecurity.cs

규칙을 적용할 사용자 또는 그룹, 액세스 권한, 상속 플래그, 전파 플래그 및 지정된 액세스 권한의 허용 여부를 지정하여 RegistryAccessRule 클래스의 새 인스턴스를 초기화합니다.

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

매개 변수

identity
IdentityReference

규칙을 적용할 사용자나 그룹입니다. 이 값은 SecurityIdentifier 형식이거나 NTAccount와 같이 SecurityIdentifier 형식으로 변환할 수 있는 형식이어야 합니다.

registryRights
RegistryRights

허용 또는 거부 권한을 지정하는 RegistryRights 값의 비트 조합입니다.

inheritanceFlags
InheritanceFlags

액세스 권한이 다른 개체에서 상속되는 방식을 지정하는 InheritanceFlags 플래그의 비트 조합입니다.

propagationFlags
PropagationFlags

액세스 권한이 다른 개체로 전파되는 방식을 지정하는 PropagationFlags 플래그의 비트 조합입니다.

type
AccessControlType

권한 허용 여부를 지정하는 AccessControlType 값 중 하나입니다.

예외

registryRights가 잘못된 값을 지정하는 경우

또는

type가 잘못된 값을 지정하는 경우

또는

inheritanceFlags가 잘못된 값을 지정하는 경우

또는

propagationFlags가 잘못된 값을 지정하는 경우

identity이(가) null인 경우

또는

registryRights가 0입니다.

identity의 형식이 SecurityIdentifier도 아니고 NTAccount와 같이 SecurityIdentifier 형식으로 변환할 수 있는 형식도 아닌 경우

설명

모든 레지스트리 키는 컨테이너이므로 레지스트리 키에 의미 있는 유일한 상속 플래그는 플래그입니다 InheritanceFlags.ContainerInherit . 이 플래그를 지정하지 않으면 전파 플래그가 무시되고 즉시 키만 영향을 받습니다. 플래그가 있으면 다음 표와 같이 규칙이 전파됩니다. 테이블은 하위 키 CS 및 손자 하위 키 GS가 있는 하위 키 S가 있다고 가정합니다. 즉, 손자 하위 키의 경로는 S\CS\GS입니다.

전파 플래그 S CS GS
None X X X
NoPropagateInherit X X
InheritOnly X X
NoPropagateInherit, InheritOnly X

손자 하위 키의 패턴은 손자 하위 키에 포함된 모든 하위 키를 제어합니다.

예를 들어 플래그가 ContainerInheritinheritanceFlags 대해 지정되고 InheritOnly 전파 플래그가 에 propagationFlags대해 지정된 경우 이 규칙은 바로 하위 키에 적용되지 않지만 모든 직계 자식 하위 키 및 포함된 모든 하위 키에 적용됩니다.

참고

에 대한 inheritanceFlags플래그를 InheritanceFlags.ObjectInherit 지정할 수 있지만 아무 소용이 없습니다. 액세스 제어를 위해 하위 키의 이름/값 쌍은 별도의 개체가 아닙니다. 이름/값 쌍에 대한 액세스 권한은 하위 키의 권한에 의해 제어됩니다. 또한 모든 하위 키는 컨테이너(즉, 다른 하위 키를 포함할 수 있음)이므로 플래그의 ObjectInherit 영향을 받지 않습니다. 마지막으로 플래그를 ObjectInherit 지정하면 호환되는 규칙의 조합을 방해하므로 규칙의 유지 관리가 불필요하게 복잡합니다.

적용 대상

RegistryAccessRule(String, RegistryRights, InheritanceFlags, PropagationFlags, AccessControlType)

Source:
RegistrySecurity.cs

RegistryAccessRule 클래스의 새 인스턴스를 초기화하여 규칙을 적용할 사용자 또는 그룹의 이름, 액세스 권한, 상속 플래그, 전파 플래그 및 지정된 액세스 권한의 허용 또는 거부 여부를 지정합니다.

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

매개 변수

identity
String

규칙을 적용할 사용자나 그룹의 이름입니다.

registryRights
RegistryRights

허용 또는 거부 권한을 나타내는 RegistryRights 값의 비트 조합입니다.

inheritanceFlags
InheritanceFlags

액세스 권한이 다른 개체에서 상속되는 방식을 지정하는 InheritanceFlags 플래그의 비트 조합입니다.

propagationFlags
PropagationFlags

액세스 권한이 다른 개체로 전파되는 방식을 지정하는 PropagationFlags 플래그의 비트 조합입니다.

type
AccessControlType

권한 허용 여부를 지정하는 AccessControlType 값 중 하나입니다.

예외

registryRights가 잘못된 값을 지정하는 경우

또는

type가 잘못된 값을 지정하는 경우

또는

inheritanceFlags가 잘못된 값을 지정하는 경우

또는

propagationFlags가 잘못된 값을 지정하는 경우

eventRights가 0입니다.

identity이(가) null인 경우

또는

identity이 빈 문자열입니다.

또는

identity이 512자보다 깁니다.

예제

다음 코드 예제에서는 상속 및 전파를 사용하는 액세스 규칙을 보여 줍니다. 이 예제에서는 개체를 RegistrySecurity 만든 다음 플래그가 있는 두 개의 ContainerInherit 규칙을 만들고 추가합니다. 첫 번째 규칙에는 전파 플래그가 없지만 두 번째 규칙에는 및 InheritOnlyNoPropagateInherit 있습니다.

프로그램은 개체에 규칙을 RegistrySecurity 표시한 다음 개체를 RegistrySecurity 사용하여 하위 키를 만듭니다. 프로그램은 자식 하위 키와 손자 하위 키를 만든 다음 각 하위 키에 대한 규칙을 표시합니다. 마지막으로 프로그램에서 테스트 키를 삭제합니다.


using System;
using System.Security.AccessControl;
using System.Security.Principal;
using System.Security;
using Microsoft.Win32;

public class Example
{
    public static void Main()
    {
        const string TestKey = "TestKey3927";
        RegistryKey cu = Registry.CurrentUser;

        string user = Environment.UserDomainName + 
            "\\" + Environment.UserName;

        // Create a security object that grants no access.
        RegistrySecurity mSec = new RegistrySecurity();

        // Add a rule that grants the current user the right
        // to read and enumerate the name/value pairs in a key, 
        // to read its access and audit rules, to enumerate
        // its subkeys, to create subkeys, and to delete the key. 
        // The rule is inherited by all contained subkeys.
        //
        RegistryAccessRule rule = new RegistryAccessRule(user, 
           RegistryRights.ReadKey | RegistryRights.WriteKey 
               | RegistryRights.Delete, 
           InheritanceFlags.ContainerInherit, 
           PropagationFlags.None, 
           AccessControlType.Allow
        );
        mSec.AddAccessRule(rule);

        // Add a rule that allows the current user the right
        // right to set the name/value pairs in a key. 
        // This rule is inherited by contained subkeys, but
        // propagation flags limit it to immediate child 
        // subkeys.
        rule = new RegistryAccessRule(user, 
            RegistryRights.ChangePermissions, 
            InheritanceFlags.ContainerInherit, 
            PropagationFlags.InheritOnly | 
                PropagationFlags.NoPropagateInherit, 
            AccessControlType.Allow);
        mSec.AddAccessRule(rule);

        // Display the rules in the security object.
        ShowSecurity(mSec);

        // Create the test key using the security object.
        //
        RegistryKey rk = cu.CreateSubKey(TestKey, 
            RegistryKeyPermissionCheck.ReadWriteSubTree, mSec);

        // Create a child subkey and a grandchild subkey, 
        // without security.
        RegistryKey rkChild = rk.CreateSubKey("ChildKey", 
            RegistryKeyPermissionCheck.ReadWriteSubTree);
        RegistryKey rkGrandChild = 
            rkChild.CreateSubKey("GrandChildKey", 
                RegistryKeyPermissionCheck.ReadWriteSubTree);

        Show(rk);
        Show(rkChild);
        Show(rkGrandChild);

        rkGrandChild.Close();
        rkChild.Close();
        rk.Close();

        cu.DeleteSubKeyTree(TestKey);
    }

    private static void Show(RegistryKey rk)
    {
        Console.WriteLine(rk.Name);
        ShowSecurity(rk.GetAccessControl());
    }

    private static void ShowSecurity(RegistrySecurity security)
    {
        Console.WriteLine("\r\nCurrent access rules:\r\n");

        foreach( RegistryAccessRule ar in security.GetAccessRules(true, true, typeof(NTAccount)) )
        {

            Console.WriteLine("        User: {0}", ar.IdentityReference);
            Console.WriteLine("        Type: {0}", ar.AccessControlType);
            Console.WriteLine("      Rights: {0}", ar.RegistryRights);
            Console.WriteLine(" Inheritance: {0}", ar.InheritanceFlags);
            Console.WriteLine(" Propagation: {0}", ar.PropagationFlags);
            Console.WriteLine("   Inherited? {0}", ar.IsInherited);
            Console.WriteLine();
        }
    }
}

/* This code example produces output similar to following:

Current access rules:

        User: TestDomain\TestUser
        Type: Allow
      Rights: SetValue, CreateSubKey, Delete, ReadKey
 Inheritance: ContainerInherit
 Propagation: None
   Inherited? False

        User: TestDomain\TestUser
        Type: Allow
      Rights: ChangePermissions
 Inheritance: ContainerInherit
 Propagation: NoPropagateInherit, InheritOnly
   Inherited? False

HKEY_CURRENT_USER\TestKey3927

Current access rules:

        User: TestDomain\TestUser
        Type: Allow
      Rights: SetValue, CreateSubKey, Delete, ReadKey
 Inheritance: ContainerInherit
 Propagation: None
   Inherited? False

        User: TestDomain\TestUser
        Type: Allow
      Rights: ChangePermissions
 Inheritance: ContainerInherit
 Propagation: NoPropagateInherit, InheritOnly
   Inherited? False

HKEY_CURRENT_USER\TestKey3927\ChildKey

Current access rules:

        User: TestDomain\TestUser
        Type: Allow
      Rights: SetValue, CreateSubKey, Delete, ReadKey
 Inheritance: ContainerInherit
 Propagation: None
   Inherited? True

        User: TestDomain\TestUser
        Type: Allow
      Rights: ChangePermissions
 Inheritance: None
 Propagation: None
   Inherited? True

HKEY_CURRENT_USER\TestKey3927\ChildKey\GrandChildKey

Current access rules:

        User: TestDomain\TestUser
        Type: Allow
      Rights: SetValue, CreateSubKey, Delete, ReadKey
 Inheritance: ContainerInherit
 Propagation: None
   Inherited? True
 */
Option Explicit
Imports System.Security.AccessControl
Imports System.Security.Principal
Imports System.Security
Imports Microsoft.Win32

Public Class Example

    Public Shared Sub Main()

        Const TestKey As String = "TestKey3927"
        Dim cu As RegistryKey = Registry.CurrentUser

        Dim user As String = Environment.UserDomainName _ 
            & "\" & Environment.UserName

        ' Create a security object that grants no access.
        Dim mSec As New RegistrySecurity()

        ' Add a rule that grants the current user the right
        ' to read and enumerate the name/value pairs in a key, 
        ' to read its access and audit rules, to enumerate
        ' its subkeys, to create subkeys, and to delete the key. 
        ' The rule is inherited by all contained subkeys.
        '
        Dim rule As New RegistryAccessRule(user, _
            RegistryRights.ReadKey Or RegistryRights.WriteKey _
                Or RegistryRights.Delete, _
            InheritanceFlags.ContainerInherit, _
            PropagationFlags.None, _
            AccessControlType.Allow)
        mSec.AddAccessRule(rule)

        ' Add a rule that allows the current user the right
        ' right to set the name/value pairs in a key. 
        ' This rule is inherited by contained subkeys, but
        ' propagation flags limit it to immediate child 
        ' subkeys.
        rule = New RegistryAccessRule(user, _
            RegistryRights.ChangePermissions, _
            InheritanceFlags.ContainerInherit, _
            PropagationFlags.InheritOnly Or PropagationFlags.NoPropagateInherit, _
            AccessControlType.Allow)
        mSec.AddAccessRule(rule)

        ' Display the rules in the security object.
        ShowSecurity(mSec)

        ' Create the test key using the security object.
        '
        Dim rk As RegistryKey = cu.CreateSubKey(TestKey, _
            RegistryKeyPermissionCheck.ReadWriteSubTree, _
            mSec)

        ' Create a child subkey and a grandchild subkey, 
        ' without security.
        Dim rkChild As RegistryKey= rk.CreateSubKey("ChildKey", _
            RegistryKeyPermissionCheck.ReadWriteSubTree)
        Dim rkGrandChild As RegistryKey = _
            rkChild.CreateSubKey("GrandChildKey", _
                RegistryKeyPermissionCheck.ReadWriteSubTree)

        Show(rk)
        Show(rkChild)
        Show(rkGrandChild)

        rkGrandChild.Close()
        rkChild.Close()
        rk.Close()

        cu.DeleteSubKeyTree(TestKey)
    End Sub 

    Private Shared Sub Show(ByVal rk As RegistryKey)
        Console.WriteLine(rk.Name)            
        ShowSecurity(rk.GetAccessControl())
    End Sub

    Private Shared Sub ShowSecurity(ByVal security As RegistrySecurity)
        Console.WriteLine(vbCrLf & "Current access rules:" & vbCrLf)

        For Each ar As RegistryAccessRule In _
            security.GetAccessRules(True, True, GetType(NTAccount))

            Console.WriteLine("        User: {0}", ar.IdentityReference)
            Console.WriteLine("        Type: {0}", ar.AccessControlType)
            Console.WriteLine("      Rights: {0}", ar.RegistryRights)
            Console.WriteLine(" Inheritance: {0}", ar.InheritanceFlags)
            Console.WriteLine(" Propagation: {0}", ar.PropagationFlags)
            Console.WriteLine("   Inherited? {0}", ar.IsInherited)
            Console.WriteLine()
        Next

    End Sub
End Class 

'This code example produces output similar to following:
'
'Current access rules:
'
'        User: TestDomain\TestUser
'        Type: Allow
'      Rights: SetValue, CreateSubKey, Delete, ReadKey
' Inheritance: ContainerInherit
' Propagation: None
'   Inherited? False
'
'        User: TestDomain\TestUser
'        Type: Allow
'      Rights: ChangePermissions
' Inheritance: ContainerInherit
' Propagation: NoPropagateInherit, InheritOnly
'   Inherited? False
'
'HKEY_CURRENT_USER\TestKey3927
'
'Current access rules:
'
'        User: TestDomain\TestUser
'        Type: Allow
'      Rights: SetValue, CreateSubKey, Delete, ReadKey
' Inheritance: ContainerInherit
' Propagation: None
'   Inherited? False
'
'        User: TestDomain\TestUser
'        Type: Allow
'      Rights: ChangePermissions
' Inheritance: ContainerInherit
' Propagation: NoPropagateInherit, InheritOnly
'   Inherited? False
'
'HKEY_CURRENT_USER\TestKey3927\ChildKey
'
'Current access rules:
'
'        User: TestDomain\TestUser
'        Type: Allow
'      Rights: SetValue, CreateSubKey, Delete, ReadKey
' Inheritance: ContainerInherit
' Propagation: None
'   Inherited? True
'
'        User: TestDomain\TestUser
'        Type: Allow
'      Rights: ChangePermissions
' Inheritance: None
' Propagation: None
'   Inherited? True
'
'HKEY_CURRENT_USER\TestKey3927\ChildKey\GrandChildKey
'
'Current access rules:
'
'        User: TestDomain\TestUser
'        Type: Allow
'      Rights: SetValue, CreateSubKey, Delete, ReadKey
' Inheritance: ContainerInherit
' Propagation: None
'   Inherited? True

설명

모든 레지스트리 키는 컨테이너이므로 레지스트리 키에 의미 있는 유일한 상속 플래그는 플래그입니다 InheritanceFlags.ContainerInherit . 이 플래그를 지정하지 않으면 전파 플래그가 무시되고 즉시 키만 영향을 받습니다. 플래그가 있으면 다음 표와 같이 규칙이 전파됩니다. 테이블은 하위 키 CS 및 손자 하위 키 GS가 있는 하위 키 S가 있다고 가정합니다. 즉, 손자 하위 키의 경로는 S\CS\GS입니다.

전파 플래그 S CS GS
None X X X
NoPropagateInherit X X
InheritOnly X X
NoPropagateInherit, InheritOnly X

손자 하위 키의 패턴은 손자 하위 키에 포함된 모든 하위 키를 제어합니다.

예를 들어 플래그가 ContainerInherit 에 대해 inheritanceFlags 지정되고 InheritOnly 전파 플래그가 에 propagationFlags지정된 경우 이 규칙은 바로 하위 키에 적용되지 않지만 모든 직계 자식 하위 키 및 해당 하위 키에 적용되는 모든 하위 키에 적용됩니다.

참고

에 대한 inheritanceFlags플래그를 InheritanceFlags.ObjectInherit 지정할 수 있지만 아무 소용이 없습니다. 액세스 제어를 위해 하위 키의 이름/값 쌍은 별도의 개체가 아닙니다. 이름/값 쌍에 대한 액세스 권한은 하위 키의 권한에 의해 제어됩니다. 또한 모든 하위 키는 컨테이너(즉, 다른 하위 키를 포함할 수 있음)이므로 플래그의 ObjectInherit 영향을 받지 않습니다. 마지막으로 플래그를 ObjectInherit 지정하면 호환되지 않는 규칙의 조합을 방해하므로 규칙 유지 관리가 불필요하게 복잡해지게 됩니다.

이 생성자는 생성자에 전달하고 새로 만든 개체를 NTAccountNTAccount.NTAccount(String) 생성자에 전달 identity 하여 개체를 만드는 NTAccount 것과 RegistryAccessRule(IdentityReference, RegistryRights, InheritanceFlags, PropagationFlags, AccessControlType) 같습니다.

적용 대상