wizardDetectorBaseDN.js 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. /**
  2. * SPDX-FileCopyrightText: 2017 Nextcloud GmbH and Nextcloud contributors
  3. * SPDX-FileCopyrightText: 2015 ownCloud, Inc.
  4. * SPDX-License-Identifier: AGPL-3.0-or-later
  5. */
  6. OCA = OCA || {};
  7. (function() {
  8. /**
  9. * @classdesc a Base DN Detector. It executes the auto-detection of the base
  10. * DN by the Nextcloud server, if requirements are met.
  11. *
  12. * @constructor
  13. */
  14. var WizardDetectorBaseDN = OCA.LDAP.Wizard.WizardDetectorGeneric.subClass({
  15. /** @inheritdoc */
  16. init: function() {
  17. this.setTargetKey('ldap_base');
  18. this.runsOnRequest = true;
  19. },
  20. /**
  21. * runs the detector, if specified configuration settings are set and
  22. * base DN is not set.
  23. *
  24. * @param {OCA.LDAP.Wizard.ConfigModel} model
  25. * @param {string} configID - the configuration prefix
  26. * @returns {boolean|jqXHR}
  27. * @abstract
  28. */
  29. run: function(model, configID) {
  30. if( !model.configuration['ldap_host']
  31. || !model.configuration['ldap_port']
  32. )
  33. {
  34. return false;
  35. }
  36. model.notifyAboutDetectionStart(this.getTargetKey());
  37. var params = OC.buildQueryString({
  38. action: 'guessBaseDN',
  39. ldap_serverconfig_chooser: configID
  40. });
  41. return model.callWizard(params, this.processResult, this);
  42. }
  43. });
  44. OCA.LDAP.Wizard.WizardDetectorBaseDN = WizardDetectorBaseDN;
  45. })();