diff options
Diffstat (limited to 'apps/user_ldap/lib')
-rw-r--r-- | apps/user_ldap/lib/Access.php | 8 | ||||
-rw-r--r-- | apps/user_ldap/lib/Connection.php | 38 | ||||
-rw-r--r-- | apps/user_ldap/lib/Group_LDAP.php | 2 | ||||
-rw-r--r-- | apps/user_ldap/lib/ILDAPWrapper.php | 4 | ||||
-rw-r--r-- | apps/user_ldap/lib/User/User.php | 7 |
5 files changed, 40 insertions, 19 deletions
diff --git a/apps/user_ldap/lib/Access.php b/apps/user_ldap/lib/Access.php index 028e01e2c41..daa5d343185 100644 --- a/apps/user_ldap/lib/Access.php +++ b/apps/user_ldap/lib/Access.php @@ -1467,7 +1467,7 @@ class Access extends LDAPUtility { * @param string $search the search term * @return string the final filter part to use in LDAP searches */ - public function getFilterPartForUserSearch($search) { + public function getFilterPartForUserSearch($search): string { return $this->getFilterPartForSearch($search, $this->connection->ldapAttributesForUserSearch, $this->connection->ldapUserDisplayName); @@ -1479,7 +1479,7 @@ class Access extends LDAPUtility { * @param string $search the search term * @return string the final filter part to use in LDAP searches */ - public function getFilterPartForGroupSearch($search) { + public function getFilterPartForGroupSearch($search): string { return $this->getFilterPartForSearch($search, $this->connection->ldapAttributesForGroupSearch, $this->connection->ldapGroupDisplayName); @@ -1571,10 +1571,8 @@ class Access extends LDAPUtility { /** * returns the filter used for counting users - * - * @return string */ - public function getFilterForUserCount() { + public function getFilterForUserCount(): string { $filter = $this->combineFilterWithAnd([ $this->connection->ldapUserFilter, $this->connection->ldapUserDisplayName . '=*' diff --git a/apps/user_ldap/lib/Connection.php b/apps/user_ldap/lib/Connection.php index fefa1f0e329..565fb415e58 100644 --- a/apps/user_ldap/lib/Connection.php +++ b/apps/user_ldap/lib/Connection.php @@ -78,10 +78,25 @@ class Connection extends LDAPUtility { * @var resource|\LDAP\Connection|null */ private $ldapConnectionRes = null; + + /** + * @var string + */ private $configPrefix; + + /** + * @var ?string + */ private $configID; + + /** + * @var bool + */ private $configured = false; - //whether connection should be kept on __destruct + + /** + * @var bool whether connection should be kept on __destruct + */ private $dontDestruct = false; /** @@ -94,16 +109,27 @@ class Connection extends LDAPUtility { */ public $hasGidNumber = true; - //cache handler - protected $cache; + /** + * @var \OCP\ICache|null + */ + protected $cache = null; /** @var Configuration settings handler **/ protected $configuration; + /** + * @var bool + */ protected $doNotValidate = false; + /** + * @var bool + */ protected $ignoreValidation = false; + /** + * @var array{dn?: mixed, hash?: string, result?: bool} + */ protected $bindResult = []; /** @var LoggerInterface */ @@ -111,16 +137,14 @@ class Connection extends LDAPUtility { /** * Constructor - * @param ILDAPWrapper $ldap * @param string $configPrefix a string with the prefix for the configkey column (appconfig table) * @param string|null $configID a string with the value for the appid column (appconfig table) or null for on-the-fly connections */ - public function __construct(ILDAPWrapper $ldap, $configPrefix = '', $configID = 'user_ldap') { + public function __construct(ILDAPWrapper $ldap, string $configPrefix = '', ?string $configID = 'user_ldap') { parent::__construct($ldap); $this->configPrefix = $configPrefix; $this->configID = $configID; - $this->configuration = new Configuration($configPrefix, - !is_null($configID)); + $this->configuration = new Configuration($configPrefix, !is_null($configID)); $memcache = \OC::$server->getMemCacheFactory(); if ($memcache->isAvailable()) { $this->cache = $memcache->createDistributed(); diff --git a/apps/user_ldap/lib/Group_LDAP.php b/apps/user_ldap/lib/Group_LDAP.php index 0f701f66b19..766b77bf521 100644 --- a/apps/user_ldap/lib/Group_LDAP.php +++ b/apps/user_ldap/lib/Group_LDAP.php @@ -1347,7 +1347,7 @@ class Group_LDAP extends BackendUtility implements GroupInterface, IGroupLDAP, I $this->access->groupname2dn($gid), $this->access->connection->ldapGroupDisplayName); - if ($displayName && (count($displayName) > 0)) { + if (($displayName !== false) && (count($displayName) > 0)) { $displayName = $displayName[0]; $this->access->connection->writeToCache($cacheKey, $displayName); return $displayName; diff --git a/apps/user_ldap/lib/ILDAPWrapper.php b/apps/user_ldap/lib/ILDAPWrapper.php index 569f31315bc..e72d85ac2b9 100644 --- a/apps/user_ldap/lib/ILDAPWrapper.php +++ b/apps/user_ldap/lib/ILDAPWrapper.php @@ -178,8 +178,8 @@ interface ILDAPWrapper { /** * Sets the value of the specified option to be $value * @param resource|\LDAP\Connection $link LDAP link resource - * @param string $option a defined LDAP Server option - * @param int $value the new value for the option + * @param int $option a defined LDAP Server option + * @param mixed $value the new value for the option * @return bool true on success, false otherwise */ public function setOption($link, $option, $value); diff --git a/apps/user_ldap/lib/User/User.php b/apps/user_ldap/lib/User/User.php index ab1500ff368..15894ce04b7 100644 --- a/apps/user_ldap/lib/User/User.php +++ b/apps/user_ldap/lib/User/User.php @@ -266,8 +266,8 @@ class User { /** * returns the home directory of the user if specified by LDAP settings - * @param string $valueFromLDAP - * @return bool|string + * @param ?string $valueFromLDAP + * @return false|string * @throws \Exception */ public function getHomePath($valueFromLDAP = null) { @@ -278,8 +278,7 @@ class User { && strpos($this->access->connection->homeFolderNamingRule, 'attr:') === 0 && $this->access->connection->homeFolderNamingRule !== 'attr:') { $attr = substr($this->access->connection->homeFolderNamingRule, strlen('attr:')); - $homedir = $this->access->readAttribute( - $this->access->username2dn($this->getUsername()), $attr); + $homedir = $this->access->readAttribute($this->access->username2dn($this->getUsername()), $attr); if ($homedir && isset($homedir[0])) { $path = $homedir[0]; } |