RegistryAccessRule Costruttori
Definizione
Importante
Alcune informazioni sono relative alla release non definitiva del prodotto, che potrebbe subire modifiche significative prima della release definitiva. Microsoft non riconosce alcuna garanzia, espressa o implicita, in merito alle informazioni qui fornite.
Inizializza una nuova istanza della classe RegistryAccessRule.
Overload
| Nome | Descrizione |
|---|---|
| RegistryAccessRule(IdentityReference, RegistryRights, AccessControlType) |
Inizializza una nuova istanza della RegistryAccessRule classe , specificando l'utente o il gruppo a cui si applica la regola, i diritti di accesso e se i diritti di accesso specificati sono consentiti o negati. |
| RegistryAccessRule(String, RegistryRights, AccessControlType) |
Inizializza una nuova istanza della RegistryAccessRule classe , specificando il nome dell'utente o del gruppo a cui si applica la regola, i diritti di accesso e se i diritti di accesso specificati sono consentiti o negati. |
| RegistryAccessRule(IdentityReference, RegistryRights, InheritanceFlags, PropagationFlags, AccessControlType) |
Inizializza una nuova istanza della RegistryAccessRule classe , specificando l'utente o il gruppo a cui si applica la regola, i diritti di accesso, i flag di ereditarietà, i flag di propagazione e se i diritti di accesso specificati sono consentiti o negati. |
| RegistryAccessRule(String, RegistryRights, InheritanceFlags, PropagationFlags, AccessControlType) |
Inizializza una nuova istanza della RegistryAccessRule classe , specificando il nome dell'utente o del gruppo a cui si applica la regola, i diritti di accesso, i flag di ereditarietà, i flag di propagazione e se i diritti di accesso specificati sono consentiti o negati. |
RegistryAccessRule(IdentityReference, RegistryRights, AccessControlType)
- Origine:
- RegistrySecurity.cs
Inizializza una nuova istanza della RegistryAccessRule classe , specificando l'utente o il gruppo a cui si applica la regola, i diritti di accesso e se i diritti di accesso specificati sono consentiti o negati.
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)
Parametri
- identity
- IdentityReference
L'utente o il gruppo a cui si applica la regola. Deve essere di tipo o di un tipo SecurityIdentifier , ad esempio NTAccount , che può essere convertito nel tipo SecurityIdentifier.
- registryRights
- RegistryRights
Combinazione bit per bit di RegistryRights valori che indica i diritti consentiti o negati.
- type
- AccessControlType
Uno dei AccessControlType valori che indica se i diritti sono consentiti o negati.
Eccezioni
registryRights specifica un valore non valido.
oppure
type specifica un valore non valido.
identity non è né di tipo né di un tipo SecurityIdentifier , NTAccount ad esempio che può essere convertito in tipo SecurityIdentifier.
Commenti
Questo costruttore specifica la propagazione e l'ereditarietà predefinite. Vale a dire, InheritanceFlags.None e PropagationFlags.None.
Si applica a
RegistryAccessRule(String, RegistryRights, AccessControlType)
- Origine:
- RegistrySecurity.cs
Inizializza una nuova istanza della RegistryAccessRule classe , specificando il nome dell'utente o del gruppo a cui si applica la regola, i diritti di accesso e se i diritti di accesso specificati sono consentiti o negati.
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)
Parametri
- identity
- String
Nome dell'utente o del gruppo a cui si applica la regola.
- registryRights
- RegistryRights
Combinazione bit per bit di RegistryRights valori che indica i diritti consentiti o negati.
- type
- AccessControlType
Uno dei AccessControlType valori che indica se i diritti sono consentiti o negati.
Eccezioni
registryRights specifica un valore non valido.
oppure
type specifica un valore non valido.
registryRights è zero.
identity è null.
oppure
identity è una stringa di lunghezza zero.
oppure
identity è più lungo di 512 caratteri.
Esempio
L'esempio di codice seguente crea regole di accesso al Registro di sistema e le aggiunge a un RegistrySecurity oggetto, mostrando in che modo le regole che consentono e negano i diritti rimangono separate, mentre le regole compatibili dello stesso tipo vengono unite.
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
Commenti
Questo costruttore specifica la propagazione e l'ereditarietà predefinite. Vale a dire, InheritanceFlags.None e PropagationFlags.None.
Questo costruttore equivale alla creazione di un NTAccount oggetto, passando identity al NTAccount.NTAccount(String) costruttore e passando l'oggetto appena creato NTAccount al RegistryAccessRule(IdentityReference, RegistryRights, AccessControlType) costruttore.
Si applica a
RegistryAccessRule(IdentityReference, RegistryRights, InheritanceFlags, PropagationFlags, AccessControlType)
- Origine:
- RegistrySecurity.cs
Inizializza una nuova istanza della RegistryAccessRule classe , specificando l'utente o il gruppo a cui si applica la regola, i diritti di accesso, i flag di ereditarietà, i flag di propagazione e se i diritti di accesso specificati sono consentiti o negati.
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)
Parametri
- identity
- IdentityReference
L'utente o il gruppo a cui si applica la regola. Deve essere di tipo o di un tipo SecurityIdentifier , ad esempio NTAccount , che può essere convertito nel tipo SecurityIdentifier.
- registryRights
- RegistryRights
Combinazione bit per bit di RegistryRights valori che specificano i diritti consentiti o negati.
- inheritanceFlags
- InheritanceFlags
Combinazione bit per bit di flag che specifica il modo in cui i diritti di InheritanceFlags accesso vengono ereditati da altri oggetti.
- propagationFlags
- PropagationFlags
Combinazione bit per bit di flag che specifica la modalità di propagazione dei diritti di PropagationFlags accesso ad altri oggetti.
- type
- AccessControlType
Uno dei AccessControlType valori che specifica se i diritti sono consentiti o negati.
Eccezioni
registryRights specifica un valore non valido.
oppure
type specifica un valore non valido.
oppure
inheritanceFlags specifica un valore non valido.
oppure
propagationFlags specifica un valore non valido.
identity non è né di tipo SecurityIdentifierné di un tipo, ad esempio NTAccount che può essere convertito in tipo SecurityIdentifier.
Commenti
Tutte le chiavi del Registro di sistema sono contenitori, quindi l'unico flag di ereditarietà significativo per le chiavi del Registro di sistema è il InheritanceFlags.ContainerInherit flag . Se questo flag non viene specificato, i flag di propagazione vengono ignorati e viene interessata solo la chiave immediata. Se il flag è presente, la regola viene propagata come illustrato nella tabella seguente. La tabella presuppone che sia presente una sottochiave S con sottochiave figlio CS e sottochiave nipote GS. Ovvero, il percorso della sottochiave nipote è S\CS\GS.
| Flag di propagazione | S | Informatica | GS |
|---|---|---|---|
| None | X | X | X |
| NoPropagateInherit | X | X | |
| InheritOnly | X | X | |
| NoPropagateInherit, InheritOnly | X |
Il modello per la sottochiave nipote regola tutte le sottochiavi contenute nella sottochiave grandchild.
Ad esempio, se il ContainerInherit flag viene specificato per inheritanceFlags e il InheritOnly flag di propagazione viene specificato per propagationFlags, questa regola non si applica alla sottochiave immediata, ma si applica a tutte le relative sottochiavi figlio immediate e a tutte le sottochiavi che contengono.
Note
Anche se è possibile specificare il InheritanceFlags.ObjectInherit flag per inheritanceFlags, non c'è alcun punto in questo modo. Ai fini del controllo di accesso, le coppie nome/valore in una sottochiave non sono oggetti separati. I diritti di accesso alle coppie nome/valore sono controllati dai diritti della sottochiave. Inoltre, poiché tutte le sottochiavi sono contenitori ,ovvero possono contenere altre sottochiavi, non sono interessate dal ObjectInherit flag. Infine, specificando il ObjectInherit flag inutilmente complica la manutenzione delle regole, perché interferisce con la combinazione di regole altrimenti compatibili.
Si applica a
RegistryAccessRule(String, RegistryRights, InheritanceFlags, PropagationFlags, AccessControlType)
- Origine:
- RegistrySecurity.cs
Inizializza una nuova istanza della RegistryAccessRule classe , specificando il nome dell'utente o del gruppo a cui si applica la regola, i diritti di accesso, i flag di ereditarietà, i flag di propagazione e se i diritti di accesso specificati sono consentiti o negati.
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)
Parametri
- identity
- String
Nome dell'utente o del gruppo a cui si applica la regola.
- registryRights
- RegistryRights
Combinazione bit per bit di RegistryRights valori che indica i diritti consentiti o negati.
- inheritanceFlags
- InheritanceFlags
Combinazione bit per bit di flag che specifica il modo in cui i diritti di InheritanceFlags accesso vengono ereditati da altri oggetti.
- propagationFlags
- PropagationFlags
Combinazione bit per bit di flag che specifica la modalità di propagazione dei diritti di PropagationFlags accesso ad altri oggetti.
- type
- AccessControlType
Uno dei AccessControlType valori che specifica se i diritti sono consentiti o negati.
Eccezioni
registryRights specifica un valore non valido.
oppure
type specifica un valore non valido.
oppure
inheritanceFlags specifica un valore non valido.
oppure
propagationFlags specifica un valore non valido.
eventRights è zero.
identity è null.
oppure
identity è una stringa di lunghezza zero.
oppure
identity è più lungo di 512 caratteri.
Esempio
Nell'esempio di codice seguente vengono illustrate le regole di accesso con ereditarietà e propagazione. Nell'esempio viene creato un RegistrySecurity oggetto e quindi vengono create e aggiunte due regole con il ContainerInherit flag . La prima regola non ha flag di propagazione, mentre la seconda ha NoPropagateInherit e InheritOnly.
Il programma visualizza le regole nell'oggetto RegistrySecurity e quindi usa l'oggetto RegistrySecurity per creare una sottochiave. Il programma crea una sottochiave figlio e una sottochiave nipote e quindi visualizza le regole per ogni sottochiave. Infine, il programma elimina le chiavi di test.
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
Commenti
Tutte le chiavi del Registro di sistema sono contenitori, quindi l'unico flag di ereditarietà significativo per le chiavi del Registro di sistema è il InheritanceFlags.ContainerInherit flag . Se questo flag non viene specificato, i flag di propagazione vengono ignorati e viene interessata solo la chiave immediata. Se il flag è presente, la regola viene propagata come illustrato nella tabella seguente. La tabella presuppone che sia presente una sottochiave S con sottochiave figlio CS e sottochiave nipote GS. Ovvero, il percorso della sottochiave nipote è S\CS\GS.
| Flag di propagazione | S | Informatica | GS |
|---|---|---|---|
| None | X | X | X |
| NoPropagateInherit | X | X | |
| InheritOnly | X | X | |
| NoPropagateInherit, InheritOnly | X |
Il modello per la sottochiave nipote regola tutte le sottochiavi contenute nella sottochiave grandchild.
Ad esempio, se il ContainerInherit flag viene specificato per inheritanceFlags e il InheritOnly flag di propagazione viene specificato per propagationFlags, questa regola non si applica alla sottochiave immediata, ma si applica a tutte le relative sottochiavi figlio immediate e a tutte le sottochiavi che contengono.
Note
Anche se è possibile specificare il InheritanceFlags.ObjectInherit flag per inheritanceFlags, non c'è alcun punto in questo modo. Ai fini del controllo di accesso, le coppie nome/valore in una sottochiave non sono oggetti separati. I diritti di accesso alle coppie nome/valore sono controllati dai diritti della sottochiave. Inoltre, poiché tutte le sottochiavi sono contenitori ,ovvero possono contenere altre sottochiavi, non sono interessate dal ObjectInherit flag. Infine, specificando il ObjectInherit flag inutilmente complica la manutenzione delle regole, perché interferisce con la combinazione di regole altrimenti compatibili.
Questo costruttore equivale alla creazione di un NTAccount oggetto, passando identity al NTAccount.NTAccount(String) costruttore e passando l'oggetto appena creato NTAccount al RegistryAccessRule(IdentityReference, RegistryRights, InheritanceFlags, PropagationFlags, AccessControlType) costruttore.