Esempio n. 1
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')) {
Esempio n. 2
0
    $pwEnc = base64_encode($pw);
    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']);
Esempio 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);
                 }
             }
         }
     }
 }