diff --git a/webservice/soap/classes/class.ilSoapUserAdministration.php b/webservice/soap/classes/class.ilSoapUserAdministration.php index 90ec9958bd16..a63b908fa07c 100755 --- a/webservice/soap/classes/class.ilSoapUserAdministration.php +++ b/webservice/soap/classes/class.ilSoapUserAdministration.php @@ -980,35 +980,42 @@ public function searchUser($sid, $a_keyfields, $query_operator, $a_keyvalues, $a */ public function __buildSearchQuery($a_keyfields, $queryOperator, $a_keyvalues) - { - global $DIC; +{ + global $DIC; - $ilDB = $DIC['ilDB']; - $query = array(); + $ilDB = $DIC['ilDB']; + $query = array(); - $allowed_fields = array("firstname","lastname","email","login","matriculation","institution","department","title","ext_account"); + $allowed_fields = array("firstname","lastname","email","login","matriculation","institution","department","title","ext_account"); - foreach ($a_keyfields as $keyfield) { - $keyfield = strtolower($keyfield); + foreach ($a_keyfields as $keyfield) { + $keyfield = strtolower($keyfield); - if (!in_array($keyfield, $allowed_fields)) { - continue; - } + if (!in_array($keyfield, $allowed_fields)) { + continue; + } - $field_query = array(); - foreach ($a_keyvalues as $keyvalue) { - if (strlen($keyvalue) >= 3) { - $field_query []= $keyfield . " like '%" . $keyvalue . "%'"; + $field_query = array(); + foreach ($a_keyvalues as $keyvalue) { + if (strlen($keyvalue) >= 3) { + if ($keyfield === 'matriculation') { + // Use exact match for matriculation + $field_query[] = $ilDB->quoteIdentifier($keyfield) . " = " . $ilDB->quote($keyvalue, 'text'); + } else { + // Use LIKE for other fields + $field_query[] = $ilDB->like($ilDB->quoteIdentifier($keyfield), 'text', '%' . $keyvalue . '%'); } } - if (count($field_query)) { - $query [] = join(" " . strtoupper($queryOperator) . " ", $field_query); - } } - - return count($query) ? " AND ((" . join(") OR (", $query) . "))" : "AND 0"; + if (count($field_query)) { + $query[] = join(" " . strtoupper($queryOperator) . " ", $field_query); + } } + return count($query) ? " AND ((" . join(") OR (", $query) . "))" : "AND 0"; +} + + /** * return user xmls for given user ids (csv separated ids) as xml based on usr dtd.