RegistryAccessRule 构造函数
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
初始化 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 值之一,用于指示是允许还是拒绝相应权限。
例外
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
为零。
示例
下面的代码示例创建注册表访问规则并将其添加到 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。
此构造函数等效于通过NTAccount传递给identity
NTAccount.NTAccount(String)构造函数并将新创建NTAccount的对象传递给构造函数来创建对象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
既不属于类型 SecurityIdentifier,也不属于可以转换为 NTAccount 类型的类型(如 SecurityIdentifier)。
注解
所有注册表项都是容器,因此唯一对注册表项有意义的继承标志是 InheritanceFlags.ContainerInherit 标志。 如果未指定此标志,则忽略传播标志,并且仅影响即时键。 如果该标志存在,则传播规则,如下表所示。 该表假定有一个子项 S,其中包含子子项 CS 和孙子项 GS。 也就是说,孙子项的路径为 S\CS\GS。
传播标志 | S | CS | GS |
---|---|---|---|
None | X | X | X |
NoPropagateInherit | X | X | |
InheritOnly | X | X | |
NoPropagateInherit, InheritOnly | X |
孙子项的模式控制孙子项包含的所有子项。
例如,如果 ContainerInherit 为 inheritanceFlags
指定标志,并为 InheritOnly 指定 propagationFlags
传播标志,则此规则不适用于直接子项,但应用于其所有直接子项以及它们包含的所有子项。
注意
尽管可以为 指定 InheritanceFlags.ObjectInherit 标志 inheritanceFlags
,但这样做毫无意义。 出于访问控制的目的,子项中的名称/值对不是单独的对象。 对名称/值对的访问权限由子项的权限控制。 此外,由于所有子项都是容器 (也就是说,它们可以包含) 的其他子项,因此它们不受 标志的影响 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
为零。
示例
下面的代码示例演示具有继承和传播的访问规则。 该示例创建一个 对象,然后创建并添加两个 RegistrySecurity 具有 ContainerInherit 标志的规则。 第一个规则没有传播标志,而第二个规则具有 NoPropagateInherit 和 InheritOnly。
程序显示 对象中的 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 标志。 如果未指定此标志,则忽略传播标志,并且仅影响即时键。 如果该标志存在,则传播规则,如下表所示。 该表假定有一个子项 S,其中包含子子项 CS 和孙子项 GS。 也就是说,孙子项的路径为 S\CS\GS。
传播标志 | S | CS | GS |
---|---|---|---|
None | X | X | X |
NoPropagateInherit | X | X | |
InheritOnly | X | X | |
NoPropagateInherit, InheritOnly | X |
孙子项的模式控制孙子项包含的所有子项。
例如,如果 ContainerInherit 为 inheritanceFlags
指定标志,并为 InheritOnly 指定 propagationFlags
传播标志,则此规则不适用于直接子项,但应用于其所有直接子项以及它们包含的所有子项。
注意
尽管可以为 指定 InheritanceFlags.ObjectInherit 标志 inheritanceFlags
,但这样做毫无意义。 出于访问控制的目的,子项中的名称/值对不是单独的对象。 对名称/值对的访问权限由子项的权限控制。 此外,由于所有子项都是容器 (也就是说,它们可以包含) 的其他子项,因此它们不受 标志的影响 ObjectInherit 。 最后,不必要地 ObjectInherit 指定标志会使规则的维护复杂化,因为它会干扰其他兼容规则的组合。
此构造函数等效于通过NTAccount传递给identity
NTAccount.NTAccount(String)构造函数并将新创建NTAccount的对象传递给构造函数来创建对象RegistryAccessRule(IdentityReference, RegistryRights, InheritanceFlags, PropagationFlags, AccessControlType)。