Each network resource is represented in the directory as an
object. Directory objects have the following characteristics:
Name. The object name is also known as the relative
distinguished name (RDN). The format for the RDN uses the syntax
key=value. For example, in the following diagram, the RDN for a
user object is CN=Alice Reed. Be aware that spaces are
excluded.
Parent. Network objects are hierarchical and have a
parent object until you reach the root object, which is the domain
object, sometimes called the domain head, at the top of the
hierarchy.
Path. The directory object path is also known as the
distinguished name (DN). The distinguished name is constructed with
the object name preceded by the names of each parent object up to
the root object. For example, for the user object CN=Alice Reed,
the DN begins with the root object and follows the path to the user
object, as follows: DC=Fabrikam,DC=COM,OU=Sales,CN=Alice Reed.
Paths use a syntax defined by the LDAP specification. For more
information about the proper syntax for the path, see Binding Strings. The path is used in a
binding string created with the DirectoryEntry object. Formats for
commonly used binding strings are shown in Binding Strings.
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);