c# - 如何获取域 Controller IP地址

标签 c# networking active-directory network-programming

如何使用 C# 以编程方式获取域 Controller IP 地址?

最佳答案

下面是我的做法。

您需要使用 System.Net 和 System.DirectoryServices。

// get root of the directory data tree on a directory server
DirectoryEntry dirEntry = new DirectoryEntry("LDAP://rootDSE");
// get the hostname of the directory server of your root (I'm assuming that's what you want)
string dnsHostname = dirEntry.Properties["dnsHostname"].Value.ToString();
IPAddress[] ipAddresses = Dns.GetHostAddresses(dnsHostname);

关于c# - 如何获取域 Controller IP地址,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/492391/

相关文章:

amazon-s3 - S3 上托管的 Web 应用程序的 SSO

c# - 获取当前用户的直接下属列表

c# - C#获取磁盘簇大小--出现 'GetDiskFreeSpace'错误

c# - ASP.Net Core 中的模板化

C#。通过电子邮件发送 byte[] 然后检索它

用于网络测量工具的Python或C

c# - word.otherword 的正则表达式

Android Wifi配置

go - Golang中如何处理字节运算符?

c# - System.DirectoryServices.DirectoryEntry 是否包含一个实际使用 "domain\username"和 Ldap 的构造函数?