Directory Services

Binding Using GUID

To retrieve the GUID assigned to an object, use the NativeGuid property provided by the DirectoryEntry class.

The following code example shows how to use the NativeGuid property.

[C#]
DirectoryEntry ent = new DirectoryEntry();
String ADGuid = ent.NativeGuid;
// Rebind using ADGuid.
DirectoryEntry x = new DirectoryEntry("LDAP://<GUID="+ADGuid+">");
Console.WriteLine("These should be the same: {0} == {1}", ent.Name,x.Name);
[Visual Basic .NET]
Dim ent As New DirectoryEntry()
Dim ADGuid As [String] = ent.NativeGuid
' Rebind using ADGuid.
Dim x As New DirectoryEntry("LDAP://<GUID=" + ADGuid + ">")
Console.WriteLine("These should be the same: {0} == {1}", ent.Name, x.Name)