Source
['if' => ['field' => 'path', 'in' => 'displayName'], 'type' => API_STRING_UTF8, 'flags' => API_REQUIRED, 'in' => implode(',', ['replace', 'Replace'])],
<?php
/*
** Copyright (C) 2001-2025 Zabbix SIA
**
** This program is free software: you can redistribute it and/or modify it under the terms of
** the GNU Affero General Public License as published by the Free Software Foundation, version 3.
**
** 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 along with this program.
** If not, see <https://www.gnu.org/licenses/>.
**/
namespace SCIM\services;
use API as APIRPC;
use APIException;
use CAuthenticationHelper;
use CApiInputValidator;
use CProvisioning;
use DB;
use SCIM\ScimApiService;
class Group extends ScimApiService {
public const SCIM_SCHEMA = 'urn:ietf:params:scim:schemas:core:2.0:Group';
/**
* Return all groups information.
* When filter 'id' or 'displayName' is defined will return information for single group.
* If group not found, for filter 'id', will return ZBX_API_ERROR_NO_ENTITY error.
*
* @param array $options
* @param string $options['id'] (optional) SCIM group id.
* @param string $options['displayName'] (optional) SCIM group display name.
*
* @return array Array of groups data when no filters are defined. Single group data for defined filter.
*/
public function get(array $options = []): array {
$this->validateGet($options);
if (array_key_exists('id', $options)) {
$db_scim_group = DB::select('scim_group', [
'output' => ['name'],
'scim_groupids' => $options['id']
]);
if (!$db_scim_group) {
self::exception(ZBX_API_ERROR_NO_ENTITY, 'No permissions to referred object or it does not exist!');
}
$users = $this->getUsersByGroupIds([$options['id']]);
return [
'id' => $options['id'],
'displayName' => $db_scim_group[0]['name'],
'users' => $users[$options['id']]
];
}
if (array_key_exists('displayName', $options)) {
$db_scim_group = DB::select('scim_group', [
'output' => ['name', 'scim_groupid'],
'filter' => ['name' => $options['displayName']]
]);
if (!$db_scim_group) {
return [];
}
$users = $this->getUsersByGroupIds([$db_scim_group[0]['scim_groupid']]);
return [
'id' => $db_scim_group[0]['scim_groupid'],
'displayName' => $db_scim_group[0]['name'],
'users' => $users
];
}
$db_scim_groups = DB::select('scim_group', [
'output' => ['name'],
'preservekeys' => true
]);
if ($db_scim_groups) {
$groups_users = $this->getUsersByGroupIds(array_keys($db_scim_groups));
foreach ($groups_users as $groupid => $users) {