Skip to content

Commit 7620249

Browse files
committed
fix(ldapfield): raw condition expression must be replaced by array
1 parent 4a0a719 commit 7620249

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

inc/field/ldapselectfield.class.php

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,9 @@
3636
use AuthLDAP;
3737
use Dropdown;
3838
use Exception;
39+
use Entity;
3940
use Html;
41+
use QuerySubQuery;
4042
use Session;
4143
use RuleRightParameter;
4244

@@ -53,10 +55,17 @@ public function getDesignSpecializationField(): array {
5355
if ($ldap_values === null) {
5456
$ldap_values = [];
5557
}
56-
$current_entity = $_SESSION['glpiactive_entity'];
58+
$current_entity = Session::getActiveEntity();
5759
$auth_ldap_condition = '';
5860
if ($current_entity != 0) {
59-
$auth_ldap_condition = "glpi_authldaps.id = (select glpi_entities.authldaps_id from glpi_entities where id=${current_entity})";
61+
$entityTable = Entity::getTable();
62+
$auth_ldap_condition = [
63+
'glpi_authldaps.id' => new QuerySubQuery([
64+
'SELECT' => "$entityTable.authldaps_id",
65+
'FROM' => $entityTable,
66+
'WHERE' => ['id' => $current_entity],
67+
])
68+
];
6069
}
6170
$field = Dropdown::show(AuthLDAP::class, [
6271
'name' => 'ldap_auth',

0 commit comments

Comments
 (0)