Skip to content

Commit

Permalink
first attempt of OpenLDAP check for disabled account (#44)
Browse files Browse the repository at this point in the history
  • Loading branch information
David Coutadeur committed Oct 16, 2024
1 parent e049a6e commit 8f8ad29
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 @@ -231,8 +231,23 @@ public function disableAccount($ldap, $dn) : bool {
}

public function isAccountEnabled($ldap, $dn) : bool {
// Not implemented
return true;

# Get entry
$search = \Ltb\PhpLDAP::ldap_read($ldap, $dn, "(objectClass=*)", array('pwdAccountDisabled'));
$errno = \Ltb\PhpLDAP::ldap_errno($ldap);

if ( $errno ) {
error_log("LDAP - Search error $errno (".ldap_error($ldap).")");
return false;
} else {
$entry = \Ltb\PhpLDAP::ldap_get_entries($ldap, $search);
}

if (empty($entry[0]['pwdAccountDisabled'])) {
return true;
} else {
return false;
}
}

public function getLdapDate($date) : string {
Expand Down

0 comments on commit 8f8ad29

Please sign in to comment.