Skip to content

Commit

Permalink
Fixed exception thrown when logging in as an LDAP user due to a direc…
Browse files Browse the repository at this point in the history
…tory not having password policy attributes available.

nextcloud#33622

Signed-off-by: Adam Reece <adam@reece.wales>
  • Loading branch information
Adambean committed Sep 19, 2022
1 parent ea08fab commit ad47c7a
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion apps/user_ldap/lib/User/User.php
Original file line number Diff line number Diff line change
Expand Up @@ -664,11 +664,15 @@ public function handlePasswordExpiry($params) {
//retrieve relevant password policy attributes
$cacheKey = 'ppolicyAttributes' . $ppolicyDN;
$result = $this->connection->getFromCache($cacheKey);
if (is_null($result)) {
if (is_null($result) || !is_array($result) || empty($result[0]) || !is_array($result[0])) {
$result = $this->access->search('objectclass=*', $ppolicyDN, ['pwdgraceauthnlimit', 'pwdmaxage', 'pwdexpirewarning']);
$this->connection->writeToCache($cacheKey, $result);
}

if (is_null($result) || !is_array($result) || empty($result[0]) || !is_array($result[0])) {
return;//password policy attributes not found in directory
}

$pwdGraceAuthNLimit = array_key_exists('pwdgraceauthnlimit', $result[0]) ? $result[0]['pwdgraceauthnlimit'] : [];
$pwdMaxAge = array_key_exists('pwdmaxage', $result[0]) ? $result[0]['pwdmaxage'] : [];
$pwdExpireWarning = array_key_exists('pwdexpirewarning', $result[0]) ? $result[0]['pwdexpirewarning'] : [];
Expand Down

0 comments on commit ad47c7a

Please sign in to comment.