app.php 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. <?php
  2. /**
  3. * ownCloud - user_ldap
  4. *
  5. * @author Dominik Schmidt
  6. * @copyright 2011 Dominik Schmidt dev@dominik-schmidt.de
  7. *
  8. * This library is free software; you can redistribute it and/or
  9. * modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
  10. * License as published by the Free Software Foundation; either
  11. * version 3 of the License, or any later version.
  12. *
  13. * This library is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU AFFERO GENERAL PUBLIC LICENSE for more details.
  17. *
  18. * You should have received a copy of the GNU Affero General Public
  19. * License along with this library. If not, see <http://www.gnu.org/licenses/>.
  20. *
  21. */
  22. OCP\App::registerAdmin('user_ldap', 'settings');
  23. $configPrefixes = OCA\user_ldap\lib\Helper::getServerConfigurationPrefixes(true);
  24. $ldapWrapper = new OCA\user_ldap\lib\LDAP();
  25. if(count($configPrefixes) === 1) {
  26. $connector = new OCA\user_ldap\lib\Connection($ldapWrapper, $configPrefixes[0]);
  27. $ldapAccess = new OCA\user_ldap\lib\Access($connector, $ldapWrapper);
  28. $userBackend = new OCA\user_ldap\USER_LDAP($ldapAccess);
  29. $groupBackend = new OCA\user_ldap\GROUP_LDAP($ldapAccess);
  30. } else if(count($configPrefixes) > 1) {
  31. $userBackend = new OCA\user_ldap\User_Proxy($configPrefixes, $ldapWrapper);
  32. $groupBackend = new OCA\user_ldap\Group_Proxy($configPrefixes, $ldapWrapper);
  33. }
  34. if(count($configPrefixes) > 0) {
  35. // register user backend
  36. OC_User::useBackend($userBackend);
  37. OC_Group::useBackend($groupBackend);
  38. }
  39. // add settings page to navigation
  40. $entry = array(
  41. 'id' => 'user_ldap_settings',
  42. 'order'=>1,
  43. 'href' => OCP\Util::linkTo( 'user_ldap', 'settings.php' ),
  44. 'name' => 'LDAP'
  45. );
  46. OCP\Backgroundjob::registerJob('OCA\user_ldap\lib\Jobs');
  47. if(OCP\App::isEnabled('user_webdavauth')) {
  48. OCP\Util::writeLog('user_ldap',
  49. 'user_ldap and user_webdavauth are incompatible. You may experience unexpected behaviour',
  50. OCP\Util::WARN);
  51. }