app.php 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. <?php
  2. /**
  3. * @copyright Copyright (c) 2016, ownCloud, Inc.
  4. *
  5. * @author Arthur Schiwon <blizzz@arthur-schiwon.de>
  6. * @author Christoph Wurst <christoph@winzerhof-wurst.at>
  7. * @author Dominik Schmidt <dev@dominik-schmidt.de>
  8. * @author Joas Schilling <coding@schilljs.com>
  9. * @author Juan Pablo Villafáñez <jvillafanez@solidgear.es>
  10. * @author Morris Jobke <hey@morrisjobke.de>
  11. * @author Roeland Jago Douma <roeland@famdouma.nl>
  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 = \OC::$server->query(\OCA\User_LDAP\AppInfo\Application::class);
  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->registerNotifierService(\OCA\User_LDAP\Notification\Notifier::class);
  43. $userSession = \OC::$server->getUserSession();
  44. $userPluginManager = \OC::$server->query('LDAPUserPluginManager');
  45. $groupPluginManager = \OC::$server->query('LDAPGroupPluginManager');
  46. $userBackend = new OCA\User_LDAP\User_Proxy(
  47. $configPrefixes, $ldapWrapper, $ocConfig, $notificationManager, $userSession, $userPluginManager
  48. );
  49. $groupBackend = new OCA\User_LDAP\Group_Proxy($configPrefixes, $ldapWrapper, $groupPluginManager);
  50. // register user backend
  51. OC_User::useBackend($userBackend);
  52. // Hook to allow plugins to work on registered backends
  53. OC::$server->getEventDispatcher()->dispatch('OCA\\User_LDAP\\User\\User::postLDAPBackendAdded');
  54. \OC::$server->getGroupManager()->addBackend($groupBackend);
  55. $app->registerBackendDependents();
  56. }
  57. \OCP\Util::connectHook(
  58. '\OCA\Files_Sharing\API\Server2Server',
  59. 'preLoginNameUsedAsUserName',
  60. '\OCA\User_LDAP\Helper',
  61. 'loginName2UserName'
  62. );