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)

ソース:
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 値の 1 つ。

例外

registryRights に無効な値が指定されています。

- または -

type に無効な値が指定されています。

identitynullです。

- または -

eventRights が 0 です。

identitySecurityIdentifier 型ではなく、NTAccount 型に変換できる SecurityIdentifier などの型でもありません。

注釈

このコンストラクターは、既定の伝達と継承を指定します。 つまり、 InheritanceFlags.NonePropagationFlags.Noneです。

適用対象

RegistryAccessRule(String, RegistryRights, AccessControlType)

ソース:
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 値の 1 つ。

例外

registryRights に無効な値が指定されています。

- または -

type に無効な値が指定されています。

registryRights が 0 です。

identitynullです。

- または -

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.NTAccount(String)コンストラクターに渡すことによって、オブジェクトをRegistryAccessRule(IdentityReference, RegistryRights, AccessControlType)作成NTAccountすることと同じです。

適用対象

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

ソース:
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 値の 1 つ。

例外

registryRights に無効な値が指定されています。

- または -

type に無効な値が指定されています。

- または -

inheritanceFlags に無効な値が指定されています。

- または -

propagationFlags に無効な値が指定されています。

identitynullです。

- または -

registryRights が 0 です。

identitySecurityIdentifier 型ではなく、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

孫サブキーのパターンは、孫サブキーに含まれるすべてのサブキーを制御します。

たとえば、 フラグが ContainerInherit に指定されInheritOnly、 に伝達フラグが指定されているpropagationFlags場合、この規則はイミディエイト サブキーには適用されませんが、すべての直接の子サブキーと、そのサブキーに含まれるすべてのサブキーinheritanceFlagsに適用されます。

Note

にフラグinheritanceFlagsInheritanceFlags.ObjectInherit指定することはできますが、その意味はありません。 アクセス制御の目的上、サブキー内の名前と値のペアは個別のオブジェクトではありません。 名前と値のペアへのアクセス権は、サブキーの権限によって制御されます。 さらに、すべてのサブキーはコンテナー (つまり、他のサブキーを含むことができる) であるため、フラグの影響を ObjectInherit 受けません。 最後に、フラグを ObjectInherit 指定すると、他の互換性のあるルールの組み合わせに干渉するため、ルールのメンテナンスが不必要に複雑になります。

適用対象

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

ソース:
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 値の 1 つ。

例外

registryRights に無効な値が指定されています。

- または -

type に無効な値が指定されています。

- または -

inheritanceFlags に無効な値が指定されています。

- または -

propagationFlags に無効な値が指定されています。

eventRights が 0 です。

identitynullです。

- または -

identity は長さゼロの文字列です。

- または -

identity が 512 文字を超えています。

次のコード例では、継承と伝達を使用したアクセス規則を示します。 この例では、 オブジェクトを RegistrySecurity 作成し、 フラグを持つ 2 つのルールを ContainerInherit 作成して追加します。 最初のルールには伝達フラグがありませんが、2 番目のルールには と InheritOnlyがありますNoPropagateInherit

プログラムは オブジェクトにルールを 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

孫サブキーのパターンは、孫サブキーに含まれるすべてのサブキーを管理します。

たとえば、 フラグが にinheritanceFlags指定されInheritOnly、 に伝達フラグが指定されているpropagationFlags場合ContainerInherit、この規則は即時サブキーには適用されませんが、すべての直接の子サブキーと、それらが含むすべてのサブキーに適用されます。

Note

にフラグinheritanceFlagsInheritanceFlags.ObjectInherit指定することはできますが、その意味はありません。 アクセス制御の目的上、サブキー内の名前と値のペアは個別のオブジェクトではありません。 名前と値のペアへのアクセス権は、サブキーの権限によって制御されます。 さらに、すべてのサブキーはコンテナーであるため (つまり、他のサブキーを含めることができます)、フラグの影響を ObjectInherit 受けなくなります。 最後に、フラグを ObjectInherit 指定すると、それ以外の互換性のあるルールの組み合わせに干渉するため、ルールのメンテナンスが不必要に複雑になります。

このコンストラクターは、コンストラクターにを渡しidentity、新しく作成したオブジェクトをNTAccount.NTAccount(String)コンストラクターに渡すことで、オブジェクトをRegistryAccessRule(IdentityReference, RegistryRights, InheritanceFlags, PropagationFlags, AccessControlType)作成NTAccountNTAccountすることと同じです。

適用対象