0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

IBM Cloud:App IDにおけるユーザー数の確認方法

Last updated at Posted at 2024-02-13

はじめに

IBM CloudのApp IDは、IBM CloudポータルのIdPになることが可能であり、かつSAMLのSPになることができます。一方で、App IDはユーザー数の比例した課金項目があるため、SAMLを用いたユーザー数が増加した場合に意図せず課金請求が増額してしまうということが起こりえます。
本記事ではApp IDのユーザー数を取得する方法をGUIとCLIの2種類を記載します。

  • 実際に課金されるユーザー数とは異なる可能性があります。正確な課金項目の内容については、IBM Cloudポータル内の「請求と使用量」より確認ください
  • GUIとCLIではUser Profileの出力が異なります

IBM Cloudポータルから確認

Cloud Directoryの場合

左タブより「Cloud Directory」→「Users」を選択すると、ユーザーリスト上部に「Total numbers of Cloud Directory users」が確認できます。
image.png

全ユーザーを確認する場合

左タブより「Profiles and roles」→「User Profiles」を選択すると、ユーザーリスト上部に「Total numbers of profiles」が確認できます。
image.png

APIを用いたユーザー情報取得

APIの応答結果はjson形式がコマンドラインへ出力されます。
件数が多いと予想される場合は、出力をファイルへリダイレクトしてください。

Cloud Directoryの場合

以下のdocsに従います。
IBM Cloud docs:すべてのユーザーのエクスポート
ibmcloud CLIにてログインします。

$ ibmcloud login --sso
API endpoint: https://cloud.ibm.com
Authenticating...
OK

Targeted resource group Common
Targeted region jp-tok

API endpoint:      https://cloud.ibm.com
Region:            jp-tok
User:              xxx.xxx@xxx.com
Account:           IBM
Resource group:    Common
CF API endpoint:
Org:
Space:

API実行で使用するAPI Tokenを取得します。

$ ibmcloud iam oauth-tokens
IAM token:  Bearer xxxxx...

APIにてユーザーリスト作成のリクエストを実行します。

  • tenantID
    • サービスのテナント ID はサービス資格情報の中に記載
  • encryptionSecret
    • ハッシュ処理されたユーザーのパスワードの暗号化と復号のために使用する文字列。16文字以上で指定。import/all API を使用するために必要な暗号化秘密鍵を保持します
  • emailAddress
    • エクスポートの準備ができたとき、または要求が失敗した場合にメールが送信されるメール・アドレス
$ curl -X POST 'https://<region>.appid.cloud.ibm.com/management/v4/<tenantID>/cloud_directory/export/all' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer <IAMToken>' \
--data-raw '{"encryptionSecret" : "<encryptionSecret>",  
"emailAddress" : "xxx@example.com"}'

必要に応じて、要求の状況を取得します。

curl -X GET 'https://<region>.appid.cloud.ibm.com/management/v4/<tenantID>/cloud_directory/export/status?id=<id>' --header 'Accept: application/json'    --header 'Content-Type: application/json'    --header 'Authorization: Bearer <IAMToken>'

エクスポートの準備ができたら、または要求が失敗すると、指定したメール・アドレスにメールが送信されます。ダウンロードするには、 export/download APIを使用します。

$ curl -X GET 'https://<region>.appid.cloud.ibm.com/management/v4/<tenantID>/cloud_directory/export/download?id=<id>' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer <IAMToken>' \
> output.json

$ vim output.json
[{"scimUser":{"originalId":"xxx","userName":"xxx","name":{"givenName":"xxx","familyName":"xxx...

Cloud Directory以外の場合

GUIと異なり、全ユーザーは出力されず、Cloud Directory以外のユーザーが出力されます。

以下のdocsに従います。
IBM Cloud docs:ユーザー・プロファイルのエクスポート

以下のAPIでエクスポートを実行します。

$ curl -X GET https://<region>.appid.cloud.ibm.com/management/v4/<tenantID>/users/export \
--header "Accept: application/json" \
--header "Authorization: Bearer <IAMToken>" \
> output2.json

$ vim output2.json
// 先頭でトータルユーザー数が確認
{'totalResults': 2, 'itemsPerPage': 2, 'requestOptions': {}, 'users': [{'id':...
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?