user.get

Description

integer/array user.get(object **parameters**) 此方法允许根据给定的参数检索用户。

Description

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

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

Parameters

(object) 定义所需输出的参数。

该方法支持以下参数。

属性类型说明
mediaidsstring/array只返回用户给定媒体。
mediatypeidsstring/array只返回用户给定媒体类型。
useridsstring/array只返回用户给定ID。
usrgrpidsstring/array只返回用户给定用户组ID。
getAccessflag添加关于用户权限附加信息。

为每个用户添加以下属性:
gui_access - (integer) 用户的前端认证方法。 参考 gui_access 的属性 关于用户组对象 列出可能的值。
debug_mode - (integer) 表明是否为用户启用了调试功能。 可能的值: 0 - 禁用调试, 1 - 开启调试。
users_status - (integer) 表示用户是否禁用。 可能的值: 0 - 用户可用, 1 - 用户禁用。
selectMediasquerymedias 属性返回用户使用的媒体。
selectMediatypesquerymediatypes 属性返回用户使用的媒体类型。
selectUsrgrpsqueryusrgrps 属性返回用户所属的组
sortfieldstring/array根据给定的属性对结果进行排序。

可能的值 : userid and alias.
countOutputboolean这些参数对于所有的get方法是常见的,在 reference commentary中有详细描述.
editableboolean
excludeSearchboolean
filterobject
limitinteger
outputquery
preservekeysboolean
searchobject
searchByAnyboolean
searchWildcardsEnabledboolean
sortorderstring/array
startSearchboolean

返回值

(integer/array)返回:

  • 一个对象数组;

  • 检索对象的计数, 如果 countOutput 参数被使用。

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.
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

检索所有已配置的用户。

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": "0s",
  12. "lang": "ru_RU",
  13. "refresh": "0s",
  14. "type": "3",
  15. "theme": "default",
  16. "attempt_failed": "0",
  17. "attempt_ip": "",
  18. "attempt_clock": "0",
  19. "rows_per_page": "50"
  20. },
  21. {
  22. "userid": "2",
  23. "alias": "guest",
  24. "name": "Default2",
  25. "surname": "User",
  26. "url": "",
  27. "autologin": "0",
  28. "autologout": "15m",
  29. "lang": "en_GB",
  30. "refresh": "30s",
  31. "type": "1",
  32. "theme": "default",
  33. "attempt_failed": "0",
  34. "attempt_ip": "",
  35. "attempt_clock": "0",
  36. "rows_per_page": "50"
  37. }
  38. ],
  39. "id": 1
  40. }

参考

来源

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