DirectoryEntry.Parent
The Parent property gets this entry's parent in the Active Directory hierarchy.
public DirectoryEntry Parent {get;}
Public ReadOnly Property Parent As DirectoryEntry
Example Code [Visual Basic .NET]
The following example searches a given DirectoryEntry and displays the Name and Parent of the result.
Dim myADSPath As String = _ "LDAP://onecity/CN=user,CN=Users,DC=onecity,DC=corp,DC=fabrikam,DC=com" Dim myDirectoryEntry As New DirectoryEntry(myADSPath, UserName, SecurelyStoredPassword) Console.WriteLine("Parent is :" + myDirectoryEntry.Parent.Path)
Example Code [C#]
The following example searches a given DirectoryEntry and displays the Name and Parent of the result.
String myADSPath = "LDAP://onecity/CN=user,CN=Users,DC=onecity,DC=corp,DC=fabrikam,DC=com"; DirectoryEntry myDirectoryEntry=new DirectoryEntry(myADSPath,UserName,SecurelyStoredPassword); Console.WriteLine("Parent is :"+myDirectoryEntry.Parent.Path);
Example Code [Managed C++]
The following example searches a given DirectoryEntry and displays the Name and Parent of the result.
String* myADSPath = S"LDAP://onecity/CN=user,CN=Users,DC=onecity,DC=corp,DC=fabrikam,DC=com"; DirectoryEntry* myDirectoryEntry = new DirectoryEntry(myADSPath, UserName, SecurelyStoredPassword); Console::WriteLine(S"Parent is :{0}", myDirectoryEntry->Parent->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. |