diff options
author | Arthur Schiwon <blizzz@arthur-schiwon.de> | 2021-03-11 23:23:55 +0100 |
---|---|---|
committer | Arthur Schiwon <blizzz@arthur-schiwon.de> | 2021-03-17 11:23:48 +0100 |
commit | 1b0355f2c6ec35efd61546937dcae87103ee44e1 (patch) | |
tree | a4abc7a7b4f2655b58e4ac6377db302cc723ecc5 /apps/user_ldap/lib/UserPluginManager.php | |
parent | a1757f83a30c48d0e6582c1ce1bc05e4b21bf2fd (diff) | |
download | nextcloud-server-1b0355f2c6ec35efd61546937dcae87103ee44e1.tar.gz nextcloud-server-1b0355f2c6ec35efd61546937dcae87103ee44e1.zip |
adds ldap user:reset command
- allows to delete data of existing LDAP users, which otherwise is safe
guarded
- ensures that the user is not being deleted on LDAP through a plugin
Signed-off-by: Arthur Schiwon <blizzz@arthur-schiwon.de>
Diffstat (limited to 'apps/user_ldap/lib/UserPluginManager.php')
-rw-r--r-- | apps/user_ldap/lib/UserPluginManager.php | 20 |
1 files changed, 17 insertions, 3 deletions
diff --git a/apps/user_ldap/lib/UserPluginManager.php b/apps/user_ldap/lib/UserPluginManager.php index 2d99d887604..fdc08d3d38b 100644 --- a/apps/user_ldap/lib/UserPluginManager.php +++ b/apps/user_ldap/lib/UserPluginManager.php @@ -28,8 +28,6 @@ namespace OCA\User_LDAP; use OC\User\Backend; class UserPluginManager { - public $test = false; - private $respondToActions = 0; private $which = [ @@ -43,6 +41,9 @@ class UserPluginManager { 'deleteUser' => null ]; + /** @var bool */ + private $suppressDeletion = false; + /** * @return int All implemented actions, except for 'deleteUser' */ @@ -192,7 +193,7 @@ class UserPluginManager { * @return bool */ public function canDeleteUser() { - return $this->which['deleteUser'] !== null; + return !$this->suppressDeletion && $this->which['deleteUser'] !== null; } /** @@ -203,8 +204,21 @@ class UserPluginManager { public function deleteUser($uid) { $plugin = $this->which['deleteUser']; if ($plugin) { + if ($this->suppressDeletion) { + return false; + } return $plugin->deleteUser($uid); } throw new \Exception('No plugin implements deleteUser in this LDAP Backend.'); } + + /** + * @param bool $value + * @return bool – the value before the change + */ + public function setSuppressDeletion(bool $value): bool { + $old = $this->suppressDeletion; + $this->suppressDeletion = $value; + return $old; + } } |