1
0

testConfiguration.php 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. <?php
  2. /**
  3. * @author Arthur Schiwon <blizzz@owncloud.com>
  4. * @author Bart Visscher <bartv@thisnet.nl>
  5. * @author Morris Jobke <hey@morrisjobke.de>
  6. * @author Robin Appelman <icewind@owncloud.com>
  7. * @author Thomas Müller <thomas.mueller@tmit.eu>
  8. *
  9. * @copyright Copyright (c) 2015, ownCloud, Inc.
  10. * @license AGPL-3.0
  11. *
  12. * This code is free software: you can redistribute it and/or modify
  13. * it under the terms of the GNU Affero General Public License, version 3,
  14. * as published by the Free Software Foundation.
  15. *
  16. * This program is distributed in the hope that it will be useful,
  17. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  18. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  19. * GNU Affero General Public License for more details.
  20. *
  21. * You should have received a copy of the GNU Affero General Public License, version 3,
  22. * along with this program. If not, see <http://www.gnu.org/licenses/>
  23. *
  24. */
  25. // Check user and app status
  26. OCP\JSON::checkAdminUser();
  27. OCP\JSON::checkAppEnabled('user_ldap');
  28. OCP\JSON::callCheck();
  29. $l = \OC::$server->getL10N('user_ldap');
  30. $ldapWrapper = new OCA\user_ldap\lib\LDAP();
  31. $connection = new \OCA\user_ldap\lib\Connection($ldapWrapper, '', null);
  32. //needs to be true, otherwise it will also fail with an irritating message
  33. $_POST['ldap_configuration_active'] = 1;
  34. if($connection->setConfiguration($_POST)) {
  35. //Configuration is okay
  36. if($connection->bind()) {
  37. OCP\JSON::success(array('message'
  38. => $l->t('The configuration is valid and the connection could be established!')));
  39. } else {
  40. OCP\JSON::error(array('message'
  41. => $l->t('The configuration is valid, but the Bind failed. Please check the server settings and credentials.')));
  42. }
  43. } else {
  44. OCP\JSON::error(array('message'
  45. => $l->t('The configuration is invalid. Please have a look at the logs for further details.')));
  46. }