如何列出域从非域计算机上运行code? [英] How to list domains running code from a non-domain computer?

查看:139
本文介绍了如何列出域从非域计算机上运行code?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的应用程序需要得到Active Directory林和列表中的域层次结构。

In my application I need to get Active Directory forest and list the domains hierarchy.

我是因为有必要权限的Active Directory帐户。但是我的开发计算机不是在域和不能被添加到域。

I was given the Active Directory account that has necessary permissions. However my development computer is NOT on the domain and can not be added to the domain.

下面是我使用获得森林和访问根域code:

Here is the code that I am using to get the forest and access the root domain:

 // 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);

如何修改它来发现的情况下域我的计算机是不是在域上运行它?

How do I modify it to discover domains in case I run it on a computer that is not on a domain?

推荐答案

即使计算机未加入到域,您仍然可以设置它的DNS服务器到一个可以在AD解析名称。

Even the computer is not joined to domain, you can still set its DNS server to one that can resolve the names in AD.

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

Ideally you can use the same DNS server that is used by the DC.

上述变更后,你应该能够创建森林同林的名字对象。然后,为了获取域,只需拨打森林

After the above change, you should be able to create the Forest object with the forest name. Then, to get the domains, simply call the Domains property of Forest.

这篇关于如何列出域从非域计算机上运行code?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆