示例#1
0
 * 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/>
 *
 */
// Check user and app status
OCP\JSON::checkAdminUser();
OCP\JSON::checkAppEnabled('user_ldap');
OCP\JSON::callCheck();
$prefix = (string) $_POST['ldap_serverconfig_chooser'];
// Checkboxes are not submitted, when they are unchecked. Set them manually.
// only legacy checkboxes (Advanced and Expert tab) need to be handled here,
// the Wizard-like tabs handle it on their own
$chkboxes = array('ldap_configuration_active', 'ldap_override_main_server', 'ldap_turn_off_cert_check');
foreach ($chkboxes as $boxid) {
    if (!isset($_POST[$boxid])) {
        $_POST[$boxid] = 0;
    }
}
$ldapWrapper = new OCA\user_ldap\lib\LDAP();
$connection = new \OCA\user_ldap\lib\Connection($ldapWrapper, $prefix);
$connection->setConfiguration($_POST);
$connection->saveConfiguration();
OCP\JSON::success();
示例#2
0
            $uuid = $groupBE->getUUID($newDN);
        }
        try {
            $updateQuery->execute(array($newDN, $uuid, $dn['ldap_dn']));
        } catch (Exception $e) {
            \OCP\Util::writeLog('user_ldap', 'Could not update ' . $object . ' ' . $dn['ldap_dn'] . ' in the mappings table. ', \OCP\Util::WARN);
        }
    }
}
function escapeDN($dn)
{
    $aDN = ldap_explode_dn($dn, false);
    unset($aDN['count']);
    foreach ($aDN as $key => $part) {
        $value = substr($part, strpos($part, '=') + 1);
        $escapedValue = strtr($value, array(',' => '\\2c', '=' => '\\3d', '+' => '\\2b', '<' => '\\3c', '>' => '\\3e', ';' => '\\3b', '\\' => '\\5c', '"' => '\\22', '#' => '\\23'));
        $part = str_replace($part, $value, $escapedValue);
    }
    $dn = implode(',', $aDN);
    return $dn;
}
// SUPPORTED UPGRADE FROM Version 0.3 (ownCloud 4.5) to 0.4 (ownCloud 5)
if (!isset($connector)) {
    $connector = new \OCA\user_ldap\lib\Connection();
}
//it is required, that connections do have ldap_configuration_active setting stored in the database
$connector->getConfiguration();
$connector->saveConfiguration();
// we don't save it anymore, was a well-meant bad idea. Clean up database.
$query = OC_DB::prepare('DELETE FROM `*PREFIX*preferences` WHERE `appid` = ? AND `configkey` = ?');
$query->execute(array('user_ldap', 'homedir'));