setName('ldap:set-config') ->setDescription('modifies an LDAP configuration') ->addArgument( 'configID', InputArgument::REQUIRED, 'the configuration ID' ) ->addArgument( 'configKey', InputArgument::REQUIRED, 'the configuration key' ) ->addArgument( 'configValue', InputArgument::REQUIRED, 'the new configuration value' ) ; } protected function execute(InputInterface $input, OutputInterface $output): int { $helper = new Helper(\OC::$server->getConfig(), \OC::$server->getDatabaseConnection()); $availableConfigs = $helper->getServerConfigurationPrefixes(); $configID = $input->getArgument('configID'); if (!in_array($configID, $availableConfigs)) { $output->writeln('Invalid configID'); return self::FAILURE; } $this->setValue( $configID, $input->getArgument('configKey'), $input->getArgument('configValue') ); return self::SUCCESS; } /** * save the configuration value as provided */ protected function setValue(string $configID, string $key, string $value): void { $configHolder = new Configuration($configID); $configHolder->$key = $value; $configHolder->saveConfiguration(); $connectionFactory = new ConnectionFactory(new LDAP()); $connectionFactory->get($configID)->clearCache(); } }