![](/img/trans.png)
[英]How to list users in all domains running code from a non-domain computer?
[英]How to list domains running code from a non-domain computer?
在我的應用程序中,我需要獲取Active Directory林並列出域層次結構。
為我提供了具有必要權限的Active Directory帳戶。 但是,我的開發計算機不在域中,並且不能添加到域中。
這是我用來獲取目錄林和訪問根域的代碼:
// I also tried to add a Global Catalog port: 192.168.2.11:3268, no success
DirectoryContext dc = new DirectoryContext(
DirectoryContextType.Forest, "192.168.2.11", “Login1”, “pass1”);
Forest f = Forest.GetForest(dc);
Console.WriteLine("Forest name: " + f.Name);
Console.WriteLine("Root domain: " + f.RootDomain);
如果我在不在域中的計算機上運行它,如何修改它以發現域?
即使計算機未加入域,您仍然可以將其DNS服務器設置為可以解析AD中名稱的服務器。
理想情況下,您可以使用DC使用的同一DNS服務器。
完成上述更改后,您應該能夠使用林名稱創建Forest
對象。 然后,要獲取域,只需調用Forest
的Domains
屬性。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.