diff options
author | blizzz <blizzz@arthur-schiwon.de> | 2022-11-30 14:44:15 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-11-30 14:44:15 +0100 |
commit | b16c9838c6676ec6c566e26bd3b262c77acf742c (patch) | |
tree | 29ae978ebbcf7c6e5ce720d87c645898bdbc87da /apps/user_ldap | |
parent | 415e68f53b393cf0ff28f4462ae756385cf7c4f3 (diff) | |
parent | a781ae3afb270af8cef33766ecc03f7d19670f12 (diff) | |
download | nextcloud-server-b16c9838c6676ec6c566e26bd3b262c77acf742c.tar.gz nextcloud-server-b16c9838c6676ec6c566e26bd3b262c77acf742c.zip |
Merge pull request #35355 from nextcloud/artonge/feat/ldap_connection_timeout
Allow to set a custom timeout for ldap connections
Diffstat (limited to 'apps/user_ldap')
-rw-r--r-- | apps/user_ldap/lib/Configuration.php | 3 | ||||
-rw-r--r-- | apps/user_ldap/lib/Connection.php | 4 |
2 files changed, 7 insertions, 0 deletions
diff --git a/apps/user_ldap/lib/Configuration.php b/apps/user_ldap/lib/Configuration.php index c16823d39ee..fc620e00e30 100644 --- a/apps/user_ldap/lib/Configuration.php +++ b/apps/user_ldap/lib/Configuration.php @@ -120,6 +120,7 @@ class Configuration { 'ldapDefaultPPolicyDN' => null, 'ldapExtStorageHomeAttribute' => null, 'ldapMatchingRuleInChainState' => self::LDAP_SERVER_FEATURE_UNKNOWN, + 'ldapConnectionTimeout' => 15, ]; public function __construct(string $configPrefix, bool $autoRead = true) { @@ -463,6 +464,7 @@ class Configuration { 'ldap_user_avatar_rule' => 'default', 'ldap_ext_storage_home_attribute' => '', 'ldap_matching_rule_in_chain_state' => self::LDAP_SERVER_FEATURE_UNKNOWN, + 'ldap_connection_timeout' => 15, ]; } @@ -526,6 +528,7 @@ class Configuration { 'ldap_ext_storage_home_attribute' => 'ldapExtStorageHomeAttribute', 'ldap_matching_rule_in_chain_state' => 'ldapMatchingRuleInChainState', 'ldapIgnoreNamingRules' => 'ldapIgnoreNamingRules', // sysconfig + 'ldap_connection_timeout' => 'ldapConnectionTimeout', ]; return $array; } diff --git a/apps/user_ldap/lib/Connection.php b/apps/user_ldap/lib/Connection.php index 82d0374c759..dca55c1750e 100644 --- a/apps/user_ldap/lib/Connection.php +++ b/apps/user_ldap/lib/Connection.php @@ -654,6 +654,10 @@ class Connection extends LDAPUtility { throw new ServerNotAvailableException('Could not disable LDAP referrals.'); } + if (!$this->ldap->setOption($this->ldapConnectionRes, LDAP_OPT_NETWORK_TIMEOUT, $this->configuration->ldapConnectionTimeout)) { + throw new ServerNotAvailableException('Could not set network timeout'); + } + if ($this->configuration->ldapTLS) { if (!$this->ldap->startTls($this->ldapConnectionRes)) { throw new ServerNotAvailableException('Start TLS failed, when connecting to LDAP host ' . $host . '.'); |