user.get

Description

integer/array user.get(object parameters)

The method allows to retrieve users according to the given parameters.

Parameters

(object) Parameters defining the desired output.

The method supports the following parameters.

Since Zabbix 5.0.46, when requesting user media or permissions, Admin and User type users may retrieve data only about their own user. For an example, see Retrieving users as Admin.

Parameter Type Description
mediaids string/array Return only users that use the given media.
mediatypeids string/array Return only users that use the given media types.
userids string/array Return only users with the given IDs.
usrgrpids string/array Return only users that belong to the given user groups.
getAccess flag Adds additional information about user permissions.

Adds the following properties for each user:
gui_access - (integer) user's frontend authentication method. Refer to the gui_access property of the user group object for a list of possible values.
debug_mode - (integer) indicates whether debug is enabled for the user. Possible values: 0 - debug disabled, 1 - debug enabled.
users_status - (integer) indicates whether the user is disabled. Possible values: 0 - user enabled, 1 - user disabled.
selectMedias query Return media used by the user in the medias property.
selectMediatypes query Return media types used by the user in the mediatypes property.
selectUsrgrps query Return user groups that the user belongs to in the usrgrps property.

See usergroup.get for restrictions based on user type.
filter object Return only those results that exactly match the given filter.

Accepts an object, where the keys are property names, and the values are either a single value or an array of values to match against.

Does not support properties of text data type.

Possible User object properties for Admin and User type users when requesting data on users in their user group (since Zabbix 5.0.46): userid, alias, name, surname.
output query User object properties to be returned.

Since Zabbix 5.0.46, Admin and User type users may retrieve only the following properties:
- For their own user: userid, alias, attempt_clock, attempt_failed, attempt_ip, autologin, autologout, lang, name, refresh, rows_per_page, surname, theme, type, url.
- For users in their user group: userid, alias, name, surname.

Default: extend.
search object Return results that match the given pattern (case-insensitive).

Accepts an object, where the keys are property names, and the values are strings to search for. If no additional options are given, this will perform a LIKE "%…%" search.

Supports only properties of string and text data type.

Possible User object properties for Admin and User type users when requesting data on users in their user group (since Zabbix 5.0.46): alias, name, surname.
sortfield string/array Sort the result by the given properties.

Possible values are: userid and alias.
countOutput boolean These parameters being common for all get methods are described in detail in the reference commentary.
editable boolean
excludeSearch boolean
limit integer
preservekeys boolean
searchByAny boolean
searchWildcardsEnabled boolean
sortorder string/array
startSearch boolean

Return values

(integer/array) Returns either:

  • an array of objects;
  • the count of retrieved objects, if the countOutput parameter has been used.

Examples

Retrieving users

Retrieve all of the configured users.

Request:

{
           "jsonrpc": "2.0",
           "method": "user.get",
           "params": {
               "output": "extend"
           },
           "auth": "038e1d7b1735c6a5436ee9eae095879e",
           "id": 1
       }

Response:

{
           "jsonrpc": "2.0",
           "result": [
               {
                   "userid": "1",
                   "alias": "Admin",
                   "name": "Zabbix",
                   "surname": "Administrator",
                   "url": "",
                   "autologin": "1",
                   "autologout": "0s",
                   "lang": "ru_RU",
                   "refresh": "0s",
                   "type": "3",
                   "theme": "default",
                   "attempt_failed": "0",
                   "attempt_ip": "",
                   "attempt_clock": "0",
                   "rows_per_page": "50"
               },
               {
                   "userid": "2",
                   "alias": "guest",
                   "name": "Default2",
                   "surname": "User",
                   "url": "",
                   "autologin": "0",
                   "autologout": "15m",
                   "lang": "en_GB",
                   "refresh": "30s",
                   "type": "1",
                   "theme": "default",
                   "attempt_failed": "0",
                   "attempt_ip": "",
                   "attempt_clock": "0",
                   "rows_per_page": "50"
               }
           ],
           "id": 1
       }

Retrieving users as Admin

As an Admin type user, retrieve detailed data about your own user and limited data for users in your user group.

Request:

{
           "jsonrpc": "2.0",
           "method": "user.get",
           "params": {
               "output": "extend",
               "getAccess": true,
               "selectMedias": "extend",
               "selectMediatypes": "extend",
               "selectUsrgrps": "extend"
           },
           "auth": "038e1d7b1735c6a5436ee9eae095879e",
           "id": 1
       }

Response:

{
           "jsonrpc": "2.0",
           "result": [
               {
                   "userid": "1",
                   "alias": "Admin",
                   "name": "Zabbix",
                   "surname": "Administrator",
                   "usrgrps": [
                       {
                           "usrgrpid": "7",
                           "name": "Zabbix administrators",
                           "gui_access": "0",
                           "users_status": "0",
                           "debug_mode": "0"
                       }
                   ]
               },
               {
                   "userid": "3",
                   "alias": "database-admin",
                   "name": "John",
                   "surname": "Doe",
                   "url": "",
                   "autologin": "0",
                   "autologout": "0",
                   "lang": "en_GB",
                   "refresh": "30s",
                   "type": "2",
                   "theme": "default",
                   "attempt_failed": "0",
                   "attempt_ip": "",
                   "attempt_clock": "0",
                   "rows_per_page": "50",
                   "gui_access": "0",
                   "debug_mode": "0",
                   "users_status": "0",
                   "usrgrps": [
                       {
                           "usrgrpid": "7",
                           "name": "Zabbix administrators",
                           "gui_access": "0",
                           "users_status": "0",
                           "debug_mode": "0"
                       }
                   ],
                   "medias": [
                       {
                           "mediaid": "2",
                           "userid": "3",
                           "mediatypeid": "1",
                           "sendto": [
                               "[email protected]"
                           ],
                           "active": "0",
                           "severity": "63",
                           "period": "1-7,00:00-24:00"
                       }
                   ],
                   "mediatypes": [
                       {
                           "mediatypeid": "1",
                           "type": "0",
                           "name": "Email",
                           "status": "0",
                           "description": "",
                           "maxattempts": "3"
                       }
                   ]
               }
           ],
           "id": 1
       }

See also

Source

CUser::get() in ui/include/classes/api/services/CUser.php.