DirectoryEntry 建構函式
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
初始化 DirectoryEntry 類別的新執行個體。
多載
| 名稱 | Description |
|---|---|
| DirectoryEntry() |
初始化 DirectoryEntry 類別的新執行個體。 |
| DirectoryEntry(Object) |
初始化一個新的類別實例 DirectoryEntry ,綁定到指定的原生 Active Directory Domain Services 物件。 |
| 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 Domain Services 物件。
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 網域服務物件名稱。
備註
此建構子使程式能在原生 Active Directory Domain Services 物件上使用該類別的方法 DirectoryEntry 與屬性,該物件透過原生 API 實作 IADs 介面。 欲了解更多關於 IADs 介面的資訊,請參閱 IADs 條目。
適用於
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該屬性初始化為此值。
範例
以下範例將物件 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);
}
}
適用於
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該屬性初始化為此值。
適用於
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該屬性初始化為此值。
- authenticationType
- AuthenticationTypes
這是其中一項 AuthenticationTypes 價值。 AuthenticationType該屬性初始化為此值。