DirectoryEntry 類別支援多種目錄服務提供者,透過不同的路徑前綴(Provider Identifier)繫結至對應的目錄存儲:
| 服務提供者 | 路徑識別碼 |
|---|---|
| Windows 2000 / XP (WinNT) | WinNT://path |
| LDAP (Active Directory) | LDAP://path |
| Novell NetWare 目錄服務 | NDS://path |
| Novell NetWare 3.x | NWCOMPAT://path |
本專案針對 Windows 網域環境,採用 WinNT 提供者。建立 DirectoryEntry 實例並指定 WinNT: 路徑,即可存取網域層級的容器物件(域、電腦、印表佇列、工作階段等)。
Visual C#構建網絡計算機樹形圖E:\VS.NET項目TreeView (名為 treeView1) + Button (名為 button1,雙擊產生 Click 事件)using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
using System.Threading;
private DirectoryEntry entryPC = new DirectoryEntry("WinNT:");
完成上述準備,即可進入介面設計與核心查詢邏輯的實作階段(詳見後續章節)。