Nota
L'accesso a questa pagina richiede l'autorizzazione. È possibile provare ad accedere o modificare le directory.
L'accesso a questa pagina richiede l'autorizzazione. È possibile provare a modificare le directory.
Proprietà come nTSecurityDescriptor utilizzano il tipo di sintassi String(NT-Sec_Desc). Se si ottiene una proprietà di questo tipo con la proprietà Properties, questo tipo di dati viene rappresentato come un oggetto COM di cui può essere eseguito il cast a IADsSecurityDescriptor. Se si ottiene una proprietà di questo tipo da ResultPropertyValueCollection, questo tipo di dati viene rappresentato come una matrice di valori Byte. Per ulteriori informazioni sulla proprietà nTSecurityDescriptor, sul tipo di sintassi String(NT-Sec_Desc) e sull'interfaccia IADsSecurityDescriptor, vedere gli argomenti relativi a nTSecurityDescriptor, the String(NT-Sec_Desc) e IADsSecurityDescriptor in MSDN Library all'indirizzo https://go.microsoft.com/fwlink/?LinkID=27252.
A partire da .NET Framework 2.0, il descrittore di protezione per un oggetto Servizi di dominio Active Directory è rappresentato dalla classe ActiveDirectorySecurity e può essere ottenuto o impostato con la proprietà ObjectSecurity.
Nell'esempio Visual Basic riportato di seguito viene illustrato come leggere un descrittore di protezione in un oggetto.
Imports ActiveDS
Imports System.Collections
Dim ent As New DirectoryEntry("LDAP://CN=My User Name,OU=Marketing,DC=fabrikam,DC=com")
Dim sd As SecurityDescriptor = CType(ent.Properties("ntSecurityDescriptor").Value, SecurityDescriptor)
Dim acl As AccessControlList = CType(sd.DiscretionaryAcl, AccessControlList)
Dim ace As AccessControlEntry
For Each ace In CType(acl, IEnumerable)
Console.WriteLine("Trustee: {0}", ace.Trustee)
Console.WriteLine("AccessMask: {0}", ace.AccessMask)
Console.WriteLine("Access Type: {0}", ace.AceType)
Next ace
using ActiveDs;
using System.Collections;
DirectoryEntry ent = new DirectoryEntry("LDAP://CN=My User Name,OU=Marketing,DC=fabrikam,DC=com");
SecurityDescriptor sd = (SecurityDescriptor) ent.Properties["ntSecurityDescriptor"].Value;
AccessControlList acl= (AccessControlList) sd.DiscretionaryAcl;
foreach(AccessControlEntry ace in (IEnumerable) acl)
{
Console.WriteLine("Trustee: {0}", ace.Trustee);
Console.WriteLine("AccessMask: {0}", ace.AccessMask);
Console.WriteLine("Access Type: {0}", ace.AceType);
}
Nell'esempio Visual Basic riportato di seguito viene illustrato come scrivere un descrittore di protezione in un oggetto.
Import ActiveDS
Dim usr As New DirectoryEntry("LDAP://CN=My User Name,OU=Marketing,DC=fabrikam,DC=com")
Dim newAce = New AccessControlEntryClass()
Dim usrSD As SecurityDescriptor = CType(usr.Properties("ntSecurityDescriptor").Value, SecurityDescriptor)
Dim usrAcl As AccessControlList = CType(usrSD.DiscretionaryAcl, AccessControlList)
newAce.Trustee = "AliceW"
newAce.AccessMask = - 1
newAce.AceType = 0
usrAcl.AddAce(newAce)
usrSD.DiscretionaryAcl = usrAcl
usr.Properties("ntSecurityDescriptor").Value = usrSD
usr.CommitChanges()
using ActiveDS;
DirectoryEntry usr = new DirectoryEntry("LDAP://CN=My User Name,OU=Marketing,DC=fabrikam,DC=com");
AccessControlEntry newAce = new AccessControlEntryClass();
SecurityDescriptor usrSD = (SecurityDescriptor)usr.Properties["ntSecurityDescriptor"].Value; AccessControlList usrAcl= (AccessControlList) usrSD.DiscretionaryAcl;
newAce.Trustee = "AliceW";
newAce.AccessMask = -1;
newAce.AceType = 0;
usrAcl.AddAce(newAce);
usrSD.DiscretionaryAcl = usrAcl;
usr.Properties["ntSecurityDescriptor"].Value = usrSD;
usr.CommitChanges();
Vedere anche
Riferimenti
System.DirectoryServices
ActiveDirectorySecurity
DirectoryEntry
ResultPropertyValueCollection
Byte
Concetti
Send comments about this topic to Microsoft.
Copyright © 2007 Microsoft Corporation. Tutti i diritti riservati.