aboutsummaryrefslogtreecommitdiffstats
path: root/apps/user_ldap/lib
diff options
context:
space:
mode:
Diffstat (limited to 'apps/user_ldap/lib')
-rw-r--r--apps/user_ldap/lib/Command/Search.php8
-rw-r--r--apps/user_ldap/lib/Helper.php3
-rw-r--r--apps/user_ldap/lib/Jobs/CleanUp.php3
-rw-r--r--apps/user_ldap/lib/Migration/UUIDFixGroup.php2
-rw-r--r--apps/user_ldap/lib/User_LDAP.php24
-rw-r--r--apps/user_ldap/lib/User_Proxy.php10
6 files changed, 31 insertions, 19 deletions
diff --git a/apps/user_ldap/lib/Command/Search.php b/apps/user_ldap/lib/Command/Search.php
index 463ad2eaeb4..d348d5b31c9 100644
--- a/apps/user_ldap/lib/Command/Search.php
+++ b/apps/user_ldap/lib/Command/Search.php
@@ -120,7 +120,13 @@ class Search extends Command {
$limit = null;
}
} else {
- $proxy = new User_Proxy($configPrefixes, $ldapWrapper, $this->ocConfig, \OC::$server->getNotificationManager());
+ $proxy = new User_Proxy(
+ $configPrefixes,
+ $ldapWrapper,
+ $this->ocConfig,
+ \OC::$server->getNotificationManager(),
+ \OC::$server->getUserSession()
+ );
$getMethod = 'getDisplayNames';
$printID = true;
}
diff --git a/apps/user_ldap/lib/Helper.php b/apps/user_ldap/lib/Helper.php
index 83b2f05f1d2..891ab7f0a3a 100644
--- a/apps/user_ldap/lib/Helper.php
+++ b/apps/user_ldap/lib/Helper.php
@@ -294,9 +294,10 @@ class Helper {
$ldapWrapper = new LDAP();
$ocConfig = \OC::$server->getConfig();
$notificationManager = \OC::$server->getNotificationManager();
+ $userSession = \OC::$server->getUserSession();
$userBackend = new User_Proxy(
- $configPrefixes, $ldapWrapper, $ocConfig, $notificationManager
+ $configPrefixes, $ldapWrapper, $ocConfig, $notificationManager, $userSession
);
$uid = $userBackend->loginName2UserName($param['uid'] );
if($uid !== false) {
diff --git a/apps/user_ldap/lib/Jobs/CleanUp.php b/apps/user_ldap/lib/Jobs/CleanUp.php
index a4dd4ba32ad..44e8f5469f1 100644
--- a/apps/user_ldap/lib/Jobs/CleanUp.php
+++ b/apps/user_ldap/lib/Jobs/CleanUp.php
@@ -99,7 +99,8 @@ class CleanUp extends TimedJob {
$this->ldapHelper->getServerConfigurationPrefixes(true),
new LDAP(),
$this->ocConfig,
- \OC::$server->getNotificationManager()
+ \OC::$server->getNotificationManager(),
+ \OC::$server->getUserSession()
);
}
diff --git a/apps/user_ldap/lib/Migration/UUIDFixGroup.php b/apps/user_ldap/lib/Migration/UUIDFixGroup.php
index 6aacb37257e..9ea406efadf 100644
--- a/apps/user_ldap/lib/Migration/UUIDFixGroup.php
+++ b/apps/user_ldap/lib/Migration/UUIDFixGroup.php
@@ -33,6 +33,6 @@ class UUIDFixGroup extends UUIDFix {
public function __construct(GroupMapping $mapper, LDAP $ldap, IConfig $config, Helper $helper) {
$this->mapper = $mapper;
$this->proxy = new User_Proxy($helper->getServerConfigurationPrefixes(true), $ldap, $config,
- \OC::$server->getNotificationManager());
+ \OC::$server->getNotificationManager(), \OC::$server->getUserSession());
}
}
diff --git a/apps/user_ldap/lib/User_LDAP.php b/apps/user_ldap/lib/User_LDAP.php
index 6c438391380..0a9a1cfe4c2 100644
--- a/apps/user_ldap/lib/User_LDAP.php
+++ b/apps/user_ldap/lib/User_LDAP.php
@@ -42,6 +42,7 @@ use OCA\User_LDAP\User\OfflineUser;
use OCA\User_LDAP\User\User;
use OCP\IConfig;
use OCP\IUser;
+use OCP\IUserSession;
use OCP\Notification\IManager as INotificationManager;
use OCP\Util;
@@ -59,24 +60,21 @@ class User_LDAP extends BackendUtility implements \OCP\IUserBackend, \OCP\UserIn
* @param Access $access
* @param \OCP\IConfig $ocConfig
* @param \OCP\Notification\IManager $notificationManager
+ * @param IUserSession $userSession
*/
- public function __construct(Access $access, IConfig $ocConfig, INotificationManager $notificationManager) {
+ public function __construct(Access $access, IConfig $ocConfig, INotificationManager $notificationManager, IUserSession $userSession) {
parent::__construct($access);
$this->ocConfig = $ocConfig;
$this->notificationManager = $notificationManager;
- $this->registerHooks();
+ $this->registerHooks($userSession);
}
- protected function registerHooks() {
- Util::connectHook('OC_User','pre_deleteUser', $this, 'preDeleteUser');
- Util::connectHook('OC_User','post_deleteUser', $this, 'postDeleteUser');
+ protected function registerHooks(IUserSession $userSession) {
+ $userSession->listen('\OC\User', 'preDelete', [$this, 'preDeleteUser']);
+ $userSession->listen('\OC\User', 'postDelete', [$this, 'postDeleteUser']);
}
- public function preDeleteUser(array $param) {
- $user = $param[0];
- if(!$user instanceof IUser) {
- throw new \RuntimeException('IUser expected');
- }
+ public function preDeleteUser(IUser $user) {
$this->currentUserInDeletionProcess = $user->getUID();
}
@@ -376,8 +374,6 @@ class User_LDAP extends BackendUtility implements \OCP\IUserBackend, \OCP\UserIn
\OC::$server->getLogger()->info('Cleaning up after user ' . $uid,
array('app' => 'user_ldap'));
- //Get Home Directory out of user preferences so we can return it later,
- //necessary for removing directories as done by OC_User.
$this->access->getUserMapper()->unmap($uid);
$this->access->userManager->invalidate($uid);
return true;
@@ -406,7 +402,9 @@ class User_LDAP extends BackendUtility implements \OCP\IUserBackend, \OCP\UserIn
// early return path if it is a deleted user
$user = $this->access->userManager->get($uid);
if($user instanceof OfflineUser) {
- if($this->currentUserInDeletionProcess === $user->getUID()) {
+ if($this->currentUserInDeletionProcess !== null
+ && $this->currentUserInDeletionProcess === $user->getOCName()
+ ) {
return $user->getHomePath();
} else {
throw new NoUserException($uid . ' is not a valid user anymore');
diff --git a/apps/user_ldap/lib/User_Proxy.php b/apps/user_ldap/lib/User_Proxy.php
index d1784ad7c14..a25eb1bc621 100644
--- a/apps/user_ldap/lib/User_Proxy.php
+++ b/apps/user_ldap/lib/User_Proxy.php
@@ -31,6 +31,7 @@ namespace OCA\User_LDAP;
use OCA\User_LDAP\User\User;
use OCP\IConfig;
+use OCP\IUserSession;
use OCP\Notification\IManager as INotificationManager;
class User_Proxy extends Proxy implements \OCP\IUserBackend, \OCP\UserInterface, IUserLDAP {
@@ -39,14 +40,19 @@ class User_Proxy extends Proxy implements \OCP\IUserBackend, \OCP\UserInterface,
/**
* Constructor
+ *
* @param array $serverConfigPrefixes array containing the config Prefixes
+ * @param ILDAPWrapper $ldap
+ * @param IConfig $ocConfig
+ * @param INotificationManager $notificationManager
+ * @param IUserSession $userSession
*/
public function __construct(array $serverConfigPrefixes, ILDAPWrapper $ldap, IConfig $ocConfig,
- INotificationManager $notificationManager) {
+ INotificationManager $notificationManager, IUserSession $userSession) {
parent::__construct($ldap);
foreach($serverConfigPrefixes as $configPrefix) {
$this->backends[$configPrefix] =
- new User_LDAP($this->getAccess($configPrefix), $ocConfig, $notificationManager);
+ new User_LDAP($this->getAccess($configPrefix), $ocConfig, $notificationManager, $userSession);
if(is_null($this->refBackend)) {
$this->refBackend = &$this->backends[$configPrefix];
}