diff --git a/apps/user_ldap/lib/AppInfo/Application.php b/apps/user_ldap/lib/AppInfo/Application.php index 6d5c416f04..59d7cdb492 100644 --- a/apps/user_ldap/lib/AppInfo/Application.php +++ b/apps/user_ldap/lib/AppInfo/Application.php @@ -24,6 +24,8 @@ namespace OCA\User_LDAP\AppInfo; use OCA\User_LDAP\Controller\RenewPasswordController; +use OCA\User_LDAP\ILDAPWrapper; +use OCA\User_LDAP\LDAP; use OCP\AppFramework\App; use OCP\AppFramework\IAppContainer; use OCP\IL10N; @@ -50,5 +52,9 @@ class Application extends App { $server->getURLGenerator() ); }); + + $container->registerService(ILDAPWrapper::class, function () { + return new LDAP(); + }); } } diff --git a/apps/user_ldap/lib/Command/SetConfig.php b/apps/user_ldap/lib/Command/SetConfig.php index db656558ef..cf73874ade 100644 --- a/apps/user_ldap/lib/Command/SetConfig.php +++ b/apps/user_ldap/lib/Command/SetConfig.php @@ -26,6 +26,8 @@ namespace OCA\User_LDAP\Command; +use OCA\User_LDAP\ConnectionFactory; +use OCA\User_LDAP\LDAP; use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; @@ -83,5 +85,8 @@ class SetConfig extends Command { $configHolder = new Configuration($configID); $configHolder->$key = $value; $configHolder->saveConfiguration(); + + $connectionFactory = new ConnectionFactory(new LDAP()); + $connectionFactory->get($configID)->clearCache(); } } diff --git a/apps/user_ldap/lib/Controller/ConfigAPIController.php b/apps/user_ldap/lib/Controller/ConfigAPIController.php index a745e4ce06..ce885b7dab 100644 --- a/apps/user_ldap/lib/Controller/ConfigAPIController.php +++ b/apps/user_ldap/lib/Controller/ConfigAPIController.php @@ -27,6 +27,7 @@ use OC\CapabilitiesManager; use OC\Core\Controller\OCSController; use OC\Security\IdentityProof\Manager; use OCA\User_LDAP\Configuration; +use OCA\User_LDAP\ConnectionFactory; use OCA\User_LDAP\Helper; use OCP\AppFramework\Http\DataResponse; use OCP\AppFramework\OCS\OCSBadRequestException; @@ -45,6 +46,9 @@ class ConfigAPIController extends OCSController { /** @var ILogger */ private $logger; + /** @var ConnectionFactory */ + private $connectionFactory; + public function __construct( $appName, IRequest $request, @@ -53,7 +57,8 @@ class ConfigAPIController extends OCSController { IUserManager $userManager, Manager $keyManager, Helper $ldapHelper, - ILogger $logger + ILogger $logger, + ConnectionFactory $connectionFactory ) { parent::__construct( $appName, @@ -67,6 +72,7 @@ class ConfigAPIController extends OCSController { $this->ldapHelper = $ldapHelper; $this->logger = $logger; + $this->connectionFactory = $connectionFactory; } /** @@ -198,6 +204,7 @@ class ConfigAPIController extends OCSController { } $configuration->saveConfiguration(); + $this->connectionFactory->get($configID)->clearCache(); } catch(OCSException $e) { throw $e; } catch (\Exception $e) {