如何以编程方式找出哪台计算机是 Windows 中的域控制器?

问题描述:

我正在寻找一种方法来确定客户端计算机连接到的给定域的域控制器的名称/IP 地址.

I am looking for a way to determine what the Name/IP Address of the domain controller is for a given domain that a client computer is connected to.

在我们公司,我们有很多用于测试的小型网络,其中大多数都有自己的小域.例如,域之一被命名为TESTLAB".我有一个 Windows XP 工作站,它是 TESTLAB 域的成员,我正在尝试找出域控制器的名称,以便我可以查看为该域定义了哪些用户.在我们的实验室中,混合使用了 Windows Server 2000 和 Windows Server 2003(实际上可能是几个 NT 4 服务器),因此最好能找到一种适用于两者的解决方案.

At our company we have a lot of small little networks that we use for testing and most of them have their own little domains. As an example, one of the domains is named "TESTLAB". I have an Windows XP workstation that is a member of the TESTLAB domain and I am trying to figure out the name of the domain controller so that I can go and look to see what users have been defined for the domain. In our lab there is a mix of Windows Server 2000 and Windows Server 2003 (and in reality probably a couple of NT 4 Servers) so it would be nice to find a solution that would work for both.

在网上看,好像有各种实用程序,比如Windows Power Shell或者nltest,但是这些都需要你下载安装其他实用程序.我希望找到一种无需安装任何其他东西即可找到域控制器的方法.

Looking on the Internet, it looks like there are various utilities, such as Windows Power Shell or nltest, but these all require that you download and install other utilities. I was hoping to find a way to find the domain controller without having to install anything additional.

编辑如果我想编写一个程序来查找域控制器或当前域中的用户,我该怎么做?

EDIT If I wanted to write a program to find the domain controller or the users in the current domain, how would I go about doing that?

用最简单的编程语言:DOS批处理

With the most simple programming language: DOS batch

echo %LOGONSERVER%