DirectoryEntry 建構函式

定義

初始化 DirectoryEntry 類別的新執行個體。

多載

DirectoryEntry()

初始化 DirectoryEntry 類別的新執行個體。

DirectoryEntry(Object)

初始化 DirectoryEntry 類別的新執行個體,這個執行個體繫結至指定的原生 Active Directory 網域服務物件。

DirectoryEntry(String)

初始化 DirectoryEntry 類別的新執行個體,這個執行個體繫結程序至位在指定路徑之 Active Directory 網域服務中的節點。

DirectoryEntry(String, String, String)

初始化 DirectoryEntry 類別的新執行個體。

DirectoryEntry(String, String, String, AuthenticationTypes)

初始化 DirectoryEntry 類別的新執行個體。

DirectoryEntry()

初始化 DirectoryEntry 類別的新執行個體。

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

適用於

DirectoryEntry(Object)

初始化 DirectoryEntry 類別的新執行個體,這個執行個體繫結至指定的原生 Active Directory 網域服務物件。

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 網域服務物件的名稱。

備註

此建構函式可讓程式在透過原生 API 實作 IADs 介面的 DirectoryEntry 原生Active Directory 網域服務物件上使用 類別的方法和屬性。 如需 IADs 介面的詳細資訊,請參閱 IAD 一 文。

適用於

DirectoryEntry(String)

初始化 DirectoryEntry 類別的新執行個體,這個執行個體繫結程序至位在指定路徑之 Active Directory 網域服務中的節點。

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

參數

path
String

要將 DirectoryEntry(String) 繫結至目錄的路徑。 Path 屬性 (Property) 會初始化為這個值。

範例

下列範例會將 DirectoryEntry 物件系結至位於指定路徑的目錄專案,並顯示 Path 節點 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  
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 類別的新執行個體。

public:
 DirectoryEntry(System::String ^ path, System::String ^ username, System::String ^ password);
public DirectoryEntry (string path, string username, 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 的路徑。 Path 屬性 (Property) 會初始化為這個值。

username
String

驗證用戶端時所要使用的使用者名稱。 Username 屬性 (Property) 會初始化為這個值。

password
String

驗證用戶端時所要使用的密碼。 Password 屬性 (Property) 會初始化為這個值。

適用於

DirectoryEntry(String, String, String, AuthenticationTypes)

初始化 DirectoryEntry 類別的新執行個體。

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);
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 的路徑。 Path 屬性 (Property) 會初始化為這個值。

username
String

驗證用戶端時所要使用的使用者名稱。 Username 屬性 (Property) 會初始化為這個值。

password
String

驗證用戶端時所要使用的密碼。 Password 屬性 (Property) 會初始化為這個值。

authenticationType
AuthenticationTypes

其中一個 AuthenticationTypes 值。 AuthenticationType 屬性 (Property) 會初始化為這個值。

另請參閱

適用於