Directory Services

Directory Objects

Each network resource is represented in the directory as an object. Directory objects have the following characteristics:

While the previous information is applicable to any LDAP directory object that you connect to using System.DirectoryServices, there are some things that are specific to Active Directory. One feature of Active Directory objects is that they must contain a globally unique identifier (GUID). While the values for different attributes on the object may be modified, the GUID is immutable.

In System.DirectoryServices, each entry in the directory is represented by the DirectoryEntry object. DirectoryEntry creates an entry object in memory; it does not actually create the object in the directory. The following code example shows how to create a DirectoryEntry and write its path, name and GUID.

[C#]
using System.DirectoryServices;
...
DirectoryEntry entry = new DirectoryEntry(path);
Console.WriteLine(entry.Path);
Console.WriteLine(entry.Name);
Console.WriteLine(entry.GUID);