Share via


DirectoryEntry.NativeGuid

The NativeGuid property gets the globally unique identifier of the DirectoryEntry, as returned from the provider.

public String NativeGuid {get;}
Public ReadOnly Property NativeGuid As String

Property Value

The globally unique identifier of the DirectoryEntry, as returned from the provider.

Remarks

Use the NativeGuid property when binding an object in Active Directory.

Note  The Lightweight Directory Access Protocol (LDAP) provider returns the globally unique identifier of a DirectoryEntry in a different format than the Internet Information Services (IIS), Novell NetWare Directory Server (NDS), and WinNT providers.

Example Code [Visual Basic .NET]

The following example demonstrates the Guid and NativeGuid properties of the DirectoryEntry class. This example gets the user-specified DirectoryEntry and displays its Guid and NativeGuid properties.

Dim myADSPath As [String] = "LDAP://onecity/CN=Users,
             DC=onecity,DC=corp,DC=fabrikam,DC=com"
Dim myDirectoryEntry As New DirectoryEntry(myADSPath)

' Display the Guid and NativeGuid.
Console.WriteLine("The GUID of the ADS object:" + myDirectoryEntry.Guid.ToString)
Console.WriteLine("The Native GUID of the ADS" + "object:" + 
             myDirectoryEntry.NativeGuid)

Example Code [C#]

The following example demonstrates the Guid and NativeGuid properties of the DirectoryEntry class. This example gets the user-specified DirectoryEntry and displays its Guid and NativeGuid properties.

String myADSPath = "LDAP://onecity/CN=Users,
             DC=onecity,DC=corp,DC=fabrikam,DC=com";
DirectoryEntry myDirectoryEntry=new DirectoryEntry(myADSPath);

// Display the Guid and NativeGuid.
Console.WriteLine("The GUID of the ADS object:"+
                  myDirectoryEntry.Guid);
Console.WriteLine("The Native GUID of the ADS"+
                  "object:"+myDirectoryEntry.NativeGuid);

Example Code [Managed C++]

The following example demonstrates the Guid and NativeGuid properties of the DirectoryEntry class. This example gets the user-specified DirectoryEntry and displays its Guid and NativeGuid properties.

String* myADSPath = S"LDAP://onecity/CN=Users,DC=onecity,DC=corp,DC=fabrikam,DC=com";
DirectoryEntry* myDirectoryEntry = new DirectoryEntry(myADSPath);

// Display the Guid and NativeGuid.
Console::WriteLine("The GUID of the ADS object: {0}", __box(myDirectoryEntry->Guid));
Console::WriteLine("The Native GUID of the ADS object: {0}",
                   myDirectoryEntry->NativeGuid);

Requirements

Client Requires Windows XP Home Edition, Windows XP Professional, Windows Me, or Windows 98.
Server Requires Windows Server 2003, Windows 2000, or Windows NT 4.0.
Namespace

Defined in System.DirectoryServices.

Assembly

Requires System.DirectoryServices (in System.DirectoryServices.dll).

.NET Framework

Requires .NET Framework 1.0.