Skip to content

Commit

Permalink
Use ltb-common password expiration functions
Browse files Browse the repository at this point in the history
  • Loading branch information
coudot committed Jul 24, 2024
1 parent 6d2b636 commit e220b77
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 30 deletions.
33 changes: 4 additions & 29 deletions htdocs/display.php
Original file line number Diff line number Diff line change
Expand Up @@ -114,34 +114,9 @@
$isLocked = $directory->isLocked($ldap, $dn, array('lockoutDuration' => $lockoutDuration));
$canLockAccount = $directory->canLockAccount($ldap, $dn, array('pwdPolicy' => $pwdPolicy));

$isExpired = false;

if ($pwdPolicy) {
$search_ppolicy = ldap_read($ldap, $pwdPolicy, "(objectClass=pwdPolicy)", array('pwdMaxAge'));

$ppolicy_entry = "";
if ( $errno ) {
error_log("LDAP - PPolicy search error $errno (".ldap_error($ldap).")");
} else {
$ppolicy_entry = ldap_get_entries($ldap, $search_ppolicy);
}

# Expiration
$pwdMaxAge = $ppolicy_entry[0]['pwdmaxage'][0];
$pwdChangedTime = $entry[0]['pwdchangedtime'][0];

if (isset($pwdChangedTime) and isset($pwdMaxAge) and ($pwdMaxAge > 0)) {
$changedDate = ldapDate2phpDate($pwdChangedTime);
$expirationDate = date_add( $changedDate, new DateInterval('PT'.$pwdMaxAge.'S'));
if ( time() >= $expirationDate->getTimestamp() ) {
$isExpired = true;
}
if ( $display_password_expiration_date ) {
$ldapExpirationDate = $expirationDate->format('YmdHis\Z');
}
}
}

$pwdMaxAge = $directory->getPasswordMaxAge($ldap, $dn, array('pwdPolicy' => $pwdPolicy, 'pwdMaxAge' => $ldap_password_max_age));
$expirationDate = $directory->getPasswordExpirationDate($ldap, $dn, array('pwdMaxAge' => $pwdMaxAge));
$isExpired = $directory->isPasswordExpired($ldap, $dn, array('pwdMaxAge' => $pwdMaxAge));
}
}

Expand All @@ -156,7 +131,7 @@
$smarty->assign("isLocked", $isLocked);
$smarty->assign("unlockDate", $unlockDate);
$smarty->assign("isExpired", $isExpired);
$smarty->assign("ldapExpirationDate", $ldapExpirationDate);
$smarty->assign("ldapExpirationDate", $expirationDate ? $expirationDate->getTimestamp(): NULL);

$smarty->assign("edit_link", $edit_link);

Expand Down
2 changes: 1 addition & 1 deletion templates/display.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@
{$msg_label_expirationdate}
</th>
<td class="col-md-6">
{include 'value_displayer.tpl' value=$ldapExpirationDate type="date" truncate_value_after=10000}
{$ldapExpirationDate|date_format:{$date_specifiers}|truncate:10000}
</td>
</tr>
{/if}
Expand Down

0 comments on commit e220b77

Please sign in to comment.