RegistryAccessRule Construtores
Definição
Importante
Algumas informações dizem respeito a um produto pré-lançado que pode ser substancialmente modificado antes de ser lançado. A Microsoft não faz garantias, de forma expressa ou implícita, em relação à informação aqui apresentada.
Inicializa uma nova instância da RegistryAccessRule classe.
Sobrecargas
| Name | Description |
|---|---|
| RegistryAccessRule(IdentityReference, RegistryRights, AccessControlType) |
Inicializa uma nova instância da RegistryAccessRule classe, especificando o utilizador ou grupo a que a regra se aplica, os direitos de acesso e se os direitos de acesso especificados são permitidos ou negados. |
| RegistryAccessRule(String, RegistryRights, AccessControlType) |
Inicializa uma nova instância da RegistryAccessRule classe, especificando o nome do utilizador ou grupo a que a regra se aplica, os direitos de acesso e se os direitos de acesso especificados são permitidos ou negados. |
| RegistryAccessRule(IdentityReference, RegistryRights, InheritanceFlags, PropagationFlags, AccessControlType) |
Inicializa uma nova instância da RegistryAccessRule classe, especificando o utilizador ou grupo a que a regra se aplica, os direitos de acesso, os flags de herança, os flags de propagação e se os direitos de acesso especificados são permitidos ou negados. |
| RegistryAccessRule(String, RegistryRights, InheritanceFlags, PropagationFlags, AccessControlType) |
Inicializa uma nova instância da RegistryAccessRule classe, especificando o nome do utilizador ou grupo a que a regra se aplica, os direitos de acesso, os flags de herança, os flags de propagação e se os direitos de acesso especificados são permitidos ou recusados. |
RegistryAccessRule(IdentityReference, RegistryRights, AccessControlType)
- Origem:
- RegistrySecurity.cs
Inicializa uma nova instância da RegistryAccessRule classe, especificando o utilizador ou grupo a que a regra se aplica, os direitos de acesso e se os direitos de acesso especificados são permitidos ou negados.
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)
Parâmetros
- identity
- IdentityReference
O utilizador ou grupo a que a regra se aplica. Deve ser de tipo SecurityIdentifier ou um tipo como NTAccount esse pode ser convertido em tipo SecurityIdentifier.
- registryRights
- RegistryRights
Uma combinação bit a bit de RegistryRights valores que indica os direitos permitidos ou negados.
- type
- AccessControlType
Um dos AccessControlType valores que indica se os direitos são permitidos ou negados.
Exceções
registryRights especifica um valor inválido.
-ou-
type especifica um valor inválido.
identity não é nem do tipo SecurityIdentifier nem de um tipo tal como NTAccount que pode ser convertido em tipo SecurityIdentifier.
Observações
Este construtor especifica propagação e herança por defeito. Ou seja, InheritanceFlags.None e PropagationFlags.None.
Aplica-se a
RegistryAccessRule(String, RegistryRights, AccessControlType)
- Origem:
- RegistrySecurity.cs
Inicializa uma nova instância da RegistryAccessRule classe, especificando o nome do utilizador ou grupo a que a regra se aplica, os direitos de acesso e se os direitos de acesso especificados são permitidos ou negados.
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)
Parâmetros
- identity
- String
O nome do utilizador ou grupo a que a regra se aplica.
- registryRights
- RegistryRights
Uma combinação bit a bit de RegistryRights valores que indica os direitos permitidos ou negados.
- type
- AccessControlType
Um dos AccessControlType valores que indica se os direitos são permitidos ou negados.
Exceções
registryRights especifica um valor inválido.
-ou-
type especifica um valor inválido.
registryRights é zero.
identity é null.
-ou-
identity é uma corda de comprimento zero.
-ou-
identity tem mais de 512 caracteres.
Exemplos
O exemplo de código seguinte cria regras de acesso ao registo e adiciona-as a um RegistrySecurity objeto, mostrando como as regras que permitem e negam direitos permanecem separadas, enquanto regras compatíveis do mesmo tipo são fundidas.
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
Observações
Este construtor especifica propagação e herança por defeito. Ou seja, InheritanceFlags.None e PropagationFlags.None.
Este construtor é equivalente a criar um NTAccount objeto, passando identity para o NTAccount.NTAccount(String) construtor, e passando o objeto recém-criado NTAccount para o RegistryAccessRule(IdentityReference, RegistryRights, AccessControlType) construtor.
Aplica-se a
RegistryAccessRule(IdentityReference, RegistryRights, InheritanceFlags, PropagationFlags, AccessControlType)
- Origem:
- RegistrySecurity.cs
Inicializa uma nova instância da RegistryAccessRule classe, especificando o utilizador ou grupo a que a regra se aplica, os direitos de acesso, os flags de herança, os flags de propagação e se os direitos de acesso especificados são permitidos ou negados.
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)
Parâmetros
- identity
- IdentityReference
O utilizador ou grupo a que a regra se aplica. Deve ser de tipo SecurityIdentifier ou um tipo como NTAccount esse pode ser convertido em tipo SecurityIdentifier.
- registryRights
- RegistryRights
Uma combinação bit a bit de RegistryRights valores que especifica os direitos permitidos ou negados.
- inheritanceFlags
- InheritanceFlags
Uma combinação bit a bit de InheritanceFlags flags que especifica como os direitos de acesso são herdados de outros objetos.
- propagationFlags
- PropagationFlags
Uma combinação bit a bit de PropagationFlags flags que especifica como os direitos de acesso são propagados para outros objetos.
- type
- AccessControlType
Um dos AccessControlType valores especifica se os direitos são permitidos ou negados.
Exceções
registryRights especifica um valor inválido.
-ou-
type especifica um valor inválido.
-ou-
inheritanceFlags especifica um valor inválido.
-ou-
propagationFlags especifica um valor inválido.
identity não é do tipo SecurityIdentifier, nem de um tipo tal como NTAccount que pode ser convertido em tipo SecurityIdentifier.
Observações
Todas as chaves de registo são contentores, por isso a única bandeira de herança significativa para chaves de registo é a InheritanceFlags.ContainerInherit flag. Se esta flag não for especificada, as flags de propagação são ignoradas e apenas a chave imediata é afetada. Se a bandeira estiver presente, a regra é propagada conforme mostrado na tabela seguinte. A tabela assume que existe uma subchave S com subchave filho CS e subchave neto GS. Ou seja, o caminho para a subchave do neto é S\CS\GS.
| Bandeiras de propagação | S | Ciência da Computação | GS |
|---|---|---|---|
| None | X | X | X |
| NoPropagateInherit | X | X | |
| InheritOnly | X | X | |
| NoPropagateInherit, InheritOnly | X |
O padrão para a subchave do neto governa todas as subchaves contidas pela subchave do neto.
Por exemplo, se o ContainerInherit flag for especificado para inheritanceFlags e o InheritOnly flag de propagação for especificado para propagationFlags, esta regra não se aplica à subchave imediata, mas aplica-se a todas as suas subchaves filhas imediatas e a todas as subchaves que contêm.
Note
Embora possas especificar o InheritanceFlags.ObjectInherit flag para inheritanceFlags, não faz sentido fazê-lo. Para efeitos de controlo de acesso, os pares nome/valor numa subchave não são objetos separados. Os direitos de acesso aos pares nome/valor são controlados pelos direitos da subchave. Além disso, como todas as subchaves são recipientes (ou seja, podem conter outras subchaves), não são afetadas pelo ObjectInherit flag. Finalmente, especificar a ObjectInherit bandeira complica desnecessariamente a manutenção das regras, porque interfere com a combinação de regras compatíveis.
Aplica-se a
RegistryAccessRule(String, RegistryRights, InheritanceFlags, PropagationFlags, AccessControlType)
- Origem:
- RegistrySecurity.cs
Inicializa uma nova instância da RegistryAccessRule classe, especificando o nome do utilizador ou grupo a que a regra se aplica, os direitos de acesso, os flags de herança, os flags de propagação e se os direitos de acesso especificados são permitidos ou recusados.
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)
Parâmetros
- identity
- String
O nome do utilizador ou grupo a que a regra se aplica.
- registryRights
- RegistryRights
Uma combinação bit a bit de RegistryRights valores que indica os direitos permitidos ou negados.
- inheritanceFlags
- InheritanceFlags
Uma combinação bit a bit de InheritanceFlags flags que especifica como os direitos de acesso são herdados de outros objetos.
- propagationFlags
- PropagationFlags
Uma combinação bit a bit de PropagationFlags flags que especifica como os direitos de acesso são propagados para outros objetos.
- type
- AccessControlType
Um dos AccessControlType valores especifica se os direitos são permitidos ou negados.
Exceções
registryRights especifica um valor inválido.
-ou-
type especifica um valor inválido.
-ou-
inheritanceFlags especifica um valor inválido.
-ou-
propagationFlags especifica um valor inválido.
eventRights é zero.
identity é null.
-ou-
identity é uma corda de comprimento zero.
-ou-
identity tem mais de 512 caracteres.
Exemplos
O exemplo de código seguinte demonstra regras de acesso com herança e propagação. O exemplo cria um RegistrySecurity objeto, e depois cria e adiciona duas regras que têm a ContainerInherit bandeira. A primeira regra não tem flags de propagação, enquanto a segunda tem NoPropagateInherit e InheritOnly.
O programa apresenta as regras no RegistrySecurity objeto e depois usa o RegistrySecurity objeto para criar uma subchave. O programa cria uma subchave filho e uma subchave neta, e depois apresenta as regras para cada subchave. Finalmente, o programa elimina as teclas de teste.
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
Observações
Todas as chaves de registo são contentores, por isso a única bandeira de herança significativa para chaves de registo é a InheritanceFlags.ContainerInherit flag. Se esta flag não for especificada, as flags de propagação são ignoradas e apenas a chave imediata é afetada. Se a bandeira estiver presente, a regra é propagada conforme mostrado na tabela seguinte. A tabela assume que existe uma subchave S com subchave filho CS e subchave neto GS. Ou seja, o caminho para a subchave do neto é S\CS\GS.
| Bandeiras de propagação | S | Ciência da Computação | GS |
|---|---|---|---|
| None | X | X | X |
| NoPropagateInherit | X | X | |
| InheritOnly | X | X | |
| NoPropagateInherit, InheritOnly | X |
O padrão para a subchave do neto governa todas as subchaves contidas pela subchave do neto.
Por exemplo, se o ContainerInherit flag for especificado para inheritanceFlags e o InheritOnly flag de propagação for especificado para propagationFlags, esta regra não se aplica à subchave imediata, mas aplica-se a todas as suas subchaves filhas imediatas e a todas as subchaves que contêm.
Note
Embora possas especificar o InheritanceFlags.ObjectInherit flag para inheritanceFlags, não faz sentido fazê-lo. Para efeitos de controlo de acesso, os pares nome/valor numa subchave não são objetos separados. Os direitos de acesso aos pares nome/valor são controlados pelos direitos da subchave. Além disso, como todas as subchaves são recipientes (ou seja, podem conter outras subchaves), não são afetadas pelo ObjectInherit flag. Finalmente, especificar a ObjectInherit bandeira complica desnecessariamente a manutenção das regras, porque interfere com a combinação de regras compatíveis.
Este construtor é equivalente a criar um NTAccount objeto, passando identity para o NTAccount.NTAccount(String) construtor, e passando o objeto recém-criado NTAccount para o RegistryAccessRule(IdentityReference, RegistryRights, InheritanceFlags, PropagationFlags, AccessControlType) construtor.