Compare commits

...

1 Commits

Author SHA1 Message Date
Côme Chilliet b15e4d518a fix(user_ldap): Do not block access to configuration page upon bad configuration
It should be possible to access configuration page with the local admin
 user even when LDAP configuration is not valid.
This prevent ldap backend from throwing in countUsers to allow this.

Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
2024-02-12 14:17:27 +01:00
2 changed files with 12 additions and 7 deletions
+1
View File
@@ -241,6 +241,7 @@ class Connection extends LDAPUtility {
}
/**
* @throws ServerNotAvailableException When connection failed or configuration is invalid
* @return resource|\LDAP\Connection The LDAP resource
*/
public function getConnectionResource() {
+11 -7
View File
@@ -300,7 +300,7 @@ class User_LDAP extends BackendUtility implements IUserBackend, UserInterface, I
* @param string|\OCA\User_LDAP\User\User $user either the Nextcloud user
* name or an instance of that user
* @throws \Exception
* @throws \OC\ServerNotAvailableException
* @throws ServerNotAvailableException
*/
public function userExistsOnLDAP($user, bool $ignoreCache = false): bool {
if (is_string($user)) {
@@ -586,14 +586,18 @@ class User_LDAP extends BackendUtility implements IUserBackend, UserInterface, I
return $this->userPluginManager->countUsers();
}
$filter = $this->access->getFilterForUserCount();
$cacheKey = 'countUsers-'.$filter;
if (!is_null($entries = $this->access->connection->getFromCache($cacheKey))) {
try {
$filter = $this->access->getFilterForUserCount();
$cacheKey = 'countUsers-'.$filter;
if (!is_null($entries = $this->access->connection->getFromCache($cacheKey))) {
return $entries;
}
$entries = $this->access->countUsers($filter);
$this->access->connection->writeToCache($cacheKey, $entries);
return $entries;
} catch (ServerNotAvailableException $e) {
return false;
}
$entries = $this->access->countUsers($filter);
$this->access->connection->writeToCache($cacheKey, $entries);
return $entries;
}
public function countMappedUsers(): int {