2012-05-14 14:58:58 +04:00
|
|
|
<?php
|
|
|
|
|
|
|
|
//from version 0.1 to 0.2
|
2012-05-17 21:33:38 +04:00
|
|
|
|
2012-08-23 20:29:43 +04:00
|
|
|
//ATTENTION
|
|
|
|
//Upgrade from ownCloud 3 (LDAP backend 0.1) to ownCloud 4.5 (LDAP backend 0.3) is not supported!!
|
|
|
|
//You must do upgrade to ownCloud 4.0 first!
|
|
|
|
//The upgrade stuff in the section from 0.1 to 0.2 is just to minimize the bad efffects.
|
|
|
|
|
2012-05-17 21:33:38 +04:00
|
|
|
//settings
|
2012-05-14 14:58:58 +04:00
|
|
|
$pw = OCP\Config::getAppValue('user_ldap', 'ldap_password');
|
|
|
|
if(!is_null($pw)) {
|
|
|
|
$pwEnc = base64_encode($pw);
|
|
|
|
OCP\Config::setAppValue('user_ldap', 'ldap_agent_password', $pwEnc);
|
|
|
|
OC_Appconfig::deleteKey('user_ldap', 'ldap_password');
|
2012-05-17 21:33:38 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
//detect if we can switch on naming guidelines. We won't do it on conflicts.
|
|
|
|
//it's a bit spaghetti, but hey.
|
2012-08-23 20:29:43 +04:00
|
|
|
$state = OCP\Config::getSystemValue('ldapIgnoreNamingRules', 'unset');
|
|
|
|
if($state == 'unset'){
|
2012-05-18 19:38:22 +04:00
|
|
|
OCP\Config::setSystemValue('ldapIgnoreNamingRules', false);
|
2012-05-28 15:57:45 +04:00
|
|
|
}
|
2012-07-02 22:31:07 +04:00
|
|
|
|
2012-08-23 20:29:43 +04:00
|
|
|
// ### SUPPORTED upgrade path starts here ###
|
2012-07-02 22:31:07 +04:00
|
|
|
|
2012-08-23 20:29:43 +04:00
|
|
|
//from version 0.2 to 0.3 (0.2.0.x dev version)
|
2012-07-02 22:31:07 +04:00
|
|
|
$objects = array('user', 'group');
|
|
|
|
|
2012-08-23 20:29:43 +04:00
|
|
|
$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);
|
|
|
|
|
2012-07-02 22:31:07 +04:00
|
|
|
foreach($objects as $object) {
|
2012-08-25 03:52:27 +04:00
|
|
|
$fetchDNSql = 'SELECT `ldap_dn` FROM `*PREFIX*ldap_'.$object.'_mapping`';
|
|
|
|
$updateSql = 'UPDATE `*PREFIX*ldap_'.$object.'_mapping` SET `ldap_DN` = ?, `directory_uuid` = ? WHERE `ldap_dn` = ?';
|
2012-07-02 22:31:07 +04:00
|
|
|
|
|
|
|
$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');
|
2012-08-23 20:29:43 +04:00
|
|
|
if($object == 'user') {
|
|
|
|
$uuid = $userBE->getUUID($newDN);
|
|
|
|
} else {
|
|
|
|
$uuid = $groupBE->getUUID($newDN);
|
|
|
|
}
|
|
|
|
$updateQuery->execute(array($newDN, $uuid, $dn['ldap_dn']));
|
2012-07-02 22:31:07 +04:00
|
|
|
}
|
|
|
|
}
|