From 97127cd9716ec1169367481c47d21e6bef83c0d2 Mon Sep 17 00:00:00 2001 From: Arthur Schiwon Date: Thu, 11 Jun 2015 18:24:45 +0200 Subject: [PATCH 1/2] the user is gone, userExists will not bring him back. But the user's folder needs to be deleted anyway --- apps/user_ldap/user_ldap.php | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/apps/user_ldap/user_ldap.php b/apps/user_ldap/user_ldap.php index cc5d5f5226..014d60c731 100644 --- a/apps/user_ldap/user_ldap.php +++ b/apps/user_ldap/user_ldap.php @@ -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. $user = $this->access->userManager->get($uid); + if(is_null($user)) { \OCP\Util::writeLog('user_ldap', 'No DN found for '.$uid.' on '. $this->access->connection->ldapHost, \OCP\Util::DEBUG); @@ -249,16 +250,16 @@ class USER_LDAP extends BackendUtility implements \OCP\IUserBackend, \OCP\UserIn * @return string|bool */ 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])) { //a deleted user who needs some clean up 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; if($this->access->connection->isCached($cacheKey)) { return $this->access->connection->getFromCache($cacheKey); From 0e522a0b018b868de4ddf1402991e509710aa250 Mon Sep 17 00:00:00 2001 From: Arthur Schiwon Date: Wed, 17 Jun 2015 14:13:01 +0200 Subject: [PATCH 2/2] delete user test to take getHome into account to ensure it is also deleted subsequently --- apps/user_ldap/tests/user_ldap.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/apps/user_ldap/tests/user_ldap.php b/apps/user_ldap/tests/user_ldap.php index 53229e2d64..2f15a5acc6 100644 --- a/apps/user_ldap/tests/user_ldap.php +++ b/apps/user_ldap/tests/user_ldap.php @@ -259,12 +259,15 @@ class Test_User_Ldap_Direct extends \Test\TestCase { $config = $this->getMock('\OCP\IConfig'); $config->expects($this->exactly(2)) ->method('getUserValue') - ->will($this->returnValue(1)); + ->will($this->onConsecutiveCalls('1', '/var/vhome/jdings/')); $backend = new UserLDAP($access, $config); $result = $backend->deleteUser('jeremy'); $this->assertTrue($result); + + $home = $backend->getHome('jeremy'); + $this->assertSame($home, '/var/vhome/jdings/'); } /**