1
0

app.php 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. <?php
  2. /**
  3. * @copyright Copyright (c) 2016, ownCloud, Inc.
  4. *
  5. * @author Arthur Schiwon <blizzz@arthur-schiwon.de>
  6. * @author Dominik Schmidt <dev@dominik-schmidt.de>
  7. * @author Joas Schilling <coding@schilljs.com>
  8. * @author Juan Pablo Villafáñez <jvillafanez@solidgear.es>
  9. * @author Morris Jobke <hey@morrisjobke.de>
  10. * @author Roeland Jago Douma <roeland@famdouma.nl>
  11. * @author Roger Szabo <roger.szabo@web.de>
  12. * @author Vinicius Cubas Brand <vinicius@eita.org.br>
  13. *
  14. * @license AGPL-3.0
  15. *
  16. * This code is free software: you can redistribute it and/or modify
  17. * it under the terms of the GNU Affero General Public License, version 3,
  18. * as published by the Free Software Foundation.
  19. *
  20. * This program is distributed in the hope that it will be useful,
  21. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  22. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  23. * GNU Affero General Public License for more details.
  24. *
  25. * You should have received a copy of the GNU Affero General Public License, version 3,
  26. * along with this program. If not, see <http://www.gnu.org/licenses/>
  27. *
  28. */
  29. \OC::$server->registerService('LDAPUserPluginManager', function() {
  30. return new OCA\User_LDAP\UserPluginManager();
  31. });
  32. \OC::$server->registerService('LDAPGroupPluginManager', function() {
  33. return new OCA\User_LDAP\GroupPluginManager();
  34. });
  35. $app = new \OCA\User_LDAP\AppInfo\Application();
  36. $helper = new \OCA\User_LDAP\Helper(\OC::$server->getConfig());
  37. $configPrefixes = $helper->getServerConfigurationPrefixes(true);
  38. if(count($configPrefixes) > 0) {
  39. $ldapWrapper = new OCA\User_LDAP\LDAP();
  40. $ocConfig = \OC::$server->getConfig();
  41. $notificationManager = \OC::$server->getNotificationManager();
  42. $notificationManager->registerNotifier(function() {
  43. return new \OCA\User_LDAP\Notification\Notifier(
  44. \OC::$server->getL10NFactory()
  45. );
  46. }, function() {
  47. $l = \OC::$server->getL10N('user_ldap');
  48. return [
  49. 'id' => 'user_ldap',
  50. 'name' => $l->t('LDAP user and group backend'),
  51. ];
  52. });
  53. $userSession = \OC::$server->getUserSession();
  54. $userPluginManager = \OC::$server->query('LDAPUserPluginManager');
  55. $groupPluginManager = \OC::$server->query('LDAPGroupPluginManager');
  56. $userBackend = new OCA\User_LDAP\User_Proxy(
  57. $configPrefixes, $ldapWrapper, $ocConfig, $notificationManager, $userSession, $userPluginManager
  58. );
  59. $groupBackend = new OCA\User_LDAP\Group_Proxy($configPrefixes, $ldapWrapper, $groupPluginManager);
  60. // register user backend
  61. OC_User::useBackend($userBackend);
  62. // Hook to allow plugins to work on registered backends
  63. OC::$server->getEventDispatcher()->dispatch('OCA\\User_LDAP\\User\\User::postLDAPBackendAdded');
  64. \OC::$server->getGroupManager()->addBackend($groupBackend);
  65. $app->registerBackendDependents();
  66. }
  67. \OCP\Util::connectHook(
  68. '\OCA\Files_Sharing\API\Server2Server',
  69. 'preLoginNameUsedAsUserName',
  70. '\OCA\User_LDAP\Helper',
  71. 'loginName2UserName'
  72. );