|
|
@ -76,11 +76,12 @@ class User_LDAP extends BackendUtility implements IUserBackend, UserInterface, I |
|
|
|
* @return string|false |
|
|
|
* @return string|false |
|
|
|
* @throws \Exception |
|
|
|
* @throws \Exception |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public function loginName2UserName($loginName) { |
|
|
|
public function loginName2UserName($loginName, bool $forceLdapRefetch = false) { |
|
|
|
$cacheKey = 'loginName2UserName-' . $loginName; |
|
|
|
$cacheKey = 'loginName2UserName-' . $loginName; |
|
|
|
$username = $this->access->connection->getFromCache($cacheKey); |
|
|
|
$username = $this->access->connection->getFromCache($cacheKey); |
|
|
|
|
|
|
|
|
|
|
|
if ($username !== null) { |
|
|
|
$ignoreCache = ($username === false && $forceLdapRefetch); |
|
|
|
|
|
|
|
if ($username !== null && !$ignoreCache) { |
|
|
|
return $username; |
|
|
|
return $username; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -95,6 +96,9 @@ class User_LDAP extends BackendUtility implements IUserBackend, UserInterface, I |
|
|
|
} |
|
|
|
} |
|
|
|
$username = $user->getUsername(); |
|
|
|
$username = $user->getUsername(); |
|
|
|
$this->access->connection->writeToCache($cacheKey, $username); |
|
|
|
$this->access->connection->writeToCache($cacheKey, $username); |
|
|
|
|
|
|
|
if ($forceLdapRefetch) { |
|
|
|
|
|
|
|
$user->processAttributes($ldapRecord); |
|
|
|
|
|
|
|
} |
|
|
|
return $username; |
|
|
|
return $username; |
|
|
|
} catch (NotOnLDAP $e) { |
|
|
|
} catch (NotOnLDAP $e) { |
|
|
|
$this->access->connection->writeToCache($cacheKey, false); |
|
|
|
$this->access->connection->writeToCache($cacheKey, false); |
|
|
@ -138,16 +142,11 @@ class User_LDAP extends BackendUtility implements IUserBackend, UserInterface, I |
|
|
|
* @return false|string |
|
|
|
* @return false|string |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public function checkPassword($uid, $password) { |
|
|
|
public function checkPassword($uid, $password) { |
|
|
|
try { |
|
|
|
$username = $this->loginName2UserName($uid, true); |
|
|
|
$ldapRecord = $this->getLDAPUserByLoginName($uid); |
|
|
|
if ($username === false) { |
|
|
|
} catch (NotOnLDAP $e) { |
|
|
|
|
|
|
|
$this->logger->debug( |
|
|
|
|
|
|
|
$e->getMessage(), |
|
|
|
|
|
|
|
['app' => 'user_ldap', 'exception' => $e] |
|
|
|
|
|
|
|
); |
|
|
|
|
|
|
|
return false; |
|
|
|
return false; |
|
|
|
} |
|
|
|
} |
|
|
|
$dn = $ldapRecord['dn'][0]; |
|
|
|
$dn = $this->access->username2dn($username); |
|
|
|
$user = $this->access->userManager->get($dn); |
|
|
|
$user = $this->access->userManager->get($dn); |
|
|
|
|
|
|
|
|
|
|
|
if (!$user instanceof User) { |
|
|
|
if (!$user instanceof User) { |
|
|
@ -165,7 +164,6 @@ class User_LDAP extends BackendUtility implements IUserBackend, UserInterface, I |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
$this->access->cacheUserExists($user->getUsername()); |
|
|
|
$this->access->cacheUserExists($user->getUsername()); |
|
|
|
$user->processAttributes($ldapRecord); |
|
|
|
|
|
|
|
$user->markLogin(); |
|
|
|
$user->markLogin(); |
|
|
|
|
|
|
|
|
|
|
|
return $user->getUsername(); |
|
|
|
return $user->getUsername(); |
|
|
|