summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCôme Chilliet <come.chilliet@nextcloud.com>2022-11-17 14:55:55 +0100
committerCôme Chilliet <come.chilliet@nextcloud.com>2022-12-19 14:15:46 +0100
commit4758bdc476f0b2ed981b40bff46239d2a64718fa (patch)
tree574fa86f5c9c41423a5143c3b040bceded02a0d7
parent75e369d3069fea662af7ef41378f8ef4460e3ce1 (diff)
downloadnextcloud-server-4758bdc476f0b2ed981b40bff46239d2a64718fa.tar.gz
nextcloud-server-4758bdc476f0b2ed981b40bff46239d2a64718fa.zip
Use a dedicated LDAP host and port for background jobs if configured
Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
-rw-r--r--apps/user_ldap/lib/Configuration.php12
-rw-r--r--apps/user_ldap/lib/Connection.php12
2 files changed, 18 insertions, 6 deletions
diff --git a/apps/user_ldap/lib/Configuration.php b/apps/user_ldap/lib/Configuration.php
index f2090291d32..59fac50b90b 100644
--- a/apps/user_ldap/lib/Configuration.php
+++ b/apps/user_ldap/lib/Configuration.php
@@ -68,6 +68,8 @@ class Configuration {
'ldapPort' => null,
'ldapBackupHost' => null,
'ldapBackupPort' => null,
+ 'ldapBackgroundHost' => null,
+ 'ldapBackgroundPort' => null,
'ldapBase' => null,
'ldapBaseUsers' => null,
'ldapBaseGroups' => null,
@@ -278,7 +280,7 @@ class Configuration {
$value = implode("\n", $value);
}
break;
- //following options are not stored but detected, skip them
+ //following options are not stored but detected, skip them
case 'ldapIgnoreNamingRules':
case 'ldapUuidUserAttribute':
case 'ldapUuidGroupAttribute':
@@ -367,8 +369,8 @@ class Configuration {
$defaults = $this->getDefaults();
}
return \OC::$server->getConfig()->getAppValue('user_ldap',
- $this->configPrefix.$varName,
- $defaults[$varName]);
+ $this->configPrefix.$varName,
+ $defaults[$varName]);
}
/**
@@ -413,6 +415,8 @@ class Configuration {
'ldap_port' => '',
'ldap_backup_host' => '',
'ldap_backup_port' => '',
+ 'ldap_background_host' => '',
+ 'ldap_background_port' => '',
'ldap_override_main_server' => '',
'ldap_dn' => '',
'ldap_agent_password' => '',
@@ -478,6 +482,8 @@ class Configuration {
'ldap_port' => 'ldapPort',
'ldap_backup_host' => 'ldapBackupHost',
'ldap_backup_port' => 'ldapBackupPort',
+ 'ldap_background_host' => 'ldapBackgroundHost',
+ 'ldap_background_port' => 'ldapBackgroundPort',
'ldap_override_main_server' => 'ldapOverrideMainServer',
'ldap_dn' => 'ldapAgentName',
'ldap_agent_password' => 'ldapAgentPassword',
diff --git a/apps/user_ldap/lib/Connection.php b/apps/user_ldap/lib/Connection.php
index 0ebca44082e..a144810b39b 100644
--- a/apps/user_ldap/lib/Connection.php
+++ b/apps/user_ldap/lib/Connection.php
@@ -600,12 +600,18 @@ class Connection extends LDAPUtility {
$isOverrideMainServer = ($this->configuration->ldapOverrideMainServer
|| $this->getFromCache('overrideMainServer'));
- $isBackupHost = (trim($this->configuration->ldapBackupHost) !== "");
+ $isBackupHost = (trim($this->configuration->ldapBackupHost) !== "")
+ && (!\OC::$CLI || !$this->configuration->ldapBackgroundHost);
$bindStatus = false;
try {
if (!$isOverrideMainServer) {
- $this->doConnect($this->configuration->ldapHost,
- $this->configuration->ldapPort);
+ $host = $this->configuration->ldapHost;
+ $port = $this->configuration->ldapPort;
+ if (\OC::$CLI && $this->configuration->ldapBackgroundHost) {
+ $host = $this->configuration->ldapBackgroundHost;
+ $port = $this->configuration->ldapBackgroundPort;
+ }
+ $this->doConnect($host, $port);
return $this->bind();
}
} catch (ServerNotAvailableException $e) {