Skip to content
Snippets Groups Projects
Commit 7ec3e371 authored by Arthur Schiwon's avatar Arthur Schiwon
Browse files

LDAP: make queries compatible also with PostgreSQL

parent f4577bf0
No related branches found
No related tags found
No related merge requests found
......@@ -366,19 +366,24 @@ class OC_LDAP {
$table = self::getMapTable($isUser);
$dn = self::sanitizeDN($dn);
$sqliteAdjustment = '';
$sqlAdjustment = '';
$dbtype = OCP\Config::getSystemValue('dbtype');
if(($dbtype == 'sqlite') || ($dbtype == 'sqlite3')) {
$sqliteAdjustment = 'OR';
if($dbtype == 'mysql') {
$sqlAdjustment = 'FROM dual';
}
$insert = OCP\DB::prepare('
INSERT '.$sqliteAdjustment.' IGNORE INTO '.$table.'
(ldap_dn, owncloud_name)
VALUES (?,?)
INSERT INTO '.$table.' (ldap_dn, owncloud_name)
SELECT ?,?
'.$sqlAdjustment.'
WHERE NOT EXISTS (
SELECT 1
FROM '.$table.'
WHERE ldap_dn = ?
AND owncloud_name = ? )
');
$res = $insert->execute(array($dn, $ocname));
$res = $insert->execute(array($dn, $ocname, $dn, $ocname));
return !OCP\DB::isError($res);
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment