示例#1
0
文件: otp.php 项目: DerRiFlo/user-otp
 public static function registerBackends($usedBackends)
 {
     //OC_Log::write('OC_USER_OTP', __FUNCTION__.'().', OC_Log::DEBUG);
     if (self::$_backends === null) {
         foreach ($usedBackends as $backend) {
             OC_Log::write('user_otp', 'instance ' . $backend . ' backend.', OC_Log::DEBUG);
             self::$_backends[$backend] = new $backend();
             if (self::$_backends[$backend] instanceof OCA\user_ldap\USER_LDAP || self::$_backends[$backend] instanceof OCA\user_ldap\User_Proxy) {
                 OC_Log::write('OC_USER_OTP az', __FUNCTION__ . '().', OC_Log::DEBUG);
                 $configPrefixes = OCA\user_ldap\lib\Helper::getServerConfigurationPrefixes(true);
                 if (count($configPrefixes) == 1) {
                     $connector = new OCA\user_ldap\lib\Connection($configPrefixes[0]);
                     $userBackend = new OCA\user_ldap\USER_LDAP();
                     $userBackend->setConnector($connector);
                     $groupBackend = new OCA\user_ldap\GROUP_LDAP();
                     $groupBackend->setConnector($connector);
                 } else {
                     $userBackend = new OCA\user_ldap\User_Proxy($configPrefixes);
                     $groupBackend = new OCA\user_ldap\Group_Proxy($configPrefixes);
                 }
                 self::$_backends[$backend] = $userBackend;
                 if (count($configPrefixes) > 0) {
                     // register user backend
                     //~ OC_User::useBackend($userBackend);
                     OC_Group::useBackend($groupBackend);
                 }
             }
         }
     }
 }
 private function connect()
 {
     if (!$this->connected) {
         $helper = new \OCA\user_ldap\lib\Helper();
         $configPrefixes = $helper->getServerConfigurationPrefixes(true);
         $this->ldap = new \OCA\user_ldap\lib\LDAP();
         $dbc = \OC::$server->getDatabaseConnection();
         $this->usermanager = new \OCA\user_ldap\lib\user\Manager(\OC::$server->getConfig(), new \OCA\user_ldap\lib\FilesystemHelper(), new \OCA\user_ldap\lib\LogWrapper(), \OC::$server->getAvatarManager(), new \OCP\Image(), $dbc);
         $this->connection = new \OCA\user_ldap\lib\Connection($this->ldap, $configPrefixes[0]);
         $this->access = new \OCA\user_ldap\lib\Access($this->connection, $this->ldap, $this->usermanager);
         $this->access->setUserMapper(new \OCA\User_LDAP\Mapping\UserMapping($dbc));
         $this->access->setGroupMapper(new \OCA\User_LDAP\Mapping\GroupMapping($dbc));
         $this->connected = true;
     }
 }
示例#3
0
文件: app.php 项目: kenwi/core
 * This code is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Affero General Public License, version 3,
 * as published by the Free Software Foundation.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 * GNU Affero General Public License for more details.
 *
 * You should have received a copy of the GNU Affero General Public License, version 3,
 * along with this program.  If not, see <http://www.gnu.org/licenses/>
 *
 */
OCP\App::registerAdmin('user_ldap', 'settings');
$helper = new \OCA\user_ldap\lib\Helper();
$configPrefixes = $helper->getServerConfigurationPrefixes(true);
$ldapWrapper = new OCA\user_ldap\lib\LDAP();
$ocConfig = \OC::$server->getConfig();
if (count($configPrefixes) === 1) {
    $dbc = \OC::$server->getDatabaseConnection();
    $userManager = new OCA\user_ldap\lib\user\Manager($ocConfig, new OCA\user_ldap\lib\FilesystemHelper(), new OCA\user_ldap\lib\LogWrapper(), \OC::$server->getAvatarManager(), new \OCP\Image(), $dbc);
    $connector = new OCA\user_ldap\lib\Connection($ldapWrapper, $configPrefixes[0]);
    $ldapAccess = new OCA\user_ldap\lib\Access($connector, $ldapWrapper, $userManager);
    $ldapAccess->setUserMapper(new OCA\User_LDAP\Mapping\UserMapping($dbc));
    $ldapAccess->setGroupMapper(new OCA\User_LDAP\Mapping\GroupMapping($dbc));
    $userBackend = new OCA\user_ldap\USER_LDAP($ldapAccess, $ocConfig);
    $groupBackend = new OCA\user_ldap\GROUP_LDAP($ldapAccess);
} else {
    if (count($configPrefixes) > 1) {
        $userBackend = new OCA\user_ldap\User_Proxy($configPrefixes, $ldapWrapper, $ocConfig);
        $groupBackend = new OCA\user_ldap\Group_Proxy($configPrefixes, $ldapWrapper);
示例#4
0
文件: update.php 项目: rosarion/core
 *
 * @copyright Copyright (c) 2015, ownCloud, Inc.
 * @license AGPL-3.0
 *
 * This code is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Affero General Public License, version 3,
 * as published by the Free Software Foundation.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 * GNU Affero General Public License for more details.
 *
 * You should have received a copy of the GNU Affero General Public License, version 3,
 * along with this program.  If not, see <http://www.gnu.org/licenses/>
 *
 */
$installedVersion = \OC::$server->getConfig()->getAppValue('user_ldap', 'installed_version');
if (version_compare($installedVersion, '0.6.1', '<')) {
    \OC::$server->getConfig()->setAppValue('user_ldap', 'enforce_home_folder_naming_rule', false);
}
if (version_compare($installedVersion, '0.6.2', '<')) {
    // Remove LDAP case insensitive setting from DB as it is no longer beeing used.
    $helper = new \OCA\user_ldap\lib\Helper();
    $prefixes = $helper->getServerConfigurationPrefixes();
    foreach ($prefixes as $prefix) {
        \OC::$server->getConfig()->deleteAppValue('user_ldap', $prefix . "ldap_nocase");
    }
}
OCP\Backgroundjob::registerJob('OCA\\user_ldap\\lib\\Jobs');
OCP\Backgroundjob::registerJob('\\OCA\\User_LDAP\\Jobs\\CleanUp');
示例#5
0
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
* License as published by the Free Software Foundation; either
* version 3 of the License, or any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
* GNU AFFERO GENERAL PUBLIC LICENSE for more details.
*
* You should have received a copy of the GNU Affero General Public
* License along with this library.  If not, see <http://www.gnu.org/licenses/>.
*
*/
OCP\App::registerAdmin('user_ldap', 'settings');
$configPrefixes = OCA\user_ldap\lib\Helper::getServerConfigurationPrefixes(true);
$ldapWrapper = new OCA\user_ldap\lib\LDAP();
if (count($configPrefixes) === 1) {
    $connector = new OCA\user_ldap\lib\Connection($ldapWrapper, $configPrefixes[0]);
    $ldapAccess = new OCA\user_ldap\lib\Access($connector, $ldapWrapper);
    $userBackend = new OCA\user_ldap\USER_LDAP($ldapAccess);
    $groupBackend = new OCA\user_ldap\GROUP_LDAP($ldapAccess);
} else {
    if (count($configPrefixes) > 1) {
        $userBackend = new OCA\user_ldap\User_Proxy($configPrefixes, $ldapWrapper);
        $groupBackend = new OCA\user_ldap\Group_Proxy($configPrefixes, $ldapWrapper);
    }
}
if (count($configPrefixes) > 0) {
    // register user backend
    OC_User::useBackend($userBackend);
<?php

// Check user and app status
OCP\JSON::checkAdminUser();
OCP\JSON::checkAppEnabled('user_ldap');
OCP\JSON::callCheck();
$helper = new \OCA\user_ldap\lib\Helper();
$serverConnections = $helper->getServerConfigurationPrefixes();
sort($serverConnections);
$lk = array_pop($serverConnections);
$ln = intval(str_replace('s', '', $lk));
$nk = 's' . str_pad($ln + 1, 2, '0', STR_PAD_LEFT);
$resultData = array('configPrefix' => $nk);
$newConfig = new \OCA\user_ldap\lib\Configuration($nk, false);
if (isset($_POST['copyConfig'])) {
    $originalConfig = new \OCA\user_ldap\lib\Configuration($_POST['copyConfig']);
    $newConfig->setConfiguration($originalConfig->getConfiguration());
} else {
    $configuration = new \OCA\user_ldap\lib\Configuration($nk, false);
    $newConfig->setConfiguration($configuration->getDefaults());
    $resultData['defaults'] = $configuration->getDefaults();
}
$newConfig->saveConfiguration();
OCP\JSON::success($resultData);