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 @@ -22,6 +22,10 @@ public function getOperationalAttributes() : array {

public function isLocked($entry, $pwdPolicyConfiguration) : bool {

if (!$pwdPolicyConfiguration['lockout_enabled']) {
return false;
}

# Get pwdAccountLockedTime
$pwdAccountLockedTime = $entry['pwdaccountlockedtime'][0] ?? null;

Expand Down
25 changes: 19 additions & 6 deletions tests/Ltb/DirectoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public function test_openldap_islocked_locked_forever(): void
]
];

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

Expand All @@ -28,7 +28,7 @@ public function test_openldap_islocked_not_locked(): void
]
];

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

Expand All @@ -41,7 +41,7 @@ public function test_openldap_islocked_still_locked(): void
]
];

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

Expand All @@ -54,7 +54,7 @@ public function test_openldap_islocked_no_more_locked(): void
]
];

$isLocked = (new Ltb\Directory\OpenLDAP)->isLocked($entry, array('lockout_duration' => 86400));
$isLocked = (new Ltb\Directory\OpenLDAP)->isLocked($entry, array('lockout_duration' => 86400, 'lockout_enabled' => true));
$this->assertFalse($isLocked, "Account should no more be locked");
}

Expand All @@ -67,7 +67,7 @@ public function test_openldap_islocked_lockout_duration_zero(): void
]
];

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

Expand All @@ -80,10 +80,23 @@ public function test_openldap_islocked_no_lockout_duration(): void
]
];

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

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

$isLocked = (new Ltb\Directory\OpenLDAP)->isLocked($entry, array('lockout_duration' => 86400, 'lockout_enabled' => false));
$this->assertFalse($isLocked, "Account should not be locked");
}

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