C# LDAP DirectoryEntry无法通过主机名连接,但只能通过IP地址连接

C# LDAP DirectoryEntry无法通过主机名连接,但只能通过IP地址连接,c#,asp.net,tcp,active-directory,ldap,C#,Asp.net,Tcp,Active Directory,Ldap,当我试图通过写以下行连接到计算机网络中的广告时: DirectoryEntry de = new DirectoryEntry("LDAP://hostname.local"); 我得到以下错误: 登录失败:未知用户名或错误密码 但是,当我尝试使用IP连接到同一台计算机时,我能够毫无错误地连接到该计算机,即以下线路确实有效: DirectoryEntry de = new DirectoryEntry("LDAP://The IP of hostname.local"); 当我尝试使用带有主

当我试图通过写以下行连接到计算机网络中的广告时:

DirectoryEntry de = new DirectoryEntry("LDAP://hostname.local");
我得到以下错误:

登录失败:未知用户名或错误密码

但是,当我尝试使用IP连接到同一台计算机时,我能够毫无错误地连接到该计算机,即以下线路确实有效:

DirectoryEntry de = new DirectoryEntry("LDAP://The IP of hostname.local");

当我尝试使用带有主机名的ldap查询时,登录失败,但当我使用主机名ip地址时,我成功到达计算机并能够查看其广告内容,这怎么可能呢。

首先是一个愚蠢的问题。当您ping hostname.local时,是否在上面hostname.local的IP中获得相同的IP?是。这就是我第一次发现IP的原因。第二个问题是,hostname.local真的是主机名还是域名?如果是域名,则可能是DNS中的SRV记录有问题,因此无法从域名解析DC。它是域控制器,因此是域名,而不是主机名。请您详细说明一下这些SRV记录,并解释为什么有时从域名解析DC成功,有时则失败?在Windows 2k+中,域定位器遵循本文:如果未找到任何记录,则使用NT4定位器服务:-jim