diff --git a/src/Ltb/Directory/OpenLDAP.php b/src/Ltb/Directory/OpenLDAP.php index 64d3dbe..ae5f64d 100644 --- a/src/Ltb/Directory/OpenLDAP.php +++ b/src/Ltb/Directory/OpenLDAP.php @@ -226,7 +226,7 @@ public function enableAccount($ldap, $dn) : bool { $update = \Ltb\PhpLDAP::ldap_mod_replace($ldap, $dn, $attrsToDelete); $errno = \Ltb\PhpLDAP::ldap_errno($ldap); - + if ($errno) { error_log("LDAP - Enabling account error $errno (".\Ltb\PhpLDAP::ldap_error($ldap).")"); return false; @@ -237,8 +237,23 @@ public function enableAccount($ldap, $dn) : bool { } public function disableAccount($ldap, $dn) : bool { - // Not implemented + + # Date of disabling + $currentDate = gmdate("YmdHis")."Z"; + + $attrs = array( 'pwdAccountDisabled' => array($currentDate) ); + + $update = \Ltb\PhpLDAP::ldap_mod_replace($ldap, $dn, $attrs); + $errno = \Ltb\PhpLDAP::ldap_errno($ldap); + + if ($errno) { + error_log("LDAP - Disabling account error $errno (".\Ltb\PhpLDAP::ldap_error($ldap).")"); + return false; + } else { + return true; + } return false; + } public function isAccountEnabled($ldap, $dn) : bool {