示例#1
0
 /**
  * @param string $configPrefix
  */
 private function addAccess($configPrefix)
 {
     static $ocConfig;
     static $fs;
     static $log;
     static $avatarM;
     static $userMap;
     static $groupMap;
     static $db;
     static $coreUserManager;
     if (is_null($fs)) {
         $ocConfig = \OC::$server->getConfig();
         $fs = new FilesystemHelper();
         $log = new LogWrapper();
         $avatarM = \OC::$server->getAvatarManager();
         $db = \OC::$server->getDatabaseConnection();
         $userMap = new UserMapping($db);
         $groupMap = new GroupMapping($db);
         $coreUserManager = \OC::$server->getUserManager();
     }
     $userManager = new Manager($ocConfig, $fs, $log, $avatarM, new \OCP\Image(), $db, $coreUserManager);
     $connector = new Connection($this->ldap, $configPrefix);
     $access = new Access($connector, $this->ldap, $userManager);
     $access->setUserMapper($userMap);
     $access->setGroupMapper($groupMap);
     self::$accesses[$configPrefix] = $access;
 }
示例#2
0
 /**
  * @return \OCA\User_LDAP\Group_LDAP|\OCA\User_LDAP\Group_Proxy
  */
 private static function getGroupBE()
 {
     if (!is_null(self::$groupBE)) {
         return self::$groupBE;
     }
     $helper = new Helper();
     $configPrefixes = $helper->getServerConfigurationPrefixes(true);
     $ldapWrapper = new LDAP();
     if (count($configPrefixes) === 1) {
         //avoid the proxy when there is only one LDAP server configured
         $dbc = \OC::$server->getDatabaseConnection();
         $userManager = new Manager(\OC::$server->getConfig(), new FilesystemHelper(), new LogWrapper(), \OC::$server->getAvatarManager(), new \OCP\Image(), $dbc, \OC::$server->getUserManager());
         $connector = new Connection($ldapWrapper, $configPrefixes[0]);
         $ldapAccess = new Access($connector, $ldapWrapper, $userManager, $helper);
         $groupMapper = new GroupMapping($dbc);
         $userMapper = new UserMapping($dbc);
         $ldapAccess->setGroupMapper($groupMapper);
         $ldapAccess->setUserMapper($userMapper);
         self::$groupBE = new \OCA\User_LDAP\Group_LDAP($ldapAccess);
     } else {
         self::$groupBE = new \OCA\User_LDAP\Group_Proxy($configPrefixes, $ldapWrapper);
     }
     return self::$groupBE;
 }