有Windows 2000高級服務器上的Active Directory,我在Windows 2008服務器企業版上有一個Web服務器,下面的代碼在Winsows 2003服務器上工作正常,但是當我安裝Win 2008服務器,它給我以下錯誤,Web服務器不是AD服務器的子域。但它們具有相同的範圍IP地址。在Windows 2008服務器上連接到AD時出現本地錯誤
發生了本地錯誤。
System.DirectoryServices.DirectoryServicesCOMException
我想從我的網絡服務器進行身份驗證通過AD,我甚至測試端口389,它是開放的(通過telnet),我甚至增加389端口UDP和TCP防火牆的網絡服務器,以確保它是開放的,即使我關閉防火牆,但沒有任何改變。我不知道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;
}
非常感謝你,它對我來說工作正常 – Sara 2009-10-13 05:13:03