我創建的以下方法似乎不起作用。在foreach循環中總是發生錯誤。列出所有使用目錄服務的本地用戶
NotSupportedException was unhandled ...提供程序不支持 搜索,無法搜索WinNT:// WIN7,計算機。
我查詢本地機器
private static void listUser(string computer)
{
using (DirectoryEntry d= new DirectoryEntry("WinNT://" +
Environment.MachineName + ",computer"))
{
DirectorySearcher ds = new DirectorySearcher(d);
ds.Filter = ("objectClass=user");
foreach (SearchResult s in ds.FindAll())
{
//display name of each user
}
}
}
你會得到什麼錯誤? – row1
NotSupportedException未處理..............提供程序不支持搜索,無法搜索WinNT:// WIN7,計算機。 – ikel
感謝清理我的問題 – ikel