名前空間: microsoft.graph
重要
Microsoft Graph の /beta
バージョンの API は変更される可能性があります。 実稼働アプリケーションでこれらの API を使用することは、サポートされていません。 v1.0 で API を使用できるかどうかを確認するには、Version セレクターを使用します。
動的配布グループを除く、organizationで使用可能なすべてのグループを一覧表示します。 動的配布グループを取得するには、Exchange 管理センターを使用します。
この操作は既定で各グループで頻繁に使用されるプロパティのサブセットのみを返します。 これらの既定のプロパティは、「プロパティ」セクションに記載されています。 既定で返されないプロパティを取得するには、グループに対して GET 操作を実行し、$select
OData クエリ オプションでプロパティを指定します。
hasMembersWithLicenseErrors プロパティと isArchived プロパティは例外で、$select
クエリでは返されません。
この API は、次の国内クラウド展開で使用できます。
グローバル サービス |
米国政府機関 L4 |
米国政府機関 L5 (DOD) |
21Vianet が運営する中国 |
✅ |
✅ |
✅ |
✅ |
アクセス許可
この API の最小特権としてマークされているアクセス許可またはアクセス許可を選択します。
アプリで必要な場合にのみ、より高い特権のアクセス許可またはアクセス許可を使用します。 委任されたアクセス許可とアプリケーションのアクセス許可の詳細については、「アクセス許可の種類」を参照してください。 これらのアクセス許可の詳細については、「アクセス許可のリファレンス」を参照してください。
アクセス許可の種類 |
最小特権アクセス許可 |
より高い特権のアクセス許可 |
委任 (職場または学校のアカウント) |
GroupMember.Read.All |
Group.ReadWrite.All、Directory.Read.All、Directory.ReadWrite.All、Group.Read.All |
委任 (個人用 Microsoft アカウント) |
サポートされていません。 |
サポートされていません。 |
アプリケーション |
GroupMember.Read.All |
Directory.Read.All、Directory.ReadWrite.All、Group.Read.All、Group.ReadWrite.All |
HTTP 要求
GET /groups
オプションのクエリ パラメーター
このメソッドは、応答のカスタマイズに役立つ $count
、 $expand
、 $filter
、 $orderby
、 $search
、 $select
、 $top
OData クエリ パラメーター をサポートします。
$skip
はサポートされていません。 既定のページ サイズと最大ページ サイズは、それぞれ 100 と 999 のグループ オブジェクトです。 クエリの中には、ConsistencyLevel ヘッダーの設定を eventual
および $count
に使用した場合にのみサポートされるものもあります。 詳細については、「ディレクトリ オブジェクトの詳細クエリ機能」を参照してください。
Microsoft 365 グループ (統合グループ) のみを一覧表示するには、 groupTypes にフィルターを適用します。
GET https://graph.microsoft.com/beta/groups?$filter=groupTypes/any(c:c+eq+'Unified')
$search
クエリ パラメーターでは、displayName と description フィールドにのみトークン化をサポートしており、ConsistencyLevel ヘッダーが必要です。
displayName および description 以外のフィールドは、既定で$filter
startsWith
動作になります。
拡張機能プロパティでは、次のようにクエリ パラメーターもサポートされます。
拡張機能の種類 |
コメント |
スキーマ拡張機能 |
$select でのみ返されます。 |
オープン拡張機能 |
$expand でのみ返されます。 |
ディレクトリ拡張機能 |
既定で返されます。 |
OData クエリ オプションの詳細については、「OData クエリ パラメーター」を参照してください。
ConsistencyLevel と $count
の使用の詳細については、「ディレクトリ オブジェクトに対する高度なクエリ機能」を参照してください。
グループの種類でフィルター処理する
グループの種類 |
API 要求 |
Microsoft 365 (統合) グループ |
GET/groups?$filter=groupTypes/any(c:c+eq+'Unified') |
セキュリティ グループ |
GET/groups?$filter=mailEnabled eq false&securityEnabled eq true |
メールが有効なセキュリティ グループ |
取得/groups?$filter=NOT groupTypes/any(c:c eq 'Unified') and mailEnabled eq true and securityEnabled eq true&$count=true ** |
配布グループ |
取得/groups?$filter=NOT groupTypes/any(c:c eq 'Unified') and mailEnabled eq true and securityEnabled eq false&$count=true ** |
** : この例は 、高度なクエリ機能でのみサポートされています。
名前 |
説明 |
Authorization |
ベアラー {token}。 必須です。
認証と認可についての詳細をご覧ください。 |
ConsistencyLevel |
最終的。 このヘッダーと $count は、$search を使用する場合、または $filter の特別な使用をする場合に必要です。
ConsistencyLevel と $count の使用の詳細については、「ディレクトリ オブジェクトに対する高度なクエリ機能」を参照してください。 |
要求本文
このメソッドには、要求本文を指定しません。
応答
成功した場合、このメソッドは 200 OK
応答コードと、応答本文で group オブジェクトのコレクションを返します。 応答には、各グループの既定のプロパティのみが含まれています。
例
例 1: グループの一覧を取得する
要求
次の例は要求を示しています。
GET https://graph.microsoft.com/beta/groups
// 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.Groups.GetAsync();
// 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
groups, err := graphClient.Groups().Get(context.Background(), nil)
// Code snippets are only available for the latest version. Current version is 6.x
GraphServiceClient graphClient = new GraphServiceClient(requestAdapter);
GroupCollectionResponse result = graphClient.groups().get();
const options = {
authProvider,
};
const client = Client.init(options);
let groups = await client.api('/groups')
.version('beta')
.get();
<?php
use Microsoft\Graph\Beta\GraphServiceClient;
$graphServiceClient = new GraphServiceClient($tokenRequestContext, $scopes);
$result = $graphServiceClient->groups()->get()->wait();
Import-Module Microsoft.Graph.Beta.Groups
Get-MgBetaGroup
# 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.groups.get()
応答
次の例は応答を示しています。
注: ここに示す応答オブジェクトは、読みやすさのために短縮されている場合があります。 実際の呼び出しでは、各グループのすべての既定のプロパティが返されます。
HTTP/1.1 200 OK
Content-type: application/json
{
"@odata.context":"https://graph.microsoft.com/beta/$metadata#groups",
"value":[
{
"id":"45b7d2e7-b882-4a80-ba97-10b7a63b8fa4",
"deletedDateTime":null,
"classification":null,
"createdDateTime":"2018-12-22T02:21:05Z",
"description":"Self help community for golf",
"displayName":"Golf Assist",
"expirationDateTime":null,
"groupTypes":[
"Unified"
],
"isAssignableToRole":null,
"mail":"golfassist@contoso.com",
"mailEnabled":true,
"mailNickname":"golfassist",
"membershipRule":null,
"membershipRuleProcessingState":null,
"onPremisesLastSyncDateTime":null,
"onPremisesSecurityIdentifier":null,
"onPremisesSyncEnabled":null,
"preferredDataLocation":"CAN",
"preferredLanguage":null,
"proxyAddresses":[
"smtp:golfassist@contoso.com",
"SMTP:golfassist@contoso.com"
],
"renewedDateTime":"2018-12-22T02:21:05Z",
"resourceBehaviorOptions":[
],
"resourceProvisioningOptions":[
],
"securityEnabled":false,
"serviceProvisioningErrors": [
],
"theme":null,
"visibility":"Public",
"onPremisesProvisioningErrors":[
]
},
{
"id":"d7797254-3084-44d0-99c9-a3b5ab149538",
"deletedDateTime":null,
"classification":null,
"createdDateTime":"2018-11-19T20:29:40Z",
"description":"Talk about golf",
"displayName":"Golf Discussion",
"expirationDateTime":null,
"groupTypes":[
],
"isAssignableToRole":null,
"mail":"golftalk@contoso.com",
"mailEnabled":true,
"mailNickname":"golftalk",
"membershipRule":null,
"membershipRuleProcessingState":null,
"onPremisesLastSyncDateTime":null,
"onPremisesSecurityIdentifier":null,
"onPremisesSyncEnabled":null,
"preferredDataLocation":"CAN",
"preferredLanguage":null,
"proxyAddresses":[
"smtp:golftalk@contoso.com",
"SMTP:golftalk@contoso.com"
],
"renewedDateTime":"2018-11-19T20:29:40Z",
"resourceBehaviorOptions":[
],
"resourceProvisioningOptions":[
],
"securityEnabled":false,
"serviceProvisioningErrors": [
],
"theme":null,
"visibility":null,
"onPremisesProvisioningErrors":[
]
}
]
}
例 2: フィルター処理されたグループの一覧を取得する
hasMembersWithLicenseErrors プロパティに対してフィルター処理するこの要求では、返されるオブジェクトの数の取得はサポートされていません。
要求
GET https://graph.microsoft.com/beta/groups?$filter=hasMembersWithLicenseErrors+eq+true&$select=id,displayName
// 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.Groups.GetAsync((requestConfiguration) =>
{
requestConfiguration.QueryParameters.Filter = "hasMembersWithLicenseErrors eq true";
requestConfiguration.QueryParameters.Select = new string []{ "id","displayName" };
});
mgc-beta groups list --filter "hasMembersWithLicenseErrors eq true" --select "id,displayName"
// 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"
graphgroups "github.com/microsoftgraph/msgraph-beta-sdk-go/groups"
//other-imports
)
requestFilter := "hasMembersWithLicenseErrors eq true"
requestParameters := &graphgroups.GroupsRequestBuilderGetQueryParameters{
Filter: &requestFilter,
Select: [] string {"id","displayName"},
}
configuration := &graphgroups.GroupsRequestBuilderGetRequestConfiguration{
QueryParameters: requestParameters,
}
// To initialize your graphClient, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=go
groups, err := graphClient.Groups().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.groups().get(requestConfiguration -> {
requestConfiguration.queryParameters.filter = "hasMembersWithLicenseErrors eq true";
requestConfiguration.queryParameters.select = new String []{"id", "displayName"};
});
const options = {
authProvider,
};
const client = Client.init(options);
let groups = await client.api('/groups')
.version('beta')
.filter('hasMembersWithLicenseErrors eq true')
.select('id,displayName')
.get();
<?php
use Microsoft\Graph\Beta\GraphServiceClient;
use Microsoft\Graph\Beta\Generated\Groups\GroupsRequestBuilderGetRequestConfiguration;
$graphServiceClient = new GraphServiceClient($tokenRequestContext, $scopes);
$requestConfiguration = new GroupsRequestBuilderGetRequestConfiguration();
$queryParameters = GroupsRequestBuilderGetRequestConfiguration::createQueryParameters();
$queryParameters->filter = "hasMembersWithLicenseErrors eq true";
$queryParameters->select = ["id","displayName"];
$requestConfiguration->queryParameters = $queryParameters;
$result = $graphServiceClient->groups()->get($requestConfiguration)->wait();
Import-Module Microsoft.Graph.Beta.Groups
Get-MgBetaGroup -Filter "hasMembersWithLicenseErrors eq true" -Property "id,displayName"
# Code snippets are only available for the latest version. Current version is 1.x
from msgraph_beta import GraphServiceClient
from msgraph_beta.generated.groups.groups_request_builder import GroupsRequestBuilder
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 = GroupsRequestBuilder.GroupsRequestBuilderGetQueryParameters(
filter = "hasMembersWithLicenseErrors eq true",
select = ["id","displayName"],
)
request_configuration = RequestConfiguration(
query_parameters = query_params,
)
result = await graph_client.groups.get(request_configuration = request_configuration)
応答
要求したプロパティのみを含む応答の例を次に示します。
HTTP/1.1 200 OK
Content-type: application/json
{
"@odata.context":"https://graph.microsoft.com/beta/$metadata#groups(id,displayName)",
"value":[
{
"id":"11111111-2222-3333-4444-555555555555",
"displayName":"Contoso Group 1"
},
{
"id":"22222222-3333-4444-5555-666666666666",
"displayName":"Contoso Group 2"
}
]
}
例 3: グループ数のみを取得する
要求
次の例は要求を示しています。 この要求では、$count
が要求にあるため、ConsistencyLevel ヘッダーを eventual
に設定する必要があります。
ConsistencyLevel と $count
の使用の詳細については、「ディレクトリ オブジェクトに対する高度なクエリ機能」を参照してください。
注:$count
および$search
のクエリパラメーターは、現在 Azure ADB2C テナントでは使用できません。
GET https://graph.microsoft.com/beta/groups/$count
ConsistencyLevel: eventual
応答
次の例は応答を示しています。
HTTP/1.1 200 OK
Content-type: text/plain
893
例 4: $filter と $top を使用して、「a」で始まる表示名のグループを 1 つ取得する (返されたオブジェクトの数も含む)
要求
次の例は要求を示しています。 この要求では、$orderby
と $filter
の両方のクエリ パラメーターがあるため、ConsistencyLevel ヘッダーを eventual
および $count=true
クエリ文字列に設定することが必要です。
ConsistencyLevel と $count
の使用の詳細については、「ディレクトリ オブジェクトに対する高度なクエリ機能」を参照してください。
注:$count
および$search
のクエリパラメーターは、現在 Azure ADB2C テナントでは使用できません。
GET https://graph.microsoft.com/beta/groups?$filter=startswith(displayName, 'a')&$count=true&$top=1&$orderby=displayName
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.Groups.GetAsync((requestConfiguration) =>
{
requestConfiguration.QueryParameters.Filter = "startswith(displayName, 'a')";
requestConfiguration.QueryParameters.Count = true;
requestConfiguration.QueryParameters.Top = 1;
requestConfiguration.QueryParameters.Orderby = new string []{ "displayName" };
requestConfiguration.Headers.Add("ConsistencyLevel", "eventual");
});
mgc-beta groups list --top "1" --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"
graphgroups "github.com/microsoftgraph/msgraph-beta-sdk-go/groups"
//other-imports
)
headers := abstractions.NewRequestHeaders()
headers.Add("ConsistencyLevel", "eventual")
requestFilter := "startswith(displayName, 'a')"
requestCount := true
requestTop := int32(1)
requestParameters := &graphgroups.GroupsRequestBuilderGetQueryParameters{
Filter: &requestFilter,
Count: &requestCount,
Top: &requestTop,
Orderby: [] string {"displayName"},
}
configuration := &graphgroups.GroupsRequestBuilderGetRequestConfiguration{
Headers: headers,
QueryParameters: requestParameters,
}
// To initialize your graphClient, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=go
groups, err := graphClient.Groups().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.groups().get(requestConfiguration -> {
requestConfiguration.queryParameters.filter = "startswith(displayName, 'a')";
requestConfiguration.queryParameters.count = true;
requestConfiguration.queryParameters.top = 1;
requestConfiguration.queryParameters.orderby = new String []{"displayName"};
requestConfiguration.headers.add("ConsistencyLevel", "eventual");
});
const options = {
authProvider,
};
const client = Client.init(options);
let groups = await client.api('/groups')
.version('beta')
.header('ConsistencyLevel','eventual')
.filter('startswith(displayName, \'a\')')
.orderby('displayName')
.top(1)
.get();
<?php
use Microsoft\Graph\Beta\GraphServiceClient;
use Microsoft\Graph\Beta\Generated\Groups\GroupsRequestBuilderGetRequestConfiguration;
$graphServiceClient = new GraphServiceClient($tokenRequestContext, $scopes);
$requestConfiguration = new GroupsRequestBuilderGetRequestConfiguration();
$headers = [
'ConsistencyLevel' => 'eventual',
];
$requestConfiguration->headers = $headers;
$queryParameters = GroupsRequestBuilderGetRequestConfiguration::createQueryParameters();
$queryParameters->filter = "startswith(displayName, 'a')";
$queryParameters->count = true;
$queryParameters->top = 1;
$queryParameters->orderby = ["displayName"];
$requestConfiguration->queryParameters = $queryParameters;
$result = $graphServiceClient->groups()->get($requestConfiguration)->wait();
Import-Module Microsoft.Graph.Beta.Groups
Get-MgBetaGroup -Filter "startswith(displayName, 'a')" -CountVariable CountVar -Top 1 -Sort "displayName" -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.groups.groups_request_builder import GroupsRequestBuilder
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 = GroupsRequestBuilder.GroupsRequestBuilderGetQueryParameters(
filter = "startswith(displayName, 'a')",
count = True,
top = 1,
orderby = ["displayName"],
)
request_configuration = RequestConfiguration(
query_parameters = query_params,
)
request_configuration.headers.add("ConsistencyLevel", "eventual")
result = await graph_client.groups.get(request_configuration = request_configuration)
応答
次の例は応答を示しています。
注: ここに示す応答オブジェクトは、読みやすさのために短縮されている場合があります。
HTTP/1.1 200 OK
Content-type: application/json
{
"@odata.context":"https://graph.microsoft.com/beta/$metadata#groups",
"@odata.count":1,
"value":[
{
"displayName":"a",
"mailNickname":"a241"
}
]
}
例 5: $searchを使用して、文字 'Video' を含む表示名を持つグループ、または返されたオブジェクトの数を含む文字 'prod' を含む説明を取得する
要求
次の例は要求を示しています。 この要求では、$search
が要求にあるため、ConsistencyLevel ヘッダーを eventual
に設定する必要があります。
ConsistencyLevel と $count
の使用の詳細については、「ディレクトリ オブジェクトに対する高度なクエリ機能」を参照してください。
注:$count
および$search
のクエリパラメーターは、現在 Azure ADB2C テナントでは使用できません。
GET https://graph.microsoft.com/beta/groups?$search="displayName:Video" OR "description:prod"&$orderby=displayName&$count=true
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.Groups.GetAsync((requestConfiguration) =>
{
requestConfiguration.QueryParameters.Search = "\"displayName:Video\" OR \"description:prod\"";
requestConfiguration.QueryParameters.Orderby = new string []{ "displayName" };
requestConfiguration.QueryParameters.Count = true;
requestConfiguration.Headers.Add("ConsistencyLevel", "eventual");
});
mgc-beta groups list --search ""displayName:Video" OR "description:prod"" --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"
graphgroups "github.com/microsoftgraph/msgraph-beta-sdk-go/groups"
//other-imports
)
headers := abstractions.NewRequestHeaders()
headers.Add("ConsistencyLevel", "eventual")
requestSearch := "\"displayName:Video\" OR \"description:prod\""
requestCount := true
requestParameters := &graphgroups.GroupsRequestBuilderGetQueryParameters{
Search: &requestSearch,
Orderby: [] string {"displayName"},
Count: &requestCount,
}
configuration := &graphgroups.GroupsRequestBuilderGetRequestConfiguration{
Headers: headers,
QueryParameters: requestParameters,
}
// To initialize your graphClient, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=go
groups, err := graphClient.Groups().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.groups().get(requestConfiguration -> {
requestConfiguration.queryParameters.search = "\"displayName:Video\" OR \"description:prod\"";
requestConfiguration.queryParameters.orderby = new String []{"displayName"};
requestConfiguration.queryParameters.count = true;
requestConfiguration.headers.add("ConsistencyLevel", "eventual");
});
<?php
use Microsoft\Graph\Beta\GraphServiceClient;
use Microsoft\Graph\Beta\Generated\Groups\GroupsRequestBuilderGetRequestConfiguration;
$graphServiceClient = new GraphServiceClient($tokenRequestContext, $scopes);
$requestConfiguration = new GroupsRequestBuilderGetRequestConfiguration();
$headers = [
'ConsistencyLevel' => 'eventual',
];
$requestConfiguration->headers = $headers;
$queryParameters = GroupsRequestBuilderGetRequestConfiguration::createQueryParameters();
$queryParameters->search = "\"displayName:Video\" OR \"description:prod\"";
$queryParameters->orderby = ["displayName"];
$queryParameters->count = true;
$requestConfiguration->queryParameters = $queryParameters;
$result = $graphServiceClient->groups()->get($requestConfiguration)->wait();
Import-Module Microsoft.Graph.Beta.Groups
Get-MgBetaGroup -Search '"displayName:Video" OR "description:prod"' -Sort "displayName" -CountVariable CountVar -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.groups.groups_request_builder import GroupsRequestBuilder
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 = GroupsRequestBuilder.GroupsRequestBuilderGetQueryParameters(
search = "\"displayName:Video\" OR \"description:prod\"",
orderby = ["displayName"],
count = True,
)
request_configuration = RequestConfiguration(
query_parameters = query_params,
)
request_configuration.headers.add("ConsistencyLevel", "eventual")
result = await graph_client.groups.get(request_configuration = request_configuration)
応答
次の例は応答を示しています。
注: ここに示す応答オブジェクトは、読みやすさのために短縮されている場合があります。
HTTP/1.1 200 OK
Content-type: application/json
{
"@odata.context":"https://graph.microsoft.com/beta/$metadata#groups",
"@odata.count":1396,
"value":[
{
"displayName":"SFA Videos",
"mail":"SFAVideos@service.contoso.com",
"mailNickname":"SFAVideos"
},
{
"description":"Video Production",
"displayName":"Video Production",
"mail":"videoprod@service.contoso.com",
"mailNickname":"VideoProduction"
}
]
}
例 6: 動的グループを一覧表示する
要求
次の例は、 membershipRuleProcessingState によってフィルター処理して動的グループを取得する要求を示しています。
groupTypes プロパティ (つまり、$filter=groupTypes/any(s:s eq 'DynamicMembership')
) でフィルター処理することもできます。 この要求では、$filter
クエリ パラメーターのnot
演算子を使用するため、ConsistencyLevel ヘッダーを eventual
および $count=true
クエリ文字列に設定することが必要です。
ConsistencyLevel と $count
の使用の詳細については、「ディレクトリ オブジェクトに対する高度なクエリ機能」を参照してください。
注:$count
および$search
のクエリパラメーターは、現在 Azure ADB2C テナントでは使用できません。
GET https://graph.microsoft.com/beta/groups?$filter=mailEnabled eq false and securityEnabled eq true and NOT(groupTypes/any(s:s eq 'Unified')) and membershipRuleProcessingState eq 'On'&$count=true&$select=id,membershipRule,membershipRuleProcessingState
// 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.Groups.GetAsync((requestConfiguration) =>
{
requestConfiguration.QueryParameters.Filter = "mailEnabled eq false and securityEnabled eq true and NOT(groupTypes/any(s:s eq 'Unified')) and membershipRuleProcessingState eq 'On'";
requestConfiguration.QueryParameters.Count = true;
requestConfiguration.QueryParameters.Select = new string []{ "id","membershipRule","membershipRuleProcessingState" };
});
mgc-beta groups list --filter "mailEnabled eq false and securityEnabled eq true and NOT(groupTypes/any(s:s eq 'Unified')) and membershipRuleProcessingState eq 'On'" --count "true" --select "id,membershipRule,membershipRuleProcessingState"
// 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"
graphgroups "github.com/microsoftgraph/msgraph-beta-sdk-go/groups"
//other-imports
)
requestFilter := "mailEnabled eq false and securityEnabled eq true and NOT(groupTypes/any(s:s eq 'Unified')) and membershipRuleProcessingState eq 'On'"
requestCount := true
requestParameters := &graphgroups.GroupsRequestBuilderGetQueryParameters{
Filter: &requestFilter,
Count: &requestCount,
Select: [] string {"id","membershipRule","membershipRuleProcessingState"},
}
configuration := &graphgroups.GroupsRequestBuilderGetRequestConfiguration{
QueryParameters: requestParameters,
}
// To initialize your graphClient, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=go
groups, err := graphClient.Groups().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.groups().get(requestConfiguration -> {
requestConfiguration.queryParameters.filter = "mailEnabled eq false and securityEnabled eq true and NOT(groupTypes/any(s:s eq 'Unified')) and membershipRuleProcessingState eq 'On'";
requestConfiguration.queryParameters.count = true;
requestConfiguration.queryParameters.select = new String []{"id", "membershipRule", "membershipRuleProcessingState"};
});
const options = {
authProvider,
};
const client = Client.init(options);
let groups = await client.api('/groups')
.version('beta')
.filter('mailEnabled eq false and securityEnabled eq true and NOT(groupTypes/any(s:s eq \'Unified\')) and membershipRuleProcessingState eq \'On\'')
.select('id,membershipRule,membershipRuleProcessingState')
.get();
<?php
use Microsoft\Graph\Beta\GraphServiceClient;
use Microsoft\Graph\Beta\Generated\Groups\GroupsRequestBuilderGetRequestConfiguration;
$graphServiceClient = new GraphServiceClient($tokenRequestContext, $scopes);
$requestConfiguration = new GroupsRequestBuilderGetRequestConfiguration();
$queryParameters = GroupsRequestBuilderGetRequestConfiguration::createQueryParameters();
$queryParameters->filter = "mailEnabled eq false and securityEnabled eq true and NOT(groupTypes/any(s:s eq 'Unified')) and membershipRuleProcessingState eq 'On'";
$queryParameters->count = true;
$queryParameters->select = ["id","membershipRule","membershipRuleProcessingState"];
$requestConfiguration->queryParameters = $queryParameters;
$result = $graphServiceClient->groups()->get($requestConfiguration)->wait();
Import-Module Microsoft.Graph.Beta.Groups
Get-MgBetaGroup -Filter "mailEnabled eq false and securityEnabled eq true and NOT(groupTypes/any(s:s eq 'Unified')) and membershipRuleProcessingState eq 'On'" -CountVariable CountVar -Property "id,membershipRule,membershipRuleProcessingState"
# Code snippets are only available for the latest version. Current version is 1.x
from msgraph_beta import GraphServiceClient
from msgraph_beta.generated.groups.groups_request_builder import GroupsRequestBuilder
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 = GroupsRequestBuilder.GroupsRequestBuilderGetQueryParameters(
filter = "mailEnabled eq false and securityEnabled eq true and NOT(groupTypes/any(s:s eq 'Unified')) and membershipRuleProcessingState eq 'On'",
count = True,
select = ["id","membershipRule","membershipRuleProcessingState"],
)
request_configuration = RequestConfiguration(
query_parameters = query_params,
)
result = await graph_client.groups.get(request_configuration = request_configuration)
応答
次の例は応答を示しています。
HTTP/1.1 200 OK
Content-type: application/json
{
"@odata.context": "https://graph.microsoft.com/beta/$metadata#groups(id,membershipRule,membershipRuleProcessingState)",
"@odata.count": 1,
"value": [
{
"@odata.id": "https://graph.microsoft.com/v2/84841066-274d-4ec0-a5c1-276be684bdd3/directoryObjects/e9f4a701-e7b5-4401-a0ca-5bd5f3cdcf4b/Microsoft.DirectoryServices.Group",
"id": "e9f4a701-e7b5-4401-a0ca-5bd5f3cdcf4b",
"membershipRule": "(user.userType -contains \"Guest\" and user.accountEnabled -eq true) or (user.city -eq \"Nairobi\")",
"membershipRuleProcessingState": "On"
}
]
}
例 7: ライセンスを持つグループを一覧表示し、グループのメンバーを取得する
要求
GET https://graph.microsoft.com/beta/groups?$select=id,assignedLicenses&$filter=assignedLicenses/any()&$expand=members($select=id,displayName)
// 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.Groups.GetAsync((requestConfiguration) =>
{
requestConfiguration.QueryParameters.Select = new string []{ "id","assignedLicenses" };
requestConfiguration.QueryParameters.Filter = "assignedLicenses/any()";
requestConfiguration.QueryParameters.Expand = new string []{ "members($select=id,displayName)" };
});
mgc-beta groups list --filter "assignedLicenses/any()" --select "id,assignedLicenses" --expand "members(\$select=id,displayName)"
// 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"
graphgroups "github.com/microsoftgraph/msgraph-beta-sdk-go/groups"
//other-imports
)
requestFilter := "assignedLicenses/any()"
requestParameters := &graphgroups.GroupsRequestBuilderGetQueryParameters{
Select: [] string {"id","assignedLicenses"},
Filter: &requestFilter,
Expand: [] string {"members($select=id,displayName)"},
}
configuration := &graphgroups.GroupsRequestBuilderGetRequestConfiguration{
QueryParameters: requestParameters,
}
// To initialize your graphClient, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=go
groups, err := graphClient.Groups().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.groups().get(requestConfiguration -> {
requestConfiguration.queryParameters.select = new String []{"id", "assignedLicenses"};
requestConfiguration.queryParameters.filter = "assignedLicenses/any()";
requestConfiguration.queryParameters.expand = new String []{"members($select=id,displayName)"};
});
const options = {
authProvider,
};
const client = Client.init(options);
let groups = await client.api('/groups')
.version('beta')
.filter('assignedLicenses/any()')
.expand('members($select=id,displayName)')
.select('id,assignedLicenses')
.get();
<?php
use Microsoft\Graph\Beta\GraphServiceClient;
use Microsoft\Graph\Beta\Generated\Groups\GroupsRequestBuilderGetRequestConfiguration;
$graphServiceClient = new GraphServiceClient($tokenRequestContext, $scopes);
$requestConfiguration = new GroupsRequestBuilderGetRequestConfiguration();
$queryParameters = GroupsRequestBuilderGetRequestConfiguration::createQueryParameters();
$queryParameters->select = ["id","assignedLicenses"];
$queryParameters->filter = "assignedLicenses/any()";
$queryParameters->expand = ["members(\$select=id,displayName)"];
$requestConfiguration->queryParameters = $queryParameters;
$result = $graphServiceClient->groups()->get($requestConfiguration)->wait();
Import-Module Microsoft.Graph.Beta.Groups
Get-MgBetaGroup -Property "id,assignedLicenses" -Filter "assignedLicenses/any()" -ExpandProperty "members(`$select=id,displayName)"
# Code snippets are only available for the latest version. Current version is 1.x
from msgraph_beta import GraphServiceClient
from msgraph_beta.generated.groups.groups_request_builder import GroupsRequestBuilder
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 = GroupsRequestBuilder.GroupsRequestBuilderGetQueryParameters(
select = ["id","assignedLicenses"],
filter = "assignedLicenses/any()",
expand = ["members($select=id,displayName)"],
)
request_configuration = RequestConfiguration(
query_parameters = query_params,
)
result = await graph_client.groups.get(request_configuration = request_configuration)
応答
次の例は応答を示しています。
HTTP/1.1 200 OK
Content-type: application/json
{
"@odata.context": "https://graph.microsoft.com/beta/$metadata#groups(id,assignedLicenses,members())",
"value": [
{
"id": "5caf712c-8483-4b3d-8384-d8da988c0ca4",
"assignedLicenses": [
{
"disabledPlans": [],
"skuId": "6fd2c87f-b296-42f0-b197-1e91e994b900"
}
],
"members": [
{
"@odata.type": "#microsoft.graph.user",
"id": "0952e4c8-432f-4950-a65c-769c45993527"
},
{
"@odata.type": "#microsoft.graph.user",
"id": "49e373b6-4717-40c6-ad43-843c45a258f0"
}
]
},
{
"id": "aae8ec2a-5a08-4013-ae70-fafbb5c20de1",
"assignedLicenses": [
{
"disabledPlans": [
"7547a3fe-08ee-4ccb-b430-5077c5041653"
],
"skuId": "18181a46-0d4e-45cd-891e-60aabd171b4e"
}
],
"members": []
}
]
}