title: Why does Active Directory validate last password?
body: <p>I am working on a simple solution to update a user's password in Active Directory.</p>
  
  <p>I can successfully update the users password. Updating the password works fine. Lets say the user has updated the password from MyPass1 to <strong>MyPass2</strong></p>
  
  <p>Now when I run my custom code to validate users credential using:</p>
  
  <pre><code>using(PrincipalContext pc = new PrincipalContext(ContextType.Domain, "TheDomain"))
  {
      // validate the credentials
      bool isValid = pc.ValidateCredentials("myuser", "MyPass2");
  }
  
  //returns true - which is good
  </code></pre>
  
  <p>Now when I enter some wrong password it validates very nicely:</p>
  
  <pre><code>using(PrincipalContext pc = new PrincipalContext(ContextType.Domain, "TheDomain"))
  {
      // validate the credentials
      bool isValid = pc.ValidateCredentials("myuser", "wrongPass");
  }
  
  //returns false - which is good
  </code></pre>
  
  <p>Now for some odd reasons, it validates the previous last password which was MyPass1 remember?</p>
  
  <pre><code>using(PrincipalContext pc = new PrincipalContext(ContextType.Domain, "TheDomain"))
  {
      // validate the credentials
      bool isValid = pc.ValidateCredentials("myuser", "MyPass1");
  }
  
  //returns true - but why? we have updated password to Mypass2
  </code></pre>
  
  <p>I got this code from:</p>
  
  <p><a href="https://stackoverflow.com/questions/290548/c-sharp-validate-a-username-and-password-against-active-directory">Validate a username and password against Active Directory?</a></p>
  
  <p>Is it something to do with last password expiry or is this how the validation supposed to work?</p>