setConfiguration.php 967 B

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