Recupero dell'identità di un oggetto

DirectoryEntry fornisce diverse proprietà che consentono di recuperare l'identità di un oggetto.

Nell'esempio di codice riportato di seguito viene illustrato come recuperare le proprietà Path, Guid e Name per un oggetto utente.

try
{
   // Bind to the object for which to retrieve property data.
   DirectoryEntry usr = new DirectoryEntry("LDAP://CN=User Name,OU=HR,DC=fabrikam,DC=com");
   // Retrieve and write the Path for the object.
   Console.WriteLine("Path: {0}", usr.Path);
   // Retrieve and write the Guid for the object.
   Console.WriteLine("Guid: {0}", usr.Guid);
   // Retrieve and write the Name for the object.
   Console.WriteLine("Name: {0}", usr.Name);
   // Retrieve and write the DN for the object.
   Console.WriteLine("DN: {0}", usr.Properties["distinguishedName"].Value);
}
catch
{
   // Add error handling.
}

Vedere anche

Riferimenti

System.DirectoryServices
DirectoryEntry

Concetti

Introduzione a System.DirectoryServices

Send comments about this topic to Microsoft.

Copyright © 2007 Microsoft Corporation. Tutti i diritti riservati.