title: Connect to LDAP over ssl from remote machine using "DirectoryEntry" API
body: <p>I need to connect to LDAP over SSL from <strong>a remote machine</strong>; There are many discussions for this, but the solutions posted in them do work only in the same Windows Server domain machine; The same code fails to connect successfully from a remote machine;</p>
  
  <p>Code I tried:</p>
  
  <pre><code>DirectoryEntry entry = new DirectoryEntry("LDAP://fqdn:636/DC=aa,DC=bb", "username", "password");
  DirectorySearcher searcher = new DirectorySearcher();
  searcher.SearchRoot = entry;
  searcher.SearchScope = SearchScope.Subtree;
  searcher.Filter = "(&amp;(objectCategory=person)(objectClass=user))";
  SearchResultCollection results = searcher.FindAll();
  </code></pre>
  
  <p>To say again, I am able to get results from same WindowsServer domain machine; But I get exception <strong>"Server is not operational"</strong> when I try the same code from remote machine;</p>
  
  <p>I found that its due to certificate validation failure i.e. Windows Server's certificate is not validated in remote machine; But I don't know how to override certificate validation for 'DirectoryEntry object';  </p>
  
  <ul>
  <li><p>This <a href="https://stackoverflow.com/questions/12621256/connect-to-open-ldap-over-ssl">post</a> has solution for Certificate issue; But its for 'LdapConnection'</p></li>
  <li><p>But I need the solution for <strong>DirectoryEntry</strong> API;</p></li>
  </ul>
  
  <p>Just for an info; This <a href="https://stackoverflow.com/questions/28351752/certificate-unknown-on-client-while-connecting-to-ldap-over-ssl">post</a> has the same question raised for Java with no answers; My requirement is for <strong>C#</strong></p>