# SCIM APIプロビジョニングの使用

本ページでは、Keeperテナントにユーザーをプロビジョニングするための一般的なAPIプラットフォームであるPostmanの使用方法を記載しました。

## 環境の設定 <a href="#setting-up-the-environment" id="setting-up-the-environment"></a>

1. Postmanを開きます。
2. 新しいリクエストを作成します。

* メソッド: **GET**、**POST**、**DELETE**、**PATCH** 、**PUT**
* URL: <https://keepersecurity.com/api/rest/scim/v2/\\>\<node\_id>

{% hint style="info" %}
Keeperテナントのデータセンターに応じて、ドメインが変わります。

米国: keepersecurity.com\
欧州: keepersecurity.eu\
豪州: keepersecurity.com.au\
日本: keepersecurity.jp\
カナダ: keepersecurity.ca\
米国公的機関: govcloud.keepersecurity.us
{% endhint %}

3. ヘッダを設定します。

| キー            | 値                        |
| ------------- | ------------------------ |
| Authorization | Bearer YOUR\_AUTH\_TOKEN |
| Content-Type  | application/scim+json    |

4. ボディを設定します。

* rawを選択し、JSON形式を選択します。

***

## ユーザーの追加 - Users/POST <a href="#adding-a-user-users-post" id="adding-a-user-users-post"></a>

1. HTTPメソッドとURLを設定します。

* ドロップダウンメニューを使用してPOST にHTTPメソッドを設定します。
* ユーザーを追加するためのURLを入力します。

```
https://keepersecurity.com/api/rest/scim/v2/<node_id>/Users
```

{% hint style="info" %}
\<node\_id> は、ユーザーを追加する実際のノード IDに置き換えてください。このノードIDは、Keeper管理コンソールのSCIMセットアップページで確認できます。あるいは、[Keeperコマンダー](https://docs.keeper.io/keeperpam/commander-cli/overview)の「enterprise-info --nodes」コマンドを使用しても確認できます。
{% endhint %}

2. ボディを設定します。

* URLフィールドの下の「Body」タブをクリックします。
* rawを選択し、JSON形式を選択します。
* 以下のように追加するユーザーの詳細を記載したJSONボディを追加します。

```json
{
 "schemas": [
   "urn:ietf:params:scim:schemas:core:2.0:User",
   "urn:ietf:params:scim:schemas:extension:enterprise:2.0:User"
 ],
 "userName": "email@domain.com",
 "displayName": "<user_name>",
 "externalId": "",
 "name": {
   "familyName": "<first_name>",        
   "givenName": "<last_name>"              
 },
 "emails":[
 	{
   "value":"email@domain.com"
 	}
 ],
 "roles": [], // SCIM definition not used in Keeper
 "groups":[
    {
      "value":"<group_id>",
      "$ref":"http://keepersecurity.com/api/rest/scim/v2/<node_id>/<group_id>/scim/Groups",
      "display":"<team_name>"
    }
 ]
}
```

{% hint style="info" %}
グループ オブジェクトの値に \<group\_id> を含めることで、作成時にユーザーをチームに追加することもできます。ユーザーをグループに追加する際に必要な情報は\<group\_id>のみで、「$ref」と「display」はオプションです。
{% endhint %}

3. リクエストを送信します。

#### レスポンスHTTPコード <a href="#response-http-codes" id="response-http-codes"></a>

| HTTPコード |                         | 意味                |
| ------- | ----------------------- | ----------------- |
| 201     | `Created`               | 成功                |
| 409     | `Conflict`              | メールアドレスが既に使用されている |
| 428     | `Precondition Required` | ライセンス数が超過         |

### ユーザーのロック/ロック解除 - Users/PATCH <a href="#locking-unlocking-a-user-users-patch" id="locking-unlocking-a-user-users-patch"></a>

1. メソッドをPATCHに設定し、URLを以下のように設定します。

```
https://keepersecurity.com/api/rest/scim/v2/<node_id>/Users/<user_id>
```

2. JSONリクエストの本文を設定します。

* rawを選択し、JSON形式を選択します。
* 以下のように追加するユーザーの詳細を記載したJSONボディを追加します。

```json
{
  "schemas": [
    "urn:ietf:params:scim:api:messages:2.0:PatchOp"
  ],
  "Operations": [
    {
      "op": "Replace",
      "path": "active",
      "value": "true"
    }
  ]
}
```

{% hint style="info" %}
「value」を必ず「true」 (ロック解除) または「false」 (ロック) に設定してください。
{% endhint %}

3. リクエストを送信します。

***

### ユーザーに関する情報を取得する - Users/GET <a href="#retrieve-information-about-a-user-users-users-get" id="retrieve-information-about-a-user-users-users-get"></a>

1. Postmanを開き、HTTPメソッドをGETに設定します。

* ノード内のすべてのユーザーに関する情報については、以下のURLを使用します。

```
https://keepersecurity.com/api/rest/scim/v2/<node_id>/Users
```

* 特定のユーザーに関する情報を取得するには、ユーザーIDを指定します。

```
https://keepersecurity.com/api/rest/scim/v2/<node_id>/Users/<user_id>
```

2. リクエストを送信します。

ユーザーのフィルタリングにも対応しています。以下はユーザーIDに基づいて検索する例です。

```
https://keepersecurity.com/api/rest/scim/v2/<node_ID>/Users?filter=id+eq+%22<user_ID>%22
```

さらに、startIndexとcountを使用してページネーションを使用することもできます。

```
https://keepersecurity.com/api/rest/scim/v2/<node_id>/Users?startIndex=2&count=200
```

***

### グループとグループ ID の取得 - Groups/GET <a href="#retrieve-groups-and-group-ids-groups-get" id="retrieve-groups-and-group-ids-groups-get"></a>

1. Postmanを開いて新しいGETリクエストを作成します。

* URLを設定します。

```
https://keepersecurity.com/api/rest/scim/v2/<node_id>/Groups
```

2. リクエストを送信します。

#### 期待される応答

応答は、指定されたノードの下にあるすべてのグループの詳細を含むJSONオブジェクトになります。各グループオブジェクト内の「id」フィールドは、グループIDを表します。Keeperでは、グループはKeeperチームオブジェクトによって表されます。IDは KeeperチームUIDです。

```json
{
  "schemas": [
    "urn:ietf:params:scim:api:messages:2.0:ListResponse"
  ],
  "totalResults": 2,
  "Resources": [
    {
      "schemas": [
        "urn:ietf:params:scim:schemas:core:2.0:Group"
      ],
      "id": "group_id_1",
      "displayName": "Group 1",
      "members": []
    },
    {
      "schemas": [
        "urn:ietf:params:scim:schemas:core:2.0:Group"
      ],
      "id": "group_id_2",
      "displayName": "Group 2",
      "members": []
    }
  ]
}
```

{% hint style="info" %}
単一のグループの情報を取得するには、URLの末尾にグループIDを含めます。<https://keepersecurity.com/api/rest/scim/v2/\\>\<node\_id>/Groups/\<group\_id>
{% endhint %}

### チームの作成 - Groups/POST <a href="#creating-a-team-groups-post" id="creating-a-team-groups-post"></a>

1. 新しいリクエストを作成します。

* 「New」をクリックしてから、ドロップダウンメニューから「Request」を選択します。
* すでに開いている場合は「Request」タブをクリックすることもできます。

2. HTTPメソッドとURLを設定します。

* ドロップダウンメニューを使用してHTTPメソッドをPOSTに設定します。
* チームを追加するためのURLを入力します。

```
https://keepersecurity.com/api/rest/scim/v2/<node_id>/Groups
```

3. ボディを設定します。

* URL フィールドの下にある「Boday」タブをクリックします。
* rawを選択し、JSON形式を選択します。
* 以下のように作成するチームの詳細を記載したJSONボディを追加します。

```json
{
     "schemas": [
        "urn:ietf:params:scim:schemas:core:2.0:Group",
        "http://schemas.microsoft.com/2006/11/ResourceManagement/ADSCIM/Group"
     ],
     "displayName": "<team_name>",
     "externalId": "dfe9166c-57f9-417d-83a6-072b5a56a4fe"
}
```

{% hint style="info" %}
「Team Name」を任意のチーム名に置き換えます。
{% endhint %}

4. リクエストを送信します。

* Postmanの「Send」ボタンをクリックしてリクエストを実行します。

***

### チームの削除 - Groups/DELETE <a href="#deleting-a-team-groups-delete" id="deleting-a-team-groups-delete"></a>

1. HTTPメソッドとURLを設定します。

* ドロップダウンメニューを使用して、HTTPメソッドをDELETEに設定します。
* URLを設定します。

```
https://keepersecurity.com/api/rest/scim/v2/<node_id>/Groups/<group_id>
```

2. リクエストを送信します。

***

### チームへのユーザーの追加または削除 - Users/PATCH <a href="#adding-or-removing-a-user-to-a-team-users-patch" id="adding-or-removing-a-user-to-a-team-users-patch"></a>

1. HTTPメソッドとURLを設定します。

* ドロップダウンメニューを使用して、HTTPメソッドをPATCHに設定します。
* URLを設定します。

```
https://keepersecurity.com/api/rest/scim/v2/<node_id>/Groups/<group_id>
```

{% hint style="info" %}
\<node\_id>を実際のノードIDに、\<group\_id>を更新したいチームのIDに置き換えます。
{% endhint %}

2. ボディを設定します。

* URLフィールドの下の「Body」タブをクリックします。
* rawを選択し、JSON形式を選択します。
* 以下のようにチームに追加するユーザーの詳細を記載したJSONボディを追加します。

```json
{
  "Operations": [
    {
      "op": "add",
      "path": "members",
      "value": [
        {
          "value": "<user_id>"
        }
      ]
    }
  ]
}
```

{% hint style="info" %}
「op」の値を「add」に変更すると、ユーザーがチームに追加されます。値を「remove」に変更すると、ユーザーがチームから削除されます。
{% endhint %}

3. リクエストを送信します。

***

### ロールプレフィックスによるロールの取り扱い

KeeperのSCIM連携はUserオブジェクトの `roles` 引数を処理しませんが、ロールプレフィックスを使用することでロールを作成して割り当てできます。

管理コンソールのSCIMプロビジョニング方式の設定でロールマッピングプレフィックスを定義できます。

<figure><img src="https://3468650114-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FeJwa6ByNJ2qindnPknCW%2Fuploads%2F7qz68QCQMLI31NMT3tim%2Fimage.png?alt=media&#x26;token=011b8c20-d280-40cc-b1bc-138f8b462881" alt=""><figcaption></figcaption></figure>

このプレフィックスで作成されたSCIMのGroupオブジェクトは、チームは生成されず、代わりにロールが生成されます。同様に、チーム割り当てと同じリクエストを実行することで、ユーザーにそのロールを割り当てることができます。

```json
{
     "schemas": [
        "urn:ietf:params:scim:schemas:core:2.0:Group",
        "http://schemas.microsoft.com/2006/11/ResourceManagement/ADSCIM/Group"
     ],
     "displayName": "ROLE_group",
     "externalId": "dfe9166c-57f9-417d-83a6-072b5a56a4fe"
}
```

<figure><img src="https://3468650114-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FeJwa6ByNJ2qindnPknCW%2Fuploads%2F06ILm2f0R9RfhuW2Wmnc%2Fimage.png?alt=media&#x26;token=e545549a-0371-4ce2-84e2-165ab733319c" alt=""><figcaption></figcaption></figure>

***

### ユーザー属性の更新 - Users/PUT <a href="#updating-user-attributes-users-put" id="updating-user-attributes-users-put"></a>

1. 新しいリクエストを作成します。

* 「New」をクリックし、ドロップダウンメニューから「Request」を選択します。
* すでに開いている場合は、「Request」タブをクリックすることもできます。

2. HTTPメソッドとURLを設定します。

* HTTPメソッドをPUTに設定します。
* 以下のURLを使用します。

```
https://keepersecurity.com/api/rest/scim/v2/<node_id>/Users/<user_id>
```

3. ボディを設定します。

* URLフィールドの下の「Body」タブをクリックします。
* rawを選択し、JSON形式を選択します。

以下は、ユーザー情報を更新するためのJSONボディの例です。

```json
{
  "schemas": [
    "urn:ietf:params:scim:schemas:core:2.0:User"
  ],
  "userName": "email@domain.com",
  "displayName": "<Desired display name>",
  "externalId":"",  
  "name": {
     "familyName": "<first_name>",        
     "givenName": "<last_name>"              
  },
  "emails": [
    {
      "value": "email@domain.com",
      "primary": true
    }
  ],
  "roles":[], // SCIM definition not used in Keeper
  "groups":[
    {
      "value":"<group_id>",
      "$ref":"http://keepersecurity.com/api/rest/scim/v2/<node_id>/<group_id>/scim/Groups",
      "display":"<group_name>"
    }
 ],
  "active": true
}
```

{% hint style="warning" %}
「active」フラグをfalseに変更するとユーザーアカウントがロックされ、trueに変更するとアカウントのロックが解除されます。
{% endhint %}

4. リクエストを送信します。

* Postmanの「Send」ボタンをクリックしてリクエストを実行します。

### ユーザー属性の更新 - Users/Patch <a href="#updating-user-attributes-users-patch" id="updating-user-attributes-users-patch"></a>

```json
{
  "schemas": [
    "urn:ietf:params:scim:api:messages:2.0:PatchOp"
  ],
  "Operations": [
    {
      "op": "replace",
      "path": "userName",
      "value": "<user_name>"
    },
    {
      "op": "replace",
      "path": "displayName",
      "value": "<display_name>"
    },
    {
      "op": "replace",
      "path": "externalId",
      "value": "<external_Id>"
    },
    {
      "op": "replace",
      "path": "name.familyName",
      "value": "<last_name>"
    },
    {
      "op": "replace",
      "path": "name.givenName",
      "value": "<first_name>"
    },
    {
      "op": "replace",
      "path": "active",
      "value": false
    },
    {
      "op": "add",
      "path": "groups",
      "value": [
        {
          "$ref": "https://example.com/v2/Users/1743756723210",
          "value": "<group_id>"
        }
      ]
    },
    {
      "op": "remove",
      "path": "groups",
      "value": [
        {
          "$ref": "https://example.com/v2/Users/<user_id>",
          "value": "<group_id>"
        }
      ]
    }
  ]
}
```

***

### SCIM関連エンドポイント/GET <a href="#scim-related-endpoints-get" id="scim-related-endpoints-get"></a>

* HTTPメソッドをGetに設定します。
* 以下のURLを使用します。

ServiceProviderConfig / ResourceTypes (User/Groups) / Schemas

```
https://keepersecurity.com/api/rest/scim/v2/<node_id>/ServiceProviderConfig
```

```
https://keepersecurity.com/api/rest/scim/v2/<node_id>/ResourceTypes/User
```

```
https://keepersecurity.com/api/rest/scim/v2/<node_id>/ResourceTypes/Group
```

```
https://keepersecurity.com/api/rest/scim/v2/<node_id>/Schemas/urn:ietf:params:scim:schemas:core:2.0:User
```

```
https://keepersecurity.com/api/rest/scim/v2/<node_id>/Schemas
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.keeper.io/jp/enterprise-guide/user-and-team-provisioning/automated-provisioning-with-scim/using-scim-api-provisioning.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
