Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/Ltb/Directory/OpenLDAP.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@ public function isLocked($entry, $pwdPolicyConfiguration) : bool {

$unlockDate = $this->getUnlockDate($entry, $pwdPolicyConfiguration);

if (!$unlockDate) {
return true;
}

if ( $unlockDate and time() <= $unlockDate->getTimestamp() ) {
return true;
}
Expand Down
26 changes: 26 additions & 0 deletions tests/Ltb/DirectoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,32 @@ public function test_openldap_islocked_no_more_locked(): void
$this->assertFalse($isLocked, "Account should no more be locked");
}

public function test_openldap_islocked_lockout_duration_zero(): void
{
$entry = [
'pwdaccountlockedtime' => [
'count' => 1,
0 => (new DateTime)->modify("-10 days")->format("Ymdhis\Z")
]
];

$isLocked = (new Ltb\Directory\OpenLDAP)->isLocked($entry, array('lockout_duration' => 0));
$this->assertTrue($isLocked, "Account should be locked");
}

public function test_openldap_islocked_no_lockout_duration(): void
{
$entry = [
'pwdaccountlockedtime' => [
'count' => 1,
0 => (new DateTime)->modify("-10 days")->format("Ymdhis\Z")
]
];

$isLocked = (new Ltb\Directory\OpenLDAP)->isLocked($entry, array('lockout_duration' => null));
$this->assertTrue($isLocked, "Account should be locked");
}

public function test_openldap_getlockdate_empty(): void
{
$entry = [
Expand Down