DirectoryEntry 构造函数

定义

初始化 DirectoryEntry 类的新实例。Initializes a new instance of the DirectoryEntry class.

重载

DirectoryEntry()

初始化 DirectoryEntry 类的新实例。Initializes a new instance of the DirectoryEntry class.

DirectoryEntry(Object)

初始化 DirectoryEntry 类的新实例,该类可绑定到指定的本机 Active Directory 域服务对象。Initializes a new instance of the DirectoryEntry class that binds to the specified native Active Directory Domain Services object.

DirectoryEntry(String)

初始化 DirectoryEntry 类的新实例,该类将此实例绑定到位于指定路径的 Active Directory 域服务中的节点。Initializes a new instance of the DirectoryEntry class that binds this instance to the node in Active Directory Domain Services located at the specified path.

DirectoryEntry(String, String, String)

初始化 DirectoryEntry 类的新实例。Initializes a new instance of the DirectoryEntry class.

DirectoryEntry(String, String, String, AuthenticationTypes)

初始化 DirectoryEntry 类的新实例。Initializes a new instance of the DirectoryEntry class.

DirectoryEntry()

初始化 DirectoryEntry 类的新实例。Initializes a new instance of the DirectoryEntry class.

public:
 DirectoryEntry();
public DirectoryEntry ();
Public Sub New ()

适用于

DirectoryEntry(Object)

初始化 DirectoryEntry 类的新实例,该类可绑定到指定的本机 Active Directory 域服务对象。Initializes a new instance of the DirectoryEntry class that binds to the specified native Active Directory Domain Services object.

public:
 DirectoryEntry(System::Object ^ adsObject);
public DirectoryEntry (object adsObject);
new System.DirectoryServices.DirectoryEntry : obj -> System.DirectoryServices.DirectoryEntry
Public Sub New (adsObject As Object)

参数

adsObject
Object

要绑定到的本机 Active Directory 域服务对象的名称。The name of the native Active Directory Domain Services object to bind to.

注解

此构造函数使程序可以 DirectoryEntry 通过本机 API 使用实现 IADs 接口的本机 Active Directory 域服务对象上的类的方法和属性。This constructor enables a program to use the methods and properties of the DirectoryEntry class on a native Active Directory Domain Services object that implements the IADs interface through a native API. 有关 IADs 接口的详细信息,请参阅 IADs 一文。For more information about the IADs interface, see the IADs article.

适用于

DirectoryEntry(String)

初始化 DirectoryEntry 类的新实例,该类将此实例绑定到位于指定路径的 Active Directory 域服务中的节点。Initializes a new instance of the DirectoryEntry class that binds this instance to the node in Active Directory Domain Services located at the specified path.

public:
 DirectoryEntry(System::String ^ path);
public DirectoryEntry (string path);
new System.DirectoryServices.DirectoryEntry : string -> System.DirectoryServices.DirectoryEntry
Public Sub New (path As String)

参数

path
String

一个路径,在此处将 DirectoryEntry(String) 绑定到目录。The path at which to bind the DirectoryEntry(String) to the directory. Path 属性初始化为该值。The Path property is initialized to this value.

示例

下面的示例将一个 DirectoryEntry 对象绑定到指定路径处的目录项,并显示 Path 由节点的属性指定的每个子项的属性 ChildrenThe following example binds a DirectoryEntry object to the directory entry at the specified path, and displays the Path property of each child entry that is specified by the node's Children property.

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  
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);  
   }  
 }  
int main()  
{  
    String^ args[] = Environment::GetCommandLineArgs();  
    DirectoryEntry^ objDE;  
    String^ strPath = "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 = gcnew DirectoryEntry(strPath);  

    System::Collections::IEnumerator^ enum0 = objDE->Children->GetEnumerator();  
    while (enum0->MoveNext())  
    {  
        DirectoryEntry^ objChildDE = safe_cast<DirectoryEntry^>(enum0->Current);  
        Console::WriteLine(objChildDE->Path);  
    }  
}  

适用于

DirectoryEntry(String, String, String)

初始化 DirectoryEntry 类的新实例。Initializes a new instance of the DirectoryEntry class.

public:
 DirectoryEntry(System::String ^ path, System::String ^ username, System::String ^ password);
public DirectoryEntry (string path, string username, string password);
new System.DirectoryServices.DirectoryEntry : string * string * string -> System.DirectoryServices.DirectoryEntry
Public Sub New (path As String, username As String, password As String)

参数

path
String

DirectoryEntry 的路径。The path of this DirectoryEntry. Path 属性初始化为该值。The Path property is initialized to this value.

username
String

在对客户端进行身份验证时要使用的用户名。The user name to use when authenticating the client. Username 属性初始化为该值。The Username property is initialized to this value.

password
String

在对客户端进行身份验证时使用的密码。The password to use when authenticating the client. Password 属性初始化为该值。The Password property is initialized to this value.

适用于

DirectoryEntry(String, String, String, AuthenticationTypes)

初始化 DirectoryEntry 类的新实例。Initializes a new instance of the DirectoryEntry class.

public:
 DirectoryEntry(System::String ^ path, System::String ^ username, System::String ^ password, System::DirectoryServices::AuthenticationTypes authenticationType);
public DirectoryEntry (string path, string username, string password, System.DirectoryServices.AuthenticationTypes authenticationType);
new System.DirectoryServices.DirectoryEntry : string * string * string * System.DirectoryServices.AuthenticationTypes -> System.DirectoryServices.DirectoryEntry
Public Sub New (path As String, username As String, password As String, authenticationType As AuthenticationTypes)

参数

path
String

DirectoryEntry 的路径。The path of this DirectoryEntry. Path 属性初始化为该值。The Path property is initialized to this value.

username
String

在对客户端进行身份验证时要使用的用户名。The user name to use when authenticating the client. Username 属性初始化为该值。The Username property is initialized to this value.

password
String

在对客户端进行身份验证时使用的密码。The password to use when authenticating the client. Password 属性初始化为该值。The Password property is initialized to this value.

authenticationType
AuthenticationTypes

AuthenticationTypes 值之一。One of the AuthenticationTypes values. AuthenticationType 属性初始化为该值。The AuthenticationType property is initialized to this value.

另请参阅

适用于