summaryrefslogtreecommitdiffstats
path: root/apps
diff options
context:
space:
mode:
authorblizzz <blizzz@arthur-schiwon.de>2018-09-18 11:38:16 +0200
committerGitHub <noreply@github.com>2018-09-18 11:38:16 +0200
commitd9247f76407c9d7e511476f47d12d2293ecc6845 (patch)
tree8c36acc4d409f7111de0b1450cad833ae5c1f000 /apps
parent45c35fc7fd6add12fb383f6c6a3111d593497500 (diff)
parent2d30511fa63780d1b2931e1daa37d2f150f6d0d7 (diff)
downloadnextcloud-server-d9247f76407c9d7e511476f47d12d2293ecc6845.tar.gz
nextcloud-server-d9247f76407c9d7e511476f47d12d2293ecc6845.zip
Merge pull request #11245 from nextcloud/bugfix/8288/userldap-getusername-on-null
Check if user is null before getUsername
Diffstat (limited to 'apps')
-rw-r--r--apps/user_ldap/lib/User_LDAP.php12
1 files changed, 7 insertions, 5 deletions
diff --git a/apps/user_ldap/lib/User_LDAP.php b/apps/user_ldap/lib/User_LDAP.php
index 11ed02f47ab..fbdf1cc2551 100644
--- a/apps/user_ldap/lib/User_LDAP.php
+++ b/apps/user_ldap/lib/User_LDAP.php
@@ -119,24 +119,26 @@ class User_LDAP extends BackendUtility implements \OCP\IUserBackend, \OCP\UserIn
}
/**
- * returns the username for the given login name, if available
+ * Return the username for the given login name, if available
*
* @param string $loginName
* @return string|false
+ * @throws \Exception
*/
public function loginName2UserName($loginName) {
- $cacheKey = 'loginName2UserName-'.$loginName;
+ $cacheKey = 'loginName2UserName-' . $loginName;
$username = $this->access->connection->getFromCache($cacheKey);
- if(!is_null($username)) {
+
+ if ($username !== null) {
return $username;
}
try {
$ldapRecord = $this->getLDAPUserByLoginName($loginName);
$user = $this->access->userManager->get($ldapRecord['dn'][0]);
- if($user instanceof OfflineUser) {
+ if ($user === null || $user instanceof OfflineUser) {
// this path is not really possible, however get() is documented
- // to return User or OfflineUser so we are very defensive here.
+ // to return User, OfflineUser or null so we are very defensive here.
$this->access->connection->writeToCache($cacheKey, false);
return false;
}