Export (0) Print
Expand All

DirectoryEntry.Guid Property

Gets the globally unique identifier (GUID) of the DirectoryEntry.

[Visual Basic]
Public ReadOnly Property Guid As Guid
[C#]
public Guid Guid {get;}
[C++]
public: __property Guid get_Guid();
[JScript]
public function get Guid() : Guid;

Property Value

The globally unique identifier of the DirectoryEntry.

Remarks

When binding to an object in Active Directory, use the NativeGuid property.

Example

[Visual Basic, C#, 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.

[Visual Basic] 
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)

[C#] 
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);

[C++] 
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);

[JScript] No example is available for JScript. To view a Visual Basic, C#, or C++ example, click the Language Filter button Language Filter in the upper-left corner of the page.

Requirements

Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family

.NET Framework Security: 

See Also

DirectoryEntry Class | DirectoryEntry Members | System.DirectoryServices Namespace | Guid | NativeGuid

Show:
© 2014 Microsoft