Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions apps/user_ldap/lib/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -463,6 +464,7 @@ public function getDefaults(): array {
'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,
];
}

Expand Down Expand Up @@ -526,6 +528,7 @@ public function getConfigTranslationArray(): array {
'ldap_ext_storage_home_attribute' => 'ldapExtStorageHomeAttribute',
'ldap_matching_rule_in_chain_state' => 'ldapMatchingRuleInChainState',
'ldapIgnoreNamingRules' => 'ldapIgnoreNamingRules', // sysconfig
'ldap_connection_timeout' => 'ldapConnectionTimeout',
];
return $array;
}
Expand Down
4 changes: 4 additions & 0 deletions apps/user_ldap/lib/Connection.php
Original file line number Diff line number Diff line change
Expand Up @@ -649,6 +649,10 @@ private function doConnect($host, $port) {
throw new ServerNotAvailableException('Could not disable LDAP referrals.');
}

if (!$this->ldap->setOption($this->ldapConnectionRes, LDAP_OPT_NETWORK_TIMEOUT, $this->configuration->ldapConnectionTimeout)) {

Check failure

Code scanning / Psalm

UndefinedConstant

Const LDAP_OPT_NETWORK_TIMEOUT is not defined

Check notice

Code scanning / Psalm

PossiblyFalseArgument

Argument 1 of OCA\User_LDAP\ILDAPWrapper::setOption cannot be false, possibly LDAP\Connection|resource value expected
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 . '.');
Expand Down