【问题标题】:How to list domains running code from a non-domain computer?如何列出从非域计算机运行代码的域?
【发布时间】:2015-01-12 18:29:08
【问题描述】:

在我的应用程序中,我需要获取 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);

如果我在不在域中的计算机上运行它,如何修改它以发现域?

【问题讨论】:

    标签: c# authentication active-directory windows-authentication directoryservices


    【解决方案1】:

    即使计算机未加入域,您仍然可以将其 DNS 服务器设置为可以解析 AD 中的名称的服务器。

    理想情况下,您可以使用与 DC 相同的 DNS 服务器。

    进行上述更改后,您应该可以使用林名称创建Forest 对象。然后,要获取域,只需调用ForestDomains 属性。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2019-02-15
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-09-09
      相关资源
      最近更新 更多