PHP : How to lock an active directory user account?
active-directory, php
Solution
LDAP bind attempts don't count as logon attempts. Using APIs like LogonUser and CreateProcessWithLogon generate logon attempts.
Problem
i've a working script that allow me to unlock a user account (by setting lockouttime AD attribute to 0) something like this : ``` $entry["lockouttime"][0]=0; $mod=ldap_mod_replace($ds,$dn,$entry) ``` Now I'd like to do the opposite : lock the account. I've read that lockouttime is a system attribute and active directory will not allow us to set its value to something else that 0. So i'm trying to bind to the server with the user account and a bad password, but this doesn't seem to work. ``` for($i=0;$i<10;$i++){ ldap_bind($ds,$dn, "theWrongPasswd"); } ``` running this will show this error ``` Warning: ldap_bind(): Unable to bind to server: Invalid credentials ``` but the account is still unlock. Do you have any idea on how can i do this? Thanks in advance.