Skip to content

Commit

Permalink
Start Directory interface
Browse files Browse the repository at this point in the history
  • Loading branch information
coudot committed Jul 16, 2024
1 parent 0ca06f8 commit 25949ae
Show file tree
Hide file tree
Showing 3 changed files with 58 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/Ltb/Directory.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?php

namespace Ltb;

interface Directory
{
public function isLocked($entry, $ppolicy);
}
17 changes: 17 additions & 0 deletions src/Ltb/Directory/ActiveDirectory.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?php

namespace Ltb\Directory;

class ActiveDirectory implements Directory
{
public function isLocked($entry, $ppolicy) {

$isLocked = false;

$userAccountControl = $entry[0]['useraccountcontrol'][0];

if ($userAccountControl & 2) { $isLocked = true; }

return $isLocked;
}
}
33 changes: 33 additions & 0 deletions src/Ltb/Directory/OpenLDAP.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<?php

namespace Ltb\Directory;

class OpenLDAP implements Directory
{
public function isLocked($entry, $ppolicy) {

$ppolicy_entry = $policy;
$isLocked = false;

$pwdLockout = strtolower($ppolicy_entry[0]['pwdlockout'][0]) == "true" ? true : false;
$pwdLockoutDuration = $ppolicy_entry[0]['pwdlockoutduration'][0];
$pwdAccountLockedTime = $entry[0]['pwdaccountlockedtime'][0];

if ( $pwdAccountLockedTime === "000001010000Z" ) {
$isLocked = true;
} else if (isset($pwdAccountLockedTime)) {
if (isset($pwdLockoutDuration) and ($pwdLockoutDuration > 0)) {
// $lockDate = ldapDate2phpDate($pwdAccountLockedTime);
$lockdate = time() // TODO add Date functions in LTB-LDAP
$unlockDate = date_add( $lockDate, new DateInterval('PT'.$pwdLockoutDuration.'S'));
if ( time() <= $unlockDate->getTimestamp() ) {
$isLocked = true;
}
} else {
$isLocked = true;
}
}

return $isLocked;
}
}

0 comments on commit 25949ae

Please sign in to comment.