名前空間: microsoft.graph
重要
Microsoft Graph の /beta
バージョンの API は変更される可能性があります。 実稼働アプリケーションでこれらの API を使用することは、サポートされていません。 v1.0 で API を使用できるかどうかを確認するには、Version セレクターを使用します。
指定したユーザー、グループ、サービス プリンシパル、組織の連絡先、デバイス、またはディレクトリ オブジェクトがメンバーであるグループのすべてのグループ ID を返します。 この関数は、推移的です。
この API は、最大 11,000 個のグループ ID を返します。 11,000 を超える結果が使用可能な場合は、Directory_ResultSizeLimitExceeded
エラー コードを含む400 Bad Request
エラーが返されます。
Directory_ResultSizeLimitExceeded
エラー コードが表示される場合は、代わりに List グループ推移的メンバーOf API を使用します。
この API は、次の国内クラウド展開で使用できます。
グローバル サービス |
米国政府機関 L4 |
米国政府機関 L5 (DOD) |
21Vianet が運営する中国 |
✅ |
✅ |
✅ |
✅ |
アクセス許可
この API を呼び出すには、次のいずれかのアクセス許可が必要です。 アクセス許可の選択方法などの詳細については、「アクセス許可」を参照してください。
ディレクトリ オブジェクトのグループ メンバーシップ
この権限を使用すると、オブジェクトの種類に関係なく、 任意 のディレクトリ オブジェクトを読み取ることができます。 操作のスコープを特定のオブジェクトの種類に設定し、より権限の低いアクセス許可を使用するには、このページの他のアクセス許可テーブルを参照してください。
アクセス許可の種類 |
アクセス許可 (特権の小さいものから大きいものへ) |
委任 (職場または学校のアカウント) |
Directory.Read.All |
委任 (個人用 Microsoft アカウント) |
サポートされていません。 |
アプリケーション |
Directory.Read.All |
ユーザーのグループ メンバーシップ
アクセス許可の種類 |
アクセス許可 (特権の小さいものから大きいものへ) |
委任 (職場または学校のアカウント) |
User.ReadBasic.All と GroupMember.Read.All、User.Read.All、GroupMember.Read.All、User.ReadBasic.All、Group.Read.All、User.Read.All、Group.Read.All、Directory.Read.All |
委任 (個人用 Microsoft アカウント) |
サポートされていません。 |
アプリケーション |
User.ReadBasic.All と GroupMember.Read.All、User.Read.All、GroupMember.Read.All、User.ReadBasic.All、Group.Read.All、User.Read.All、Group.Read.All、Directory.Read.All |
グループのグループ メンバーシップ
アクセス許可の種類 |
アクセス許可 (特権の小さいものから大きいものへ) |
委任 (職場または学校のアカウント) |
GroupMember.Read.All、Group.Read.All、Directory.Read.All、Group.ReadWrite.All、Directory.ReadWrite.All |
委任 (個人用 Microsoft アカウント) |
サポートされていません。 |
アプリケーション |
GroupMember.Read.All、Group.Read.All、Directory.Read.All、Group.ReadWrite.All、Directory.ReadWrite.All |
サービス プリンシパルのグループ メンバーシップ
アクセス許可の種類 |
アクセス許可 (特権の小さいものから大きいものへ) |
委任 (職場または学校のアカウント) |
Application.Read.All、Directory.Read.All、Application.ReadWrite.All、Directory.ReadWrite.All |
委任 (個人用 Microsoft アカウント) |
サポートされていません。 |
アプリケーション |
Application.Read.All、Directory.Read.All、Application.ReadWrite.All、Directory.ReadWrite.All |
アクセス許可の種類 |
アクセス許可 (特権の小さいものから大きいものへ) |
委任 (職場または学校のアカウント) |
Directory.Read.All、Directory.ReadWrite.All |
委任 (個人用 Microsoft アカウント) |
サポートされていません。 |
アプリケーション |
Directory.Read.All、Directory.ReadWrite.All |
デバイスのグループ メンバーシップ
アクセス許可の種類 |
最小特権アクセス許可 |
より高い特権のアクセス許可 |
委任 (職場または学校のアカウント) |
Application.Read.All |
Application.ReadWrite.All、Device.Read.All、Directory.Read.All、Directory.ReadWrite.All、Group.ReadWrite.All、Group.ReadWrite.All、GroupMember.Read.All、User.Read.All |
委任 (個人用 Microsoft アカウント) |
サポートされていません。 |
サポートされていません。 |
アプリケーション |
Application.Read.All |
Application.ReadWrite.All、Device.Read.All、Device.ReadWrite.All、Directory.Read.All、Directory.ReadWrite.All、Group.ReadWrite.All、Group.ReadWrite.All、GroupMember.Read.All、User.Read.All |
HTTP 要求
ディレクトリ オブジェクトのグループ メンバーシップ (ユーザー、グループ、サービス プリンシパル、または組織の連絡先)。
POST /directoryObjects/{id}/getMemberGroups
サインインしているユーザーまたは他のユーザーのグループ メンバーシップ。
POST /me/getMemberGroups
POST /users/{id | userPrincipalName}/getMemberGroups
グループのグループ メンバーシップ。
POST /groups/{id}/getMemberGroups
サービス プリンシパルのグループ メンバーシップ。
POST /servicePrincipals/{id}/getMemberGroups
組織の連絡先のグループ メンバーシップ。
POST /contacts/{id}/getMemberGroups
デバイスのグループ メンバーシップ。
POST /devices/{id}/getMemberGroups
名前 |
説明 |
Authorization |
ベアラー {token}。 必須です。
認証と認可についての詳細をご覧ください。 |
Content-Type |
application/json |
要求本文
要求本文で、次のパラメーターを含む JSON オブジェクトを指定します。
パラメーター |
型 |
説明 |
securityEnabledOnly |
Boolean |
true エンティティがメンバーであるセキュリティ グループのみを返すように指定するには、エンティティがメンバーであるすべてのグループとディレクトリ ロールを返すように指定する false 。
true は、ユーザーまたはサービス プリンシパルがセキュリティが有効なグループを返す場合にのみ指定できます。 |
応答
成功した場合、このメソッドは 200 OK
応答コードと、応答本文で文字列コレクション オブジェクトを返します。
例
例 1: ディレクトリ オブジェクトのグループ メンバーシップを確認する
要求
POST https://graph.microsoft.com/beta/directoryObjects/0049d944-a805-4680-9f54-3ab292090309/getMemberGroups
Content-type: application/json
{
"securityEnabledOnly": false
}
// Code snippets are only available for the latest version. Current version is 5.x
// Dependencies
using Microsoft.Graph.Beta.DirectoryObjects.Item.GetMemberGroups;
var requestBody = new GetMemberGroupsPostRequestBody
{
SecurityEnabledOnly = false,
};
// To initialize your graphClient, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=csharp
var result = await graphClient.DirectoryObjects["{directoryObject-id}"].GetMemberGroups.PostAsGetMemberGroupsPostResponseAsync(requestBody);
mgc-beta directory-objects get-member-groups post --directory-object-id {directoryObject-id} --body '{\
"securityEnabledOnly": false\
}\
'
// Code snippets are only available for the latest major version. Current major version is $v0.*
// Dependencies
import (
"context"
msgraphsdk "github.com/microsoftgraph/msgraph-beta-sdk-go"
graphdirectoryobjects "github.com/microsoftgraph/msgraph-beta-sdk-go/directoryobjects"
//other-imports
)
requestBody := graphdirectoryobjects.NewGetMemberGroupsPostRequestBody()
securityEnabledOnly := false
requestBody.SetSecurityEnabledOnly(&securityEnabledOnly)
// To initialize your graphClient, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=go
getMemberGroups, err := graphClient.DirectoryObjects().ByDirectoryObjectId("directoryObject-id").GetMemberGroups().PostAsGetMemberGroupsPostResponse(context.Background(), requestBody, nil)
// Code snippets are only available for the latest version. Current version is 6.x
GraphServiceClient graphClient = new GraphServiceClient(requestAdapter);
com.microsoft.graph.beta.directoryobjects.item.getmembergroups.GetMemberGroupsPostRequestBody getMemberGroupsPostRequestBody = new com.microsoft.graph.beta.directoryobjects.item.getmembergroups.GetMemberGroupsPostRequestBody();
getMemberGroupsPostRequestBody.setSecurityEnabledOnly(false);
var result = graphClient.directoryObjects().byDirectoryObjectId("{directoryObject-id}").getMemberGroups().post(getMemberGroupsPostRequestBody);
const options = {
authProvider,
};
const client = Client.init(options);
const string = {
securityEnabledOnly: false
};
await client.api('/directoryObjects/0049d944-a805-4680-9f54-3ab292090309/getMemberGroups')
.version('beta')
.post(string);
<?php
use Microsoft\Graph\Beta\GraphServiceClient;
use Microsoft\Graph\Beta\Generated\DirectoryObjects\Item\GetMemberGroups\GetMemberGroupsPostRequestBody;
$graphServiceClient = new GraphServiceClient($tokenRequestContext, $scopes);
$requestBody = new GetMemberGroupsPostRequestBody();
$requestBody->setSecurityEnabledOnly(false);
$result = $graphServiceClient->directoryObjects()->byDirectoryObjectId('directoryObject-id')->getMemberGroups()->post($requestBody)->wait();
Import-Module Microsoft.Graph.Beta.DirectoryObjects
$params = @{
securityEnabledOnly = $false
}
Get-MgBetaDirectoryObjectMemberGroup -DirectoryObjectId $directoryObjectId -BodyParameter $params
# Code snippets are only available for the latest version. Current version is 1.x
from msgraph_beta import GraphServiceClient
from msgraph_beta.generated.directoryobjects.item.get_member_groups.get_member_groups_post_request_body import GetMemberGroupsPostRequestBody
# To initialize your graph_client, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=python
request_body = GetMemberGroupsPostRequestBody(
security_enabled_only = False,
)
result = await graph_client.directory_objects.by_directory_object_id('directoryObject-id').get_member_groups.post(request_body)
応答
次の例は応答を示しています。
注: ここに示す応答オブジェクトは、読みやすさのために短縮されている場合があります。
HTTP/1.1 200 OK
Content-type: application/json
{
"@odata.context": "https://graph.microsoft.com/beta/$metadata#Collection(Edm.String)",
"value": [
"a8daa1fb-d24c-47d0-9e9e-c99e83394e3e"
]
}
例 2: サインインしているユーザーのグループ メンバーシップを確認する
要求
POST https://graph.microsoft.com/beta/me/getMemberGroups
Content-type: application/json
{
"securityEnabledOnly": true
}
// Code snippets are only available for the latest version. Current version is 5.x
// Dependencies
using Microsoft.Graph.Beta.Me.GetMemberGroups;
var requestBody = new GetMemberGroupsPostRequestBody
{
SecurityEnabledOnly = true,
};
// To initialize your graphClient, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=csharp
var result = await graphClient.Me.GetMemberGroups.PostAsGetMemberGroupsPostResponseAsync(requestBody);
mgc-beta users get-member-groups post --user-id {user-id} --body '{\
"securityEnabledOnly": true\
}\
'
// Code snippets are only available for the latest major version. Current major version is $v0.*
// Dependencies
import (
"context"
msgraphsdk "github.com/microsoftgraph/msgraph-beta-sdk-go"
graphusers "github.com/microsoftgraph/msgraph-beta-sdk-go/users"
//other-imports
)
requestBody := graphusers.NewItemGetMemberGroupsPostRequestBody()
securityEnabledOnly := true
requestBody.SetSecurityEnabledOnly(&securityEnabledOnly)
// To initialize your graphClient, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=go
getMemberGroups, err := graphClient.Me().GetMemberGroups().PostAsGetMemberGroupsPostResponse(context.Background(), requestBody, nil)
// Code snippets are only available for the latest version. Current version is 6.x
GraphServiceClient graphClient = new GraphServiceClient(requestAdapter);
com.microsoft.graph.beta.users.item.getmembergroups.GetMemberGroupsPostRequestBody getMemberGroupsPostRequestBody = new com.microsoft.graph.beta.users.item.getmembergroups.GetMemberGroupsPostRequestBody();
getMemberGroupsPostRequestBody.setSecurityEnabledOnly(true);
var result = graphClient.me().getMemberGroups().post(getMemberGroupsPostRequestBody);
const options = {
authProvider,
};
const client = Client.init(options);
const string = {
securityEnabledOnly: true
};
await client.api('/me/getMemberGroups')
.version('beta')
.post(string);
<?php
use Microsoft\Graph\Beta\GraphServiceClient;
use Microsoft\Graph\Beta\Generated\Users\Item\GetMemberGroups\GetMemberGroupsPostRequestBody;
$graphServiceClient = new GraphServiceClient($tokenRequestContext, $scopes);
$requestBody = new GetMemberGroupsPostRequestBody();
$requestBody->setSecurityEnabledOnly(true);
$result = $graphServiceClient->me()->getMemberGroups()->post($requestBody)->wait();
Import-Module Microsoft.Graph.Beta.Users.Actions
$params = @{
securityEnabledOnly = $true
}
# A UPN can also be used as -UserId.
Get-MgBetaUserMemberGroup -UserId $userId -BodyParameter $params
# Code snippets are only available for the latest version. Current version is 1.x
from msgraph_beta import GraphServiceClient
from msgraph_beta.generated.users.item.get_member_groups.get_member_groups_post_request_body import GetMemberGroupsPostRequestBody
# To initialize your graph_client, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=python
request_body = GetMemberGroupsPostRequestBody(
security_enabled_only = True,
)
result = await graph_client.me.get_member_groups.post(request_body)
応答
注: ここに示す応答オブジェクトは、読みやすさのために短縮されている場合があります。
HTTP/1.1 200 OK
Content-type: application/json
{
"@odata.context": "https://graph.microsoft.com/beta/$metadata#Collection(Edm.String)",
"value": [
"6239671a-0db6-4e8b-9d2f-f280efb5a181",
"2e2f1227-1586-45ae-bf51-fccc1de72625",
"f5987b5a-61f6-4c31-9fa2-7bfb845c8d2a"
]
}