LDAP: make queries compatible also with PostgreSQL
This commit is contained in:
parent
f4577bf00c
commit
7ec3e37199
|
@ -366,19 +366,24 @@ class OC_LDAP {
|
||||||
$table = self::getMapTable($isUser);
|
$table = self::getMapTable($isUser);
|
||||||
$dn = self::sanitizeDN($dn);
|
$dn = self::sanitizeDN($dn);
|
||||||
|
|
||||||
$sqliteAdjustment = '';
|
$sqlAdjustment = '';
|
||||||
$dbtype = OCP\Config::getSystemValue('dbtype');
|
$dbtype = OCP\Config::getSystemValue('dbtype');
|
||||||
if(($dbtype == 'sqlite') || ($dbtype == 'sqlite3')) {
|
if($dbtype == 'mysql') {
|
||||||
$sqliteAdjustment = 'OR';
|
$sqlAdjustment = 'FROM dual';
|
||||||
}
|
}
|
||||||
|
|
||||||
$insert = OCP\DB::prepare('
|
$insert = OCP\DB::prepare('
|
||||||
INSERT '.$sqliteAdjustment.' IGNORE INTO '.$table.'
|
INSERT INTO '.$table.' (ldap_dn, owncloud_name)
|
||||||
(ldap_dn, owncloud_name)
|
SELECT ?,?
|
||||||
VALUES (?,?)
|
'.$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);
|
return !OCP\DB::isError($res);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue