Ejemplo n.º 1
0
 function testSingleBackend()
 {
     OC_Group::useBackend(new OCA\user_ldap\GROUP_LDAP());
     $group_ldap = new OCA\user_ldap\GROUP_LDAP();
     $this->assertIsA(OC_Group::getGroups(), gettype(array()));
     $this->assertIsA($group_ldap->getGroups(), gettype(array()));
     $this->assertFalse(OC_Group::inGroup('john', 'dosers'), gettype(false));
     $this->assertFalse($group_ldap->inGroup('john', 'dosers'), gettype(false));
     //TODO: check also for expected true result. This backend won't be able to do any modifications, maybe use a dummy for this.
     $this->assertIsA(OC_Group::getUserGroups('john doe'), gettype(array()));
     $this->assertIsA($group_ldap->getUserGroups('john doe'), gettype(array()));
     $this->assertIsA(OC_Group::usersInGroup('campers'), gettype(array()));
     $this->assertIsA($group_ldap->usersInGroup('campers'), gettype(array()));
 }
Ejemplo n.º 2
0
    OCP\Config::setAppValue('user_ldap', 'ldap_agent_password', $pwEnc);
    OC_Appconfig::deleteKey('user_ldap', 'ldap_password');
}
//detect if we can switch on naming guidelines. We won't do it on conflicts.
//it's a bit spaghetti, but hey.
$state = OCP\Config::getSystemValue('ldapIgnoreNamingRules', 'unset');
if ($state == 'unset') {
    OCP\Config::setSystemValue('ldapIgnoreNamingRules', false);
}
// ### SUPPORTED upgrade path starts here ###
//from version 0.2 to 0.3 (0.2.0.x dev version)
$objects = array('user', 'group');
$connector = new \OCA\user_ldap\lib\Connection('user_ldap');
$userBE = new \OCA\user_ldap\USER_LDAP();
$userBE->setConnector($connector);
$groupBE = new \OCA\user_ldap\GROUP_LDAP();
$groupBE->setConnector($connector);
foreach ($objects as $object) {
    $fetchDNSql = 'SELECT `ldap_dn`, `owncloud_name` FROM `*PREFIX*ldap_' . $object . '_mapping` WHERE `directory_uuid` = ""';
    $updateSql = 'UPDATE `*PREFIX*ldap_' . $object . '_mapping` SET `ldap_DN` = ?, `directory_uuid` = ? WHERE `ldap_dn` = ?';
    $query = OCP\DB::prepare($fetchDNSql);
    $res = $query->execute();
    $DNs = $res->fetchAll();
    $updateQuery = OCP\DB::prepare($updateSql);
    foreach ($DNs as $dn) {
        $newDN = mb_strtolower($dn['ldap_dn'], 'UTF-8');
        if ($object == 'user') {
            $uuid = $userBE->getUUID($newDN);
            //fix home folder to avoid new ones depending on the configuration
            $userBE->getHome($dn['owncloud_name']);
        } else {
Ejemplo n.º 3
0
 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);
                 }
             }
         }
     }
 }
Ejemplo n.º 4
0
* 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);
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);
}
if (count($configPrefixes) > 0) {
    // register user backend
    OC_User::useBackend($userBackend);
    OC_Group::useBackend($groupBackend);
}
// add settings page to navigation
$entry = array('id' => 'user_ldap_settings', 'order' => 1, 'href' => OCP\Util::linkTo('user_ldap', 'settings.php'), 'name' => 'LDAP');
OCP\Backgroundjob::addRegularTask('OCA\\user_ldap\\lib\\Jobs', 'updateGroups');
if (OCP\App::isEnabled('user_webdavauth')) {
    OCP\Util::writeLog('user_ldap', 'user_ldap and user_webdavauth are incompatible. You may experience unexpected behaviour', OCP\Util::WARN);
Ejemplo n.º 5
0
* ownCloud - user_ldap
*
* @author Dominik Schmidt
* @copyright 2011 Dominik Schmidt dev@dominik-schmidt.de
*
* 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');
$connector = new OCA\user_ldap\lib\Connection('user_ldap');
$userBackend = new OCA\user_ldap\USER_LDAP();
$userBackend->setConnector($connector);
$groupBackend = new OCA\user_ldap\GROUP_LDAP();
$groupBackend->setConnector($connector);
// register user backend
OC_User::useBackend($userBackend);
OC_Group::useBackend($groupBackend);
// add settings page to navigation
$entry = array('id' => 'user_ldap_settings', 'order' => 1, 'href' => OCP\Util::linkTo('user_ldap', 'settings.php'), 'name' => 'LDAP');
OCP\Backgroundjob::addRegularTask('OCA\\user_ldap\\lib\\Jobs', 'updateGroups');