title: PHP : How to lock an active directory user account?
body: <p>i've a working script that allow me to unlock a user account (by setting lockouttime AD attribute to 0)
  something like this :</p>
  
  <pre><code>$entry["lockouttime"][0]=0;
  $mod=ldap_mod_replace($ds,$dn,$entry)
  </code></pre>
  
  <p>Now I'd like to do the opposite : lock the account.
  I've read that <strong><em>lockouttime is a system attribute and active directory will not allow us to set its value to something else that 0.</em></strong></p>
  
  <p>So i'm trying to bind to the server with the user account and a bad password, but this doesn't seem to work.</p>
  
  <pre><code>for($i=0;$i&lt;10;$i++){   
      ldap_bind($ds,$dn, "theWrongPasswd");
  }
  </code></pre>
  
  <p>running this will show this error</p>
  
  <pre><code>Warning: ldap_bind(): Unable to bind to server: Invalid credentials
  </code></pre>
  
  <p>but the account is still unlock.</p>
  
  <p>Do you have any idea on how can i do this?
  Thanks in advance.</p>