This documentation is archived and is not being maintained.

DirectoryEntry.Name Property

Gets the name of the object as named with the underlying directory service.

[Visual Basic]
Public ReadOnly Property Name As String
public string Name {get;}
public: __property String* get_Name();
public function get Name() : String;

Property Value

The name of the object as named with the underlying directory service.


This name, along with SchemaClassName, distinguishes this entry from its siblings and must be unique amongst its siblings in each instance of DirectoryEntry.


[Visual Basic, C#, C++] The following example creates a DirectoryEntry for the node in the Active Directory. It then displays the Name and Path properties of its child nodes.

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

Console.WriteLine("DirectoryEntry Name :" + myDirectoryEntry.Name)
Console.WriteLine(ControlChars.NewLine _
        + "The child entries for this node in the Active Directory hierarchy")

Dim myDirectoryEntryChild As DirectoryEntry
For Each myDirectoryEntryChild In  myDirectoryEntry.Children
Next myDirectoryEntryChild

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

Console.WriteLine("DirectoryEntry Name :"+ myDirectoryEntry.Name);
Console.WriteLine("\nThe child entries for this node "+
   "in the Active Directory hierarchy");

foreach(DirectoryEntry myDirectoryEntryChild in

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

Console::WriteLine(S"DirectoryEntry Name : {0}", myDirectoryEntry->Name);
Console::WriteLine(S"\nThe child entries for this node in the Active Directory hierarchy");

Collections::IEnumerator* myEnumerator = myDirectoryEntry->Children->GetEnumerator();
while (myEnumerator->MoveNext()) {
    DirectoryEntry* myDirectoryEntryChild = __try_cast<DirectoryEntry*>(myEnumerator->Current);

[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.


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