title: C# Active Directory - Incorrect Username and Password but details are actually correct
body: <p>Issue with Active Directory &amp; C#. I'm getting an intermittent error stating that "The user name or password is incorrect.". However, I know the login details are correct as it works Locally in VS. It seemingly doesn't on the web server everytime. </p>
  
  <p><strong>Error:</strong></p>
  
  <pre><code>The user name or password is incorrect.
  Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
  
  Exception Details: System.DirectoryServices.DirectoryServicesCOMException: The user name or password is incorrect.
  </code></pre>
  
  <p>My code for storing the connection to the LDAP, bits hidden for security reasons:</p>
  
  <pre><code>    public static DirectoryEntry GetDirectoryEntryWithGc()
      {
          var de = new DirectoryEntry("GC://dc=TEXT,dc=TEXT,dc=TEXT");
          de.AuthenticationType = AuthenticationTypes.Secure;
          de.Username = "USERNAME";
          de.Password = "PASSWORD";
          return de;
      }
  </code></pre>
  
  <p>As mentioned, works Locally and is intermittent. Anyone any experience of this?</p>