From ad47c7a8e18f1ef8ca37adb5bc9ccd6b8e9c0ba4 Mon Sep 17 00:00:00 2001 From: Adam Reece Date: Mon, 19 Sep 2022 17:32:49 +0100 Subject: [PATCH] Fixed exception thrown when logging in as an LDAP user due to a directory not having password policy attributes available. https://github.com/nextcloud/server/issues/33622 Signed-off-by: Adam Reece --- apps/user_ldap/lib/User/User.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/apps/user_ldap/lib/User/User.php b/apps/user_ldap/lib/User/User.php index 15894ce04b775..fdb2b4b41a4c4 100644 --- a/apps/user_ldap/lib/User/User.php +++ b/apps/user_ldap/lib/User/User.php @@ -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'] : [];