Merge pull request #16890 from owncloud/fix-16588

the user is gone, userExists will not bring him back. But the user's …
This commit is contained in:
Thomas Müller 2015-06-18 12:51:06 +02:00
commit a04cb82fd9
2 changed files with 10 additions and 6 deletions

View file

@ -259,12 +259,15 @@ class Test_User_Ldap_Direct extends \Test\TestCase {
$config = $this->getMock('\OCP\IConfig'); $config = $this->getMock('\OCP\IConfig');
$config->expects($this->exactly(2)) $config->expects($this->exactly(2))
->method('getUserValue') ->method('getUserValue')
->will($this->returnValue(1)); ->will($this->onConsecutiveCalls('1', '/var/vhome/jdings/'));
$backend = new UserLDAP($access, $config); $backend = new UserLDAP($access, $config);
$result = $backend->deleteUser('jeremy'); $result = $backend->deleteUser('jeremy');
$this->assertTrue($result); $this->assertTrue($result);
$home = $backend->getHome('jeremy');
$this->assertSame($home, '/var/vhome/jdings/');
} }
/** /**

View file

@ -198,6 +198,7 @@ class USER_LDAP extends BackendUtility implements \OCP\IUserBackend, \OCP\UserIn
} }
//getting dn, if false the user does not exist. If dn, he may be mapped only, requires more checking. //getting dn, if false the user does not exist. If dn, he may be mapped only, requires more checking.
$user = $this->access->userManager->get($uid); $user = $this->access->userManager->get($uid);
if(is_null($user)) { if(is_null($user)) {
\OCP\Util::writeLog('user_ldap', 'No DN found for '.$uid.' on '. \OCP\Util::writeLog('user_ldap', 'No DN found for '.$uid.' on '.
$this->access->connection->ldapHost, \OCP\Util::DEBUG); $this->access->connection->ldapHost, \OCP\Util::DEBUG);
@ -249,16 +250,16 @@ class USER_LDAP extends BackendUtility implements \OCP\IUserBackend, \OCP\UserIn
* @return string|bool * @return string|bool
*/ */
public function getHome($uid) { public function getHome($uid) {
// user Exists check required as it is not done in user proxy!
if(!$this->userExists($uid)) {
return false;
}
if(isset($this->homesToKill[$uid]) && !empty($this->homesToKill[$uid])) { if(isset($this->homesToKill[$uid]) && !empty($this->homesToKill[$uid])) {
//a deleted user who needs some clean up //a deleted user who needs some clean up
return $this->homesToKill[$uid]; return $this->homesToKill[$uid];
} }
// user Exists check required as it is not done in user proxy!
if(!$this->userExists($uid)) {
return false;
}
$cacheKey = 'getHome'.$uid; $cacheKey = 'getHome'.$uid;
if($this->access->connection->isCached($cacheKey)) { if($this->access->connection->isCached($cacheKey)) {
return $this->access->connection->getFromCache($cacheKey); return $this->access->connection->getFromCache($cacheKey);