Skip to content

Commit 5d57621

Browse files
joshtrichardsAndyScherzinger
authored andcommitted
[stable31] fix: Only attempt $result array access if array not empty.
Manual backport of #53714 Signed-off-by: Josh <josh.t.richards@gmail.com>
1 parent d8a14a0 commit 5d57621

1 file changed

Lines changed: 10 additions & 8 deletions

File tree

apps/user_ldap/lib/User/User.php

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -741,16 +741,18 @@ public function handlePasswordExpiry(array $params): void {
741741
//retrieve relevant user attributes
742742
$result = $this->access->search('objectclass=*', $this->dn, ['pwdpolicysubentry', 'pwdgraceusetime', 'pwdreset', 'pwdchangedtime']);
743743

744-
if (array_key_exists('pwdpolicysubentry', $result[0])) {
745-
$pwdPolicySubentry = $result[0]['pwdpolicysubentry'];
746-
if ($pwdPolicySubentry && (count($pwdPolicySubentry) > 0)) {
747-
$ppolicyDN = $pwdPolicySubentry[0];//custom ppolicy DN
744+
if (!empty($result)) {
745+
if (array_key_exists('pwdpolicysubentry', $result[0])) {
746+
$pwdPolicySubentry = $result[0]['pwdpolicysubentry'];
747+
if ($pwdPolicySubentry && (count($pwdPolicySubentry) > 0)) {
748+
$ppolicyDN = $pwdPolicySubentry[0];//custom ppolicy DN
749+
}
748750
}
749-
}
750751

751-
$pwdGraceUseTime = array_key_exists('pwdgraceusetime', $result[0]) ? $result[0]['pwdgraceusetime'] : [];
752-
$pwdReset = array_key_exists('pwdreset', $result[0]) ? $result[0]['pwdreset'] : [];
753-
$pwdChangedTime = array_key_exists('pwdchangedtime', $result[0]) ? $result[0]['pwdchangedtime'] : [];
752+
$pwdGraceUseTime = array_key_exists('pwdgraceusetime', $result[0]) ? $result[0]['pwdgraceusetime'] : [];
753+
$pwdReset = array_key_exists('pwdreset', $result[0]) ? $result[0]['pwdreset'] : [];
754+
$pwdChangedTime = array_key_exists('pwdchangedtime', $result[0]) ? $result[0]['pwdchangedtime'] : [];
755+
}
754756

755757
//retrieve relevant password policy attributes
756758
$cacheKey = 'ppolicyAttributes' . $ppolicyDN;

0 commit comments

Comments
 (0)