名前空間: microsoft.graph
重要
Microsoft Graph の /beta
バージョンの API は変更される可能性があります。 実稼働アプリケーションでこれらの API を使用することは、サポートされていません。 v1.0 で API を使用できるかどうかを確認するには、Version セレクターを使用します。
デバイスが直接メンバーである グループ と 管理単位 を取得します。 この操作は推移的ではありません。
この API は、次の国内クラウド展開で使用できます。
グローバル サービス |
米国政府機関 L4 |
米国政府機関 L5 (DOD) |
21Vianet が運営する中国 |
✅ |
✅ |
✅ |
✅ |
アクセス許可
この API の最小特権としてマークされているアクセス許可またはアクセス許可を選択します。
アプリで必要な場合にのみ、より高い特権のアクセス許可またはアクセス許可を使用します。 委任されたアクセス許可とアプリケーションのアクセス許可の詳細については、「アクセス許可の種類」を参照してください。 これらのアクセス許可の詳細については、「アクセス許可のリファレンス」を参照してください。
アクセス許可の種類 |
最小特権アクセス許可 |
より高い特権のアクセス許可 |
委任 (職場または学校のアカウント) |
Device.Read.All |
Directory.Read.All、Directory.ReadWrite.All |
委任 (個人用 Microsoft アカウント) |
サポートされていません。 |
サポートされていません。 |
アプリケーション |
Device.Read.All |
Device.ReadWrite.All、Directory.Read.All、Directory.ReadWrite.All |
重要
アプリケーションが directoryObject 型のコレクションを返すリレーションシップをクエリするときに、特定のリソース型を読み取るアクセス許可がない場合、その型のメンバーが返されますが、情報は限られます。 たとえば、@odata.type プロパティでは、オブジェクト型と ID だけが返され、その他のプロパティは null
と表示されます。 この動作により、アプリケーションは、Directory.* 権限が付与されたアクセス許可のセットに依存するのではなく、必要な最小限のアクセス許可を要求できます。 詳細については、「アクセスできないメンバー オブジェクトについて、限定された情報が返される」を参照してください。
重要
職場または学校アカウントを使用した委任されたシナリオでは、サインインしているユーザーに、サポートされているMicrosoft Entraロールまたはサポートされているロールのアクセス許可を持つカスタム ロールを割り当てる必要があります。 この操作では、次の最小特権ロールがサポートされています。
- ディレクトリ リーダー
- グローバル閲覧者
- Intune管理者
- Windows 365 管理者
HTTP 要求
ID またはdeviceId を使用してデバイスをアドレス指定できます。
GET /devices/{id}/memberOf
GET /devices(deviceId='{deviceId}')/memberOf
オプションのクエリ パラメーター
このメソッドは、応答のカスタマイズに役立つ $select
、 $search
、 $count
、 $filter
OData クエリ パラメーター をサポートします。
- OData キャストも有効になっています。たとえば、キャストして、デバイスが割り当てられている ディレクトリRoles のみを取得できます。
-
$search
は displayName プロパティと description プロパティでのみサポートされています。
- 既定のページ サイズと最大ページ サイズはそれぞれ 100 オブジェクトと 999 オブジェクトです。
- この API でのクエリ パラメーターの使用は、高度なクエリ パラメーターでのみサポートされます。 詳細については、「ディレクトリ オブジェクトの詳細クエリ機能」を参照してください。
ヘッダー |
値 |
Authorization |
ベアラー {token}。 必須です。
認証と認可についての詳細をご覧ください。 |
ConsistencyLevel |
最終的。 このヘッダーと $count は、 $search 、OData キャスト パラメーター、または $filter の特定の使用方法で使用する場合に必要です。
ConsistencyLevel と $count の使用の詳細については、「ディレクトリ オブジェクトに対する高度なクエリ機能」を参照してください。 |
要求本文
このメソッドには、要求本文を指定しません。
応答
成功した場合、このメソッドは 200 OK
応答コードと、応答本文で directoryObject オブジェクトのコレクションを返します。
例
例 1: デバイスが直接メンバーであるグループを取得する
要求
次の例は要求を示しています。
GET https://graph.microsoft.com/beta/devices/{id}/memberOf
// Code snippets are only available for the latest version. Current version is 5.x
// To initialize your graphClient, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=csharp
var result = await graphClient.Devices["{device-id}"].MemberOf.GetAsync();
mgc-beta devices member-of list --device-id {device-id}
// 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"
//other-imports
)
// To initialize your graphClient, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=go
memberOf, err := graphClient.Devices().ByDeviceId("device-id").MemberOf().Get(context.Background(), nil)
// Code snippets are only available for the latest version. Current version is 6.x
GraphServiceClient graphClient = new GraphServiceClient(requestAdapter);
DirectoryObjectCollectionResponse result = graphClient.devices().byDeviceId("{device-id}").memberOf().get();
const options = {
authProvider,
};
const client = Client.init(options);
let memberOf = await client.api('/devices/{id}/memberOf')
.version('beta')
.get();
<?php
use Microsoft\Graph\Beta\GraphServiceClient;
$graphServiceClient = new GraphServiceClient($tokenRequestContext, $scopes);
$result = $graphServiceClient->devices()->byDeviceId('device-id')->memberOf()->get()->wait();
Import-Module Microsoft.Graph.Beta.Identity.DirectoryManagement
Get-MgBetaDeviceMemberOf -DeviceId $deviceId
# Code snippets are only available for the latest version. Current version is 1.x
from msgraph_beta import GraphServiceClient
# To initialize your graph_client, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=python
result = await graph_client.devices.by_device_id('device-id').member_of.get()
応答
次の例は応答を示しています。
注: ここに示す応答オブジェクトは、読みやすさのために短縮されている場合があります。
HTTP/1.1 200 OK
Content-type: application/json
{
"value": [
{
"@odata.type": "#microsoft.graph.group",
"id": "id-value",
"createdDateTime": null,
"description": "All users at the company",
"displayName": "All Users",
"groupTypes": [],
"mailEnabled": false,
"securityEnabled": true,
}
]
}
例 2: 全メンバーシップ数のみを取得する
要求
次の例は要求を示しています。
GET https://graph.microsoft.com/beta/devices/{id}/memberOf/$count
ConsistencyLevel: eventual
応答
次の例は応答を示しています。
HTTP/1.1 200 OK
Content-type: text/plain
394
例 3: OData キャストと$searchを使用して、返されたオブジェクトの数を含む文字 'Video' を含む表示名を持つメンバーシップを取得する
要求
次の例は要求を示しています。
GET https://graph.microsoft.com/beta/devices/{id}/memberOf/microsoft.graph.group?$count=true&$orderby=displayName&$search="displayName:Video"
ConsistencyLevel: eventual
応答
次の例は応答を示しています。
注: ここに示す応答オブジェクトは、読みやすさのために短縮されている場合があります。
HTTP/1.1 200 OK
Content-type: application/json
{
"@odata.context":"https://graph.microsoft.com/beta/$metadata#directoryObjects",
"@odata.count":1396,
"value":[
{
"displayName":"SFA Videos",
"mail":"SFAVideos@service.contoso.com",
"mailNickname":"SFAVideos"
}
]
}
例 4: OData キャストと$filterを使用して、返されたオブジェクトの数を含む文字 'A' で始まる表示名を持つメンバーシップを取得する
要求
次の例は要求を示しています。
GET https://graph.microsoft.com/beta/devices/{id}/memberOf/microsoft.graph.group?$count=true&$orderby=displayName&$filter=startswith(displayName, 'A')
ConsistencyLevel: eventual
// Code snippets are only available for the latest version. Current version is 5.x
// To initialize your graphClient, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=csharp
var result = await graphClient.Devices["{device-id}"].MemberOf.GraphGroup.GetAsync((requestConfiguration) =>
{
requestConfiguration.QueryParameters.Count = true;
requestConfiguration.QueryParameters.Orderby = new string []{ "displayName" };
requestConfiguration.QueryParameters.Filter = "startswith(displayName, 'A')";
requestConfiguration.Headers.Add("ConsistencyLevel", "eventual");
});
mgc-beta devices member-of graph-group get --device-id {device-id} --filter "startswith(displayName, 'A')" --count "true" --orderby "displayName" --consistency-level "eventual"
// Code snippets are only available for the latest major version. Current major version is $v0.*
// Dependencies
import (
"context"
abstractions "github.com/microsoft/kiota-abstractions-go"
msgraphsdk "github.com/microsoftgraph/msgraph-beta-sdk-go"
graphdevices "github.com/microsoftgraph/msgraph-beta-sdk-go/devices"
//other-imports
)
headers := abstractions.NewRequestHeaders()
headers.Add("ConsistencyLevel", "eventual")
requestCount := true
requestFilter := "startswith(displayName, 'A')"
requestParameters := &graphdevices.ItemMemberOfGraph.groupRequestBuilderGetQueryParameters{
Count: &requestCount,
Orderby: [] string {"displayName"},
Filter: &requestFilter,
}
configuration := &graphdevices.ItemMemberOfGraph.groupRequestBuilderGetRequestConfiguration{
Headers: headers,
QueryParameters: requestParameters,
}
// To initialize your graphClient, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=go
graphGroup, err := graphClient.Devices().ByDeviceId("device-id").MemberOf().GraphGroup().Get(context.Background(), configuration)
// Code snippets are only available for the latest version. Current version is 6.x
GraphServiceClient graphClient = new GraphServiceClient(requestAdapter);
GroupCollectionResponse result = graphClient.devices().byDeviceId("{device-id}").memberOf().graphGroup().get(requestConfiguration -> {
requestConfiguration.queryParameters.count = true;
requestConfiguration.queryParameters.orderby = new String []{"displayName"};
requestConfiguration.queryParameters.filter = "startswith(displayName, 'A')";
requestConfiguration.headers.add("ConsistencyLevel", "eventual");
});
const options = {
authProvider,
};
const client = Client.init(options);
let group = await client.api('/devices/{id}/memberOf/microsoft.graph.group')
.version('beta')
.header('ConsistencyLevel','eventual')
.filter('startswith(displayName, \'A\')')
.orderby('displayName')
.get();
<?php
use Microsoft\Graph\Beta\GraphServiceClient;
use Microsoft\Graph\Beta\Generated\Devices\Item\MemberOf\Graph\Group\GroupRequestBuilderGetRequestConfiguration;
$graphServiceClient = new GraphServiceClient($tokenRequestContext, $scopes);
$requestConfiguration = new GraphGroupRequestBuilderGetRequestConfiguration();
$headers = [
'ConsistencyLevel' => 'eventual',
];
$requestConfiguration->headers = $headers;
$queryParameters = GraphGroupRequestBuilderGetRequestConfiguration::createQueryParameters();
$queryParameters->count = true;
$queryParameters->orderby = ["displayName"];
$queryParameters->filter = "startswith(displayName, 'A')";
$requestConfiguration->queryParameters = $queryParameters;
$result = $graphServiceClient->devices()->byDeviceId('device-id')->memberOf()->graphGroup()->get($requestConfiguration)->wait();
Import-Module Microsoft.Graph.Beta.Identity.DirectoryManagement
Get-MgBetaDeviceMemberOfAsGroup -DeviceId $deviceId -CountVariable CountVar -Sort "displayName" -Filter "startswith(displayName, 'A')" -ConsistencyLevel eventual
# Code snippets are only available for the latest version. Current version is 1.x
from msgraph_beta import GraphServiceClient
from msgraph_beta.generated.devices.item.member_of.graph.group.group_request_builder import GroupRequestBuilder
from kiota_abstractions.base_request_configuration import RequestConfiguration
# To initialize your graph_client, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=python
query_params = GroupRequestBuilder.GroupRequestBuilderGetQueryParameters(
count = True,
orderby = ["displayName"],
filter = "startswith(displayName, 'A')",
)
request_configuration = RequestConfiguration(
query_parameters = query_params,
)
request_configuration.headers.add("ConsistencyLevel", "eventual")
result = await graph_client.devices.by_device_id('device-id').member_of.graph_group.get(request_configuration = request_configuration)
応答
次の例は応答を示しています。
注: ここに示す応答オブジェクトは、読みやすさのために短縮されている場合があります。
HTTP/1.1 200 OK
Content-type: application/json
{
"@odata.context":"https://graph.microsoft.com/beta/$metadata#directoryObjects",
"@odata.count":76,
"value":[
{
"displayName":"AAD Contoso Videos",
"mail":"AADContosoVideos@contoso.com",
"mailEnabled":true,
"mailNickname":"AADContoso_Videos",
"securityEnabled":true
}
]
}