user.get

Description

integer/array user.get(object **parameters**)

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

This method is available to users of any type. Permissions to call the method can be revoked in user role settings. See User roles for more information.

Parameters

(object) Parameters defining the desired output.

The method supports the following parameters.

ParameterTypeDescription
mediaidsstring/arrayReturn only users that use the given media.
mediatypeidsstring/arrayReturn only users that use the given media types.
useridsstring/arrayReturn only users with the given IDs.
usrgrpidsstring/arrayReturn only users that belong to the given user groups.
getAccessflagAdds 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.
selectMediasqueryReturn media used by the user in the medias property.
selectMediatypesqueryReturn media types used by the user in the mediatypes property.
selectUsrgrpsqueryReturn user groups that the user belongs to in the usrgrps property.
selectRolequeryReturn user role in the role property.
sortfieldstring/arraySort the result by the given properties.

Possible values are: userid and alias.
countOutputbooleanThese parameters being common for all get methods are described in detail in the reference commentary.
editableboolean
excludeSearchboolean
filterobject
limitinteger
outputquery
preservekeysboolean
searchobject
searchByAnyboolean
searchWildcardsEnabledboolean
sortorderstring/array
startSearchboolean

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:

  1. {
  2. "jsonrpc": "2.0",
  3. "method": "user.get",
  4. "params": {
  5. "output": "extend"
  6. },
  7. "auth": "038e1d7b1735c6a5436ee9eae095879e",
  8. "id": 1
  9. }

Response:

  1. {
  2. "jsonrpc": "2.0",
  3. "result": [
  4. {
  5. "userid": "1",
  6. "alias": "Admin",
  7. "name": "Zabbix",
  8. "surname": "Administrator",
  9. "url": "",
  10. "autologin": "1",
  11. "autologout": "0",
  12. "lang": "en_GB",
  13. "refresh": "0s",
  14. "theme": "default",
  15. "attempt_failed": "0",
  16. "attempt_ip": "",
  17. "attempt_clock": "0",
  18. "rows_per_page": "50",
  19. "timezone": "default",
  20. "roleid": "3"
  21. },
  22. {
  23. "userid": "2",
  24. "alias": "guest",
  25. "name": "",
  26. "surname": "",
  27. "url": "",
  28. "autologin": "0",
  29. "autologout": "15m",
  30. "lang": "default",
  31. "refresh": "30s",
  32. "theme": "default",
  33. "attempt_failed": "0",
  34. "attempt_ip": "",
  35. "attempt_clock": "0",
  36. "rows_per_page": "50",
  37. "timezone": "default",
  38. "roleid": "4"
  39. },
  40. {
  41. "userid": "3",
  42. "alias": "user",
  43. "name": "Zabbix",
  44. "surname": "User",
  45. "url": "",
  46. "autologin": "0",
  47. "autologout": "0",
  48. "lang": "ru_RU",
  49. "refresh": "15s",
  50. "theme": "dark-theme",
  51. "attempt_failed": "0",
  52. "attempt_ip": "",
  53. "attempt_clock": "0",
  54. "rows_per_page": "100",
  55. "timezone": "default",
  56. "roleid": "1"
  57. }
  58. ],
  59. "id": 1
  60. }

Retrieving user data

Retrieve data of a user with ID “12”.

Request:

  1. {
  2. "jsonrpc": "2.0",
  3. "method": "user.get",
  4. "params": {
  5. "output": ["userid", "alias"],
  6. "selectRole": "extend",
  7. "userids": "12"
  8. },
  9. "auth": "038e1d7b1735c6a5436ee9eae095879e",
  10. "id": 1
  11. }

Response:

  1. {
  2. "jsonrpc": "2.0",
  3. "result": [
  4. {
  5. "userid": "12",
  6. "alias": "John",
  7. "role": {
  8. "roleid": "5",
  9. "name": "Operator",
  10. "type": "1",
  11. "readonly": "0"
  12. }
  13. }
  14. ],
  15. "id": 1
  16. }

See also

Source

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