diff options
author | Côme Chilliet <come.chilliet@nextcloud.com> | 2023-04-24 16:03:40 +0200 |
---|---|---|
committer | Côme Chilliet <come.chilliet@nextcloud.com> | 2023-04-24 16:03:40 +0200 |
commit | 429db14a00b893d55f2d4e5126c2fc68dfa6cc99 (patch) | |
tree | e1bcf8d2657c85bbaa908f19e8f0d7edd482353b | |
parent | e8a48b51dc074ee2f5d23d5f48369764f917d499 (diff) | |
download | nextcloud-server-429db14a00b893d55f2d4e5126c2fc68dfa6cc99.tar.gz nextcloud-server-429db14a00b893d55f2d4e5126c2fc68dfa6cc99.zip |
Fix multiple LDAP configuration support by fixing AccessFactory
It must not reuse the same OCA\User_LDAP\User\Manager instance for
several Access instances.
Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
-rw-r--r-- | apps/user_ldap/lib/AccessFactory.php | 6 | ||||
-rw-r--r-- | apps/user_ldap/lib/Jobs/Sync.php | 19 |
2 files changed, 4 insertions, 21 deletions
diff --git a/apps/user_ldap/lib/AccessFactory.php b/apps/user_ldap/lib/AccessFactory.php index f0820f1444f..72797ef1626 100644 --- a/apps/user_ldap/lib/AccessFactory.php +++ b/apps/user_ldap/lib/AccessFactory.php @@ -26,11 +26,11 @@ namespace OCA\User_LDAP; use OCA\User_LDAP\User\Manager; use OCP\IConfig; use OCP\IUserManager; +use OCP\Server; use Psr\Log\LoggerInterface; class AccessFactory { private ILDAPWrapper $ldap; - private Manager $userManager; private Helper $helper; private IConfig $config; private IUserManager $ncUserManager; @@ -38,13 +38,11 @@ class AccessFactory { public function __construct( ILDAPWrapper $ldap, - Manager $userManager, Helper $helper, IConfig $config, IUserManager $ncUserManager, LoggerInterface $logger) { $this->ldap = $ldap; - $this->userManager = $userManager; $this->helper = $helper; $this->config = $config; $this->ncUserManager = $ncUserManager; @@ -55,7 +53,7 @@ class AccessFactory { return new Access( $connection, $this->ldap, - $this->userManager, + Server::get(Manager::class), $this->helper, $this->config, $this->ncUserManager, diff --git a/apps/user_ldap/lib/Jobs/Sync.php b/apps/user_ldap/lib/Jobs/Sync.php index 1ba24af5399..f8a9b14d02f 100644 --- a/apps/user_ldap/lib/Jobs/Sync.php +++ b/apps/user_ldap/lib/Jobs/Sync.php @@ -31,7 +31,6 @@ use OCA\User_LDAP\ConnectionFactory; use OCA\User_LDAP\Helper; use OCA\User_LDAP\LDAP; use OCA\User_LDAP\Mapping\UserMapping; -use OCA\User_LDAP\User\Manager; use OCP\AppFramework\Utility\ITimeFactory; use OCP\BackgroundJob\TimedJob; use OCP\IAvatarManager; @@ -48,8 +47,6 @@ class Sync extends TimedJob { protected $ldapHelper; /** @var LDAP */ protected $ldap; - /** @var Manager */ - protected $userManager; /** @var UserMapping */ protected $mapper; /** @var IConfig */ @@ -69,9 +66,8 @@ class Sync extends TimedJob { /** @var AccessFactory */ protected $accessFactory; - public function __construct(Manager $userManager, ITimeFactory $time) { + public function __construct(ITimeFactory $time) { parent::__construct($time); - $this->userManager = $userManager; $this->setInterval( (int)\OC::$server->getConfig()->getAppValue( 'user_ldap', @@ -350,10 +346,6 @@ class Sync extends TimedJob { $this->notificationManager = \OC::$server->getNotificationManager(); } - if (isset($argument['userManager'])) { - $this->userManager = $argument['userManager']; - } - if (isset($argument['mapper'])) { $this->mapper = $argument['mapper']; } else { @@ -369,14 +361,7 @@ class Sync extends TimedJob { if (isset($argument['accessFactory'])) { $this->accessFactory = $argument['accessFactory']; } else { - $this->accessFactory = new AccessFactory( - $this->ldap, - $this->userManager, - $this->ldapHelper, - $this->config, - $this->ncUserManager, - $this->logger - ); + $this->accessFactory = \OCP\Server::get(AccessFactory::class); } } } |