DirectoryEntry.DirectoryEntry (String)
The DirectoryEntry constructor initializes a new instance of the DirectoryEntry class that binds this instance to the node in Active Directory located at the specified path.
public DirectoryEntry(
String path
);
Public Sub New( _
ByVal path As String _
)
Parameters
- path
The path at which to bind the DirectoryEntry to the directory. The Path property is initialized to this value.
Security
Full trust for the immediate caller. This member cannot be used by partially trusted code. For more information, see Using Libraries From Partially Trusted Code.
Example Code [Visual Basic .NET]
The following example binds a DirectoryEntry to the directory entry at the specified path, and displays the Path of the node's Children.
Public Class PrintChildren 'Entry point which delegates to C-style main Private Function. Public Overloads Shared Sub Main() Main(System.Environment.GetCommandLineArgs()) End Sub Overloads Public Shared Sub Main(args() As String) Dim objDE As DirectoryEntry Dim strPath As String = "LDAP://DC=onecity,DC=corp,DC=fabrikam,DC=com" If args.Length > 0 Then strPath = args(1) End If ' Create a new DirectoryEntry with the given path. objDE = New DirectoryEntry(strPath) Dim objChildDE As DirectoryEntry For Each objChildDE In objDE.Children Console.WriteLine(objChildDE.Path) Next objChildDE End Sub 'Main End Class 'PrintChildren
Example Code [C#]
The following example binds a DirectoryEntry to the directory entry at the specified path, and displays the Path of the node's Children.
public class PrintChildren{ public static void Main(String[] args) { DirectoryEntry objDE; String strPath="LDAP://DC=onecity,DC=corp,DC=fabrikam,DC=com"; if(args.Length>0)strPath=args[1]; // Create a new DirectoryEntry with the given path. objDE=new DirectoryEntry(strPath); foreach(DirectoryEntry objChildDE in objDE.Children) Console.WriteLine(objChildDE.Path); } }
Example Code [Managed C++]
The following example binds a DirectoryEntry to the directory entry at the specified path, and displays the Path of the node's Children.
int main() { String* args[] = Environment::GetCommandLineArgs(); DirectoryEntry* objDE; String* strPath=S"LDAP://DC=onecity,DC=corp,DC=fabrikam,DC=com"; if(args->Length>1)strPath=args[1]; // Create a new DirectoryEntry with the given path. objDE=new DirectoryEntry(strPath); System::Collections::IEnumerator* enum0 = objDE->Children->GetEnumerator(); while (enum0->MoveNext()) { DirectoryEntry* objChildDE = __try_cast<DirectoryEntry*>(enum0->Current); Console::WriteLine(objChildDE->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. |
See Also
DirectoryEntry, DirectoryEntry Constructors, System.DirectoryServices Namespace, Managed Extensions for C++ Programming