title: C#: How to Connect to Active Directory with SSL Enabled using DirectoryContext, Domains and DirectoryEntry classes?
body: <p>I want to search all the Domains in a Forest and i do that in the following way:</p>
  
  <pre><code>foreach(Domain currDomain in Forest.GetCurrentForest().Domains)
  {
      try
      {
          DirectorySearcher searcher = new
                           DirectorySearcher(currDomain.GetDirectoryEntry());
          searcher.PageSize = 1000;
          searcher.PropertiesToLoad.Add("cn");
          searcher.PropertiesToLoad.Add("distinguishedName");
          searcher.Filter = "(&amp;(objectClass=group))";
          using (SearchResultCollection resList = searcher.FindAll())
          {
          }
      }
  }
  </code></pre>
  
  <p>Now i want to do the same with SSL Enabled. To do that i tried to set the</p>
  
  <pre><code>AuthenticationType 
  </code></pre>
  
  <p>property in <strong>DirectoryEntry</strong> class to</p>
  
  <pre><code>AuthenticationTypes.SecureSocketsLayer.
  </code></pre>
  
  <p>But, when i try  to execute, "An Operation Error Occured" exception is thrown.</p>
  
  <p>Can someone please help me with this?</p>