我發現了大約從Active Directory獲取用戶的一篇文章從here連接到Active Directory的使用C#
所以可能我的代碼會喜歡這個
String strPath = "format of this path";
DirectoryEntry entry = null;
entry = new DirectoryEntry(strPath);
DirectorySearcher mySearcher = new DirectorySearcher(entry);
mySearcher.Filter = ("ObjectCategory=user");
foreach (SearchResult result in mySearcher.FindAll())
{
String strName = result.GetDirectoryEntry().Name;
//Do whatever
}
能否請您在此解釋一下strPath中檢索用戶的詳細信息??這是什麼格式?
注意:我知道我的服務器信息可以使用我的本地ip「198.168.1.182」進行測試。
我不確定我的想法是否正確。
請幫忙!!!
回答marc_s是不完整的。 FindyByIntenty方法至少需要兩個參數。主要上下文對象「ctx」需要作爲第一個參數。 – user55513 2012-08-01 13:31:24
@jdmorris:謝謝,你完全正確 - 更正了我的回答 – 2012-08-01 20:42:30
非常感謝。我整天都在尋找解決方案。這使得它非常簡單易用。 – Ahmad 2013-01-20 10:11:11