user.get

説明

integer/array user.get(object parameters)

このメソッドを使用すると、指定されたパラメーターに従ってユーザー情報を取得できます。

このメソッドはどのタイプのユーザーでも利用可能です。このメソッドを呼び出す権限は、ユーザーロール設定で取り消すことができます。詳しくはユーザーの役割を参照してください。

パラメータ

(object) 目的の出力を定義するパラメーター。

このメソッドは、次のパラメーターをサポートします。

パラメータ タイプ 説明
mediaids string/array 指定されたメディアを使用するユーザーのみを返します
mediatypeids string/array 指定されたメディアタイプを使用するユーザーのみを返します
userids string/array 指定されたIDを持つユーザーのみを返します
usrgrpids string/array 指定されたユーザーグループに属するユーザーのみを返します
getAccess flag ユーザー権限に関する追加情報

ユーザーごとに次のプロパティを追加
gui_access - (integer)ユーザーのフロントエンド認証方法。 値のリストはユーザーグループオブジェクトgui_accessプロパティを参照してください。
debug_mode - (integer)ユーザーに対してデバッグが有効になっているかどうか。 値:0 - 無効,1 - 有効
users_status - (integer)ユーザーが無効になっているかどうか。 値:0 - 有効,1 - 無効
selectMedias query mediasプロパティでユーザーが使用したメディアを返します
selectMediatypes query mediatypesプロパティでユーザーが使用するメディアタイプを返します
selectUsrgrps query usrgrpsプロパティで、ユーザーが属するユーザーグループを返します
selectRole query roleプロパティでユーザーロールを返します
sortfield string/array 指定されたプロパティで結果を並べ替えます

利用可能な値はuseridusernameです
countOutput boolean すべてのgetメソッドに共通するこれらのパラメーターについてはリファレンス解説ページで詳しく説明されています。
editable boolean
excludeSearch boolean
filter object
limit integer
output query
preservekeys boolean
search object
searchByAny boolean
searchWildcardsEnabled boolean
sortorder string/array
startSearch boolean

戻り値

(integer/array) 次のいずれかを返します:

  • オブジェクトの配列
  • countOutputパラメータが使用されている場合、取得されたオブジェクトの数

ユーザーの取得

設定済みの全ユーザーを取得します

Request:

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

Response:

{
    "jsonrpc": "2.0",
    "result": [
        {
            "userid": "1",
            "username": "Admin",
            "name": "Zabbix",
            "surname": "Administrator",
            "url": "",
            "autologin": "1",
            "autologout": "0",
            "lang": "en_GB",
            "refresh": "0s",
            "theme": "default",
            "attempt_failed": "0",
            "attempt_ip": "",
            "attempt_clock": "0",
            "rows_per_page": "50",
            "timezone": "default",
            "roleid": "3"
        },
        {
            "userid": "2",
            "username": "guest",
            "name": "",
            "surname": "",
            "url": "",
            "autologin": "0",
            "autologout": "15m",
            "lang": "default",
            "refresh": "30s",
            "theme": "default",
            "attempt_failed": "0",
            "attempt_ip": "",
            "attempt_clock": "0",
            "rows_per_page": "50",
            "timezone": "default",
            "roleid": "4"
        },
        {
            "userid": "3",
            "username": "user",
            "name": "Zabbix",
            "surname": "User",
            "url": "",
            "autologin": "0",
            "autologout": "0",
            "lang": "ru_RU",
            "refresh": "15s",
            "theme": "dark-theme",
            "attempt_failed": "0",
            "attempt_ip": "",
            "attempt_clock": "0",
            "rows_per_page": "100",
            "timezone": "default",
            "roleid": "1"
        }
    ],
    "id": 1
}

管理者 としてユーザーを取得する

管理者 タイプのユーザーとして、自分のユーザーに関する詳細データと、ユーザーグループ内のユーザーの限定データを取得します。

Request:

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

Response:

{
    "jsonrpc": "2.0",
    "result": [
        {
            "userid": "1",
            "username": "Admin",
            "name": "Zabbix",
            "surname": "Administrator",
            "usrgrps": [
                {
                    "usrgrpid": "7",
                    "name": "Zabbix administrators",
                    "gui_access": "0",
                    "users_status": "0",
                    "debug_mode": "0"
                }
            ]
        },
        {
            "userid": "3",
            "username": "database-admin",
            "name": "John",
            "surname": "Doe",
            "url": "",
            "autologin": "0",
            "autologout": "0",
            "lang": "default",
            "refresh": "30s",
            "theme": "default",
            "attempt_failed": "0",
            "attempt_ip": "",
            "attempt_clock": "0",
            "rows_per_page": "50",
            "timezone": "default",
            "roleid": "2",
            "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"
                }
            ],
            "role": {
                "roleid": "2",
                "name": "Admin role",
                "type": "2",
                "readonly": "0"
            }
        }
    ],
    "id": 1
}

ユーザーデータ取得

ID"12"のユーザーのデータを取得します

Request:

{
    "jsonrpc": "2.0",
    "method": "user.get",
    "params": {
        "output": ["userid", "username"],
        "selectRole": "extend",
        "userids": "12"
    },
    "auth": "038e1d7b1735c6a5436ee9eae095879e",
    "id": 1
}

Response:

{
  "jsonrpc": "2.0",
  "result": [
      {
          "userid": "12",
          "username": "John",
          "role": {
              "roleid": "5",
              "name": "Operator",
              "type": "1",
              "readonly": "0"
          }
      }
  ],
  "id": 1
}

参照

ソース

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