title: A local error has occurred while connecting to AD in Windows 2008 server
body: <p>There's Active directory on windows 2000 advance server, I have a web server on Windows 2008 server Enterprise Edition,  the following code works fine in Winsows 2003 server but when I installed Win 2008 server, it gives me the following error, the webserver is not subdomain of the AD server. but they have the same range IP address.</p>
  
  <blockquote>
    <p>A local error has occurred.</p>
    
    <p>System.DirectoryServices.DirectoryServicesCOMException</p>
  </blockquote>
  
  <p>I want to Authenticate Via AD from my webserver, I even test the port 389 and it was open(by telnet), I even added port 389 UDP and TCP to firewall of webserver to be sure it is open, even I turned the firewall off but nothing changed. I don't know what's wrong with Windows 2008 server that cannot run my code, I search Internet but I found nothing.
  any solution would be helpful.
  Thank you</p>
  
  <pre><code>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;
  }
  </code></pre>