Skip to content

Commit

Permalink
add disabling account function (#44)
Browse files Browse the repository at this point in the history
  • Loading branch information
David Coutadeur committed Oct 16, 2024
1 parent f93e12e commit 0fc6bf9
Showing 1 changed file with 17 additions and 2 deletions.
19 changes: 17 additions & 2 deletions src/Ltb/Directory/OpenLDAP.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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 {
Expand Down

0 comments on commit 0fc6bf9

Please sign in to comment.