---
title: "ユーザー管理の自動化"
slug: "automate-user-management"
abstract: "REST API、スクリプトAPI、またはウェブSDKを使ってユーザーアカウント管理を自動化する方法。"
---
# ユーザー管理の自動化

Content Hubはすべてのユーザーの行動を追跡・記録し、同時進行イベントと連携して詳細な追跡を行う活動を記録します。これは特にオンボーディングおよびオフボーディング時に重要で、ユーザーの権限管理が不可欠です。また、データアクセスやユーザー操作をログで追跡し、監査やセキュリティ目的で [活動](https://doc.sitecore.com/ch/en/users/content-hub/user-logs.html) 記録を提供することでGDPR準拠もサポートします。

> !注Sitecore Content Hubでは、各ユーザーはユーザー名、パスワード、プロフィールで一意に識別されます。他の設定と合わせて、プロファイルはユーザーが実行できるタスク、閲覧可能なデータ、データで何ができるかを決定します。

複数のユーザーアカウントを同時に扱いやすくするために、以下のいずれかのオプションを使ってユーザーアカウント管理を自動化できます。

## REST API

[REST APIを使えば](https://doc.sitecore.com/ch/ja/developers/cloud-dev/user-1523369.html "User")ユーザー管理を自動化できます。

-   ユーザー名*SampleUser*:
    
    -   **方法:** POST
        
    -   **URL:** https://my-instance.com/api/entitydefinitions/User/entities
        
    -   **要請本体:**
        
        {
         "properties":{
         "Username":"SampleUser",
         "UserGroupConfiguration":null,
         "HasToken":null,
         "EmailConfirmationPending":null,
         "LockoutEndDate":null,
         "AccessFailedCount":null,
         "IsRestricted":null,
         "LastLoginDateTime":null,
         "LastPasswordChangeDateTime":null
         },
         "entitydefinition":{
         "href":"https://my-instance.com/api/entitydefinitions/User"
         },
        }
        
    -   **例回答:**
        
        201 created
        Content-Length: content length
        Location : https://my-instance.com/api/entities/10657
        
-   ID 10657でユーザーを削除する:
    
    -   **方法:** DELETE
    -   **URL:** https://my-instance.com/api/entities/10657
    -   **要求なし。**

## スクリプトSDK

[スクリプトSDKの](https://doc.sitecore.com/ch/ja/developers/cloud-dev/clients-1523440.html "Clients")*Users*クライアントを使ってユーザー管理を自動化できます。

-   ユーザー追加:
    
    IEntity user = await MClient.EntityFactory.CreateAsync(Constants.User.DefinitionName);
    //Add code to configure the user parameters
    await MClient.Entities.SaveAsync(user);
    
-   ユーザーを削除する:
    
    IEntity user = await MClient.Users.GetUserAsync("username");
    await MClient.Entities.DeleteAsync(user.Id);
    

## ウェブSDK

[ウェブクライアントSDKの](https://doc.sitecore.com/ch/ja/developers/cloud-dev/web-client-sdk.html "Web Client SDK")*User*クライアントを使ってユーザー管理を自動化できます。

-   ユーザー追加:
    
    IEntity user = await MClient.EntityFactory.CreateAsync(Constants.User.DefinitionName);
    //Add code to configure the user parameters
    await MClient.Entities.SaveAsync(user);
    
-   ユーザーを削除する:
    
    IEntity user = await MClient.Users.GetUserAsync("username");
    await MClient.Entities.DeleteAsync(user.Id);