fix(user_ldap): Improve typing and fix a var name

Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
pull/44533/head
Côme Chilliet 3 weeks ago
parent c99ebaa866
commit 7f3fcbc49f
No known key found for this signature in database
GPG Key ID: A3E2F658B28C760A

@ -48,7 +48,7 @@ $configuration = new \OCA\User_LDAP\Configuration($prefix);
$con = new \OCA\User_LDAP\Connection($ldapWrapper, $prefix, null);
$con->setConfiguration($configuration->getConfiguration());
$con->ldapConfigurationActive = true;
$con->ldapConfigurationActive = (string)true;
$con->setIgnoreValidation(true);
$factory = \OC::$server->get(\OCA\User_LDAP\AccessFactory::class);

@ -448,7 +448,7 @@ class Connection extends LDAPUtility {
$backupPort = (int)$this->configuration->ldapBackupPort;
if ($backupPort <= 0) {
$this->configuration->backupPort = $this->configuration->ldapPort;
$this->configuration->ldapBackupPort = $this->configuration->ldapPort;
}
//make sure empty search attributes are saved as simple, empty array
@ -463,7 +463,7 @@ class Connection extends LDAPUtility {
if ((stripos((string)$this->configuration->ldapHost, 'ldaps://') === 0)
&& $this->configuration->ldapTLS) {
$this->configuration->ldapTLS = false;
$this->configuration->ldapTLS = (string)false;
$this->logger->info(
'LDAPS (already using secure connection) and TLS do not work together. Switched off TLS.',
['app' => 'user_ldap']

@ -169,7 +169,7 @@ class Sync extends TimedJob {
$results = $access->fetchListOfUsers(
$filter,
$access->userManager->getAttributes(),
$connection->ldapPagingSize,
(int)$connection->ldapPagingSize,
$cycleData['offset'],
true
);

@ -414,7 +414,7 @@ class Wizard extends LDAPUtility {
$this->fetchGroups($dbKey, $confKey);
if ($testMemberOf) {
$this->configuration->hasMemberOfFilterSupport = $this->testMemberOf();
$this->configuration->hasMemberOfFilterSupport = (string)$this->testMemberOf();
$this->result->markChange();
if (!$this->configuration->hasMemberOfFilterSupport) {
throw new \Exception('memberOf is not supported by the server');
@ -700,8 +700,8 @@ class Wizard extends LDAPUtility {
if ($settingsFound === true) {
$config = [
'ldapPort' => $p,
'ldapTLS' => (int)$t
'ldapPort' => (string)$p,
'ldapTLS' => (string)$t,
];
$this->configuration->setConfiguration($config);
$this->logger->debug(
@ -1322,7 +1322,7 @@ class Wizard extends LDAPUtility {
$this->ldap->setOption($cr, LDAP_OPT_PROTOCOL_VERSION, 3);
$this->ldap->setOption($cr, LDAP_OPT_REFERRALS, 0);
$this->ldap->setOption($cr, LDAP_OPT_NETWORK_TIMEOUT, self::LDAP_NW_TIMEOUT);
if ($this->configuration->ldapTLS === 1) {
if ($this->configuration->ldapTLS) {
$this->ldap->startTls($cr);
}
@ -1337,6 +1337,9 @@ class Wizard extends LDAPUtility {
return false;
}
/**
* @return array<array{port:int,tls:bool}>
*/
private function getDefaultLdapPortSettings(): array {
static $settings = [
['port' => 7636, 'tls' => false],
@ -1349,6 +1352,9 @@ class Wizard extends LDAPUtility {
return $settings;
}
/**
* @return array<array{port:int,tls:bool}>
*/
private function getPortSettingsToTry(): array {
//389 ← LDAP / Unencrypted or StartTLS
//636 ← LDAPS / SSL
@ -1367,7 +1373,7 @@ class Wizard extends LDAPUtility {
}
$portSettings[] = ['port' => $port, 'tls' => false];
} elseif ($this->configuration->usesLdapi()) {
$portSettings[] = ['port' => '', 'tls' => false];
$portSettings[] = ['port' => 0, 'tls' => false];
}
//default ports

Loading…
Cancel
Save