setConfiguration.php 956 B

123456789101112131415161718192021222324252627282930
  1. <?php
  2. /**
  3. * SPDX-FileCopyrightText: 2018-2024 Nextcloud GmbH and Nextcloud contributors
  4. * SPDX-FileCopyrightText: 2016 ownCloud, Inc.
  5. * SPDX-License-Identifier: AGPL-3.0-only
  6. */
  7. // Check user and app status
  8. \OC_JSON::checkAdminUser();
  9. \OC_JSON::checkAppEnabled('user_ldap');
  10. \OC_JSON::callCheck();
  11. $prefix = (string)$_POST['ldap_serverconfig_chooser'];
  12. // Checkboxes are not submitted, when they are unchecked. Set them manually.
  13. // only legacy checkboxes (Advanced and Expert tab) need to be handled here,
  14. // the Wizard-like tabs handle it on their own
  15. $chkboxes = ['ldap_configuration_active', 'ldap_override_main_server',
  16. 'ldap_turn_off_cert_check'];
  17. foreach ($chkboxes as $boxid) {
  18. if (!isset($_POST[$boxid])) {
  19. $_POST[$boxid] = 0;
  20. }
  21. }
  22. $ldapWrapper = new OCA\User_LDAP\LDAP();
  23. $connection = new \OCA\User_LDAP\Connection($ldapWrapper, $prefix);
  24. $connection->setConfiguration($_POST);
  25. $connection->saveConfiguration();
  26. \OC_JSON::success();