在Windows 2000高级服务器上有Active Directory,在Windows 2008企业版服务器上有一个Web服务器,以下代码在Windows 2003服务器上运行良好,但当我安装Win 2008服务器时,它给我以下错误,Web服务器不是AD服务器的子域,但它们具有相同的IP地址范围。
“出现本地错误。 System.DirectoryServices.DirectoryServicesCOMException”
我想通过AD从我的Web服务器进行身份验证,我甚至测试了端口389,并且它是开放的(通过telnet),我甚至将端口389 UDP和TCP添加到Web服务器的防火墙中以确保它是开放的,甚至关闭了防火墙,但仍然无法运行我的代码。我不知道Windows 2008服务器出了什么问题,找遍互联网也没有找到解决方案。任何解决方案都会有所帮助。谢谢。
“出现本地错误。 System.DirectoryServices.DirectoryServicesCOMException”
我想通过AD从我的Web服务器进行身份验证,我甚至测试了端口389,并且它是开放的(通过telnet),我甚至将端口389 UDP和TCP添加到Web服务器的防火墙中以确保它是开放的,甚至关闭了防火墙,但仍然无法运行我的代码。我不知道Windows 2008服务器出了什么问题,找遍互联网也没有找到解决方案。任何解决方案都会有所帮助。谢谢。
public bool IsAuthenticated(string username, string pwd,string group)
{
string domainAndUsername = "LDAP://192.xx.xx.xx:389/DC=test,DC=oc,DC=com" ;
string usr="CN=" + username + ",CN=" + group;
DirectoryEntry entry = new DirectoryEntry(domainAndUsername, usr, pwd,
AuthenticationTypes.Secure );
try
{
DirectorySearcher search = new DirectorySearcher(entry);
search.Filter = "(SAMAccountName=" + username + ")";
SearchResult result = search.FindOne();
if (result == null)
{
return false;
}
}
catch (Exception ex)
{
return false;
}
return true;
}