DirectoryEntry.Name
The Name property gets the name of the object as named with the underlying directory service.
public String Name {get;}
Public ReadOnly Property Name As String
Property Value
The name of the object as named with the underlying directory service.
Remarks
This name, along with SchemaClassName, distinguishes this entry from its siblings and must be unique among its siblings in each instance of DirectoryEntry.
Example Code [Visual Basic .NET]
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.
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 Console.WriteLine(myDirectoryEntryChild.Path) Next myDirectoryEntryChild
Example Code [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.
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 myDirectoryEntry.Children) { Console.WriteLine(myDirectoryEntryChild.Path); }
Example Code [Managed 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.
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); Console::WriteLine(myDirectoryEntryChild->Path); }
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. |