title: Active Directory LDAP password change via C# ASP.NET: Cannot read configuration
body: <p>We're attempting to change user passwords in Active Directory (we'll use "Jane" as an example user), via a C# ASP.NET 4.5 app, though we're receiving the error below.</p>
  
  <p><code>Configuration information could not be read from the domain controller, either because the machine is unavailable, or access has been denied. (Exception from HRESULT: 0x80070547)</code></p>
  
  <p>A connection to the remote (3rd party) AD server can be established without issue and our service user is authenticated.  Jane's directory entry can also be retrieved without issue.</p>
  
  <p>We've attempted a password change/set whilst authenticated as both Jane and our service user, both yield the same error (above).</p>
  
  <p>Below is an example of the code in use.</p>
  
  <pre><code>using (var context = new PrincipalContext(ContextType.Domain, ServiceDomain, ServiceDefaultLocation, ContextOptions.Negotiate, ServiceUser, ServicePassword))
  using (var identity = UserPrincipal.FindByIdentity(context, IdentityType.SamAccountName, "Jane"))
  {
      // identity.SetPassword("SomeNewPassword"); // also tried
      identity.ChangePassword("TheOldPassword", "SomeNewPassword"); // this is the error line
      identity.Save();
  }
  </code></pre>
  
  <p>The system event log indicates an Audit Failure on the change/set password, with the reason listed as "An Error occured during logon.".  The Authentication Package lists "MICROSOFT_AUTHENTICATION_PACKAGE_V1_0".
  Prior to this, we have an Audit Success event against our service user.</p>
  
  <p>It's worth noting that it's approx. 20 seconds before we receive the error, indicating that it may be a connection/timeout issue, however outgoing connections are unrestricted and our IP has been whitelisted on the remote end (again, we can connect and retrieve the user entry).
  It can also take this long for authenticating as a user too though (which still works successfully).</p>
  
  <p>Our service user has permissions set to change/set other users' passwords, though not to directly alter user attributes, so we've been advised.</p>
  
  <p>If there is any other info that may help diagnose the issue, please let me know.</p>