グループの一覧表示
[アーティクル]
07/10/2022
3 人の共同作成者
この記事の内容
名前空間: microsoft.graph
動的配布グループを除き、組織内で使用可能なすべてのグループを一覧表示します。 動的配布グループを取得するには、Exchange 管理センターを使用します 。
この操作は既定で各グループのプロパティのサブセットのみを返します。 これらの既定のプロパティは、「プロパティ 」セクションに記載されています。 既定で 返されない プロパティを取得するには、グループに対して GET 操作を実行し、$select OData クエリ オプションでプロパティを指定します。 hasMembersWithLicenseErrors プロパティと isArchived プロパティは例外で、$select クエリでは返されません。
メモ: この要求には、最近作成、更新、または削除されたグループのレプリケーションの遅延が発生する可能性があります。
アクセス許可
この API を呼び出すには、次のいずれかのアクセス許可が必要です。アクセス許可の選択方法などの詳細については、「アクセス許可 」を参照してください。
アクセス許可の種類
アクセス許可 (特権の小さいものから大きいものへ)
委任 (職場または学校のアカウント)
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
HTTP 要求
GET /groups
オプションのクエリ パラメーター
このメソッドは、応答をカスタマイズするための $count、$expand、$filter、$orderBy、$search、$select、および $top OData クエリ パラメーター をサポートします。 既定のページ サイズと最大ページ サイズは、それぞれ 100 と 999 のグループ オブジェクトです。 クエリの中には、ConsistencyLevel ヘッダーの設定を eventual および $count に使用した場合にのみサポートされるものもあります。 詳細については、「Azure AD ディレクトリ オブジェクトの詳細クエリ機能 」を参照してください。
Microsoft 365 グループ (別名統合グループ) のみを一覧表示するには、groupTypes にフィルターを適用します。
GET https://graph.microsoft.com/v1.0/groups?$filter=groupTypes/any(c:c+eq+'Unified')
$search クエリ パラメーターでは、displayName と description フィールドにのみトークン化をサポートしており、ConsistencyLevel ヘッダーが必要です。 displayName と description 以外のフィールドは、既定で $filter startswith 動作になります。
OData クエリ オプションの詳細については、「OData クエリ パラメーター 」を参照してください。 ConsistencyLevel および $count の使用方法の詳細については、「Azure AD Directory オブジェクトの詳細クエリ機能 」を参照してください。
拡張機能と関連データを取得する
拡張機能の種類
コメント
スキーマ拡張機能
$select でのみ返されます。
オープン拡張機能
$expand でのみ返されます。
ディレクトリ拡張機能
既定で返されます。
名前
説明
Authorization
ベアラー {token}。必須。
ConsistencyLevel
最終的。 このヘッダーと $count は、$search を使用する場合、または $filter の特別な使用をする場合に必要です。 ConsistencyLevel および $count の使用方法の詳細については、「Azure AD ディレクトリ オブジェクトの詳細クエリ機能 」を参照してください。
要求本文
このメソッドには、要求本文を指定しません。
応答
成功した場合、このメソッドは 200 OK 応答コードと、応答本文で group オブジェクトのコレクションを返します。 応答には、各グループの既定のプロパティのみが含まれています。
例
例 1: グループの一覧を取得する
要求
要求の例を次に示します。
GET https://graph.microsoft.com/v1.0/groups
GraphServiceClient graphClient = new GraphServiceClient( authProvider );
var groups = await graphClient.Groups
.Request()
.GetAsync();
GraphServiceClient graphClient = new GraphServiceClient( authProvider );
var groups = await graphClient.Groups
.Request()
.GetAsync();
SDK をプロジェクトに追加し、authProvider インスタンスを作成する 方法の詳細については、SDK のドキュメントを参照してください 。
const options = {
authProvider,
};
const client = Client.init(options);
let groups = await client.api('/groups')
.get();
const options = {
authProvider,
};
const client = Client.init(options);
let groups = await client.api('/groups')
.get();
SDK をプロジェクトに追加し、authProvider インスタンスを作成する 方法の詳細については、SDK のドキュメントを参照してください 。
MSHTTPClient *httpClient = [MSClientFactory createHTTPClientWithAuthenticationProvider:authenticationProvider];
NSString *MSGraphBaseURL = @"https://graph.microsoft.com/v1.0/";
NSMutableURLRequest *urlRequest = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:[MSGraphBaseURL stringByAppendingString:@"/groups"]]];
[urlRequest setHTTPMethod:@"GET"];
MSURLSessionDataTask *meDataTask = [httpClient dataTaskWithRequest:urlRequest
completionHandler: ^(NSData *data, NSURLResponse *response, NSError *nserror) {
NSError *jsonError = nil;
MSCollection *collection = [[MSCollection alloc] initWithData:data error:&jsonError];
MSGraphGroup *group = [[MSGraphGroup alloc] initWithDictionary:[[collection value] objectAtIndex: 0] error:&nserror];
}];
[meDataTask execute];
MSHTTPClient *httpClient = [MSClientFactory createHTTPClientWithAuthenticationProvider:authenticationProvider];
NSString *MSGraphBaseURL = @"https://graph.microsoft.com/v1.0/";
NSMutableURLRequest *urlRequest = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:[MSGraphBaseURL stringByAppendingString:@"/groups"]]];
[urlRequest setHTTPMethod:@"GET"];
MSURLSessionDataTask *meDataTask = [httpClient dataTaskWithRequest:urlRequest
completionHandler: ^(NSData *data, NSURLResponse *response, NSError *nserror) {
NSError *jsonError = nil;
MSCollection *collection = [[MSCollection alloc] initWithData:data error:&jsonError];
MSGraphGroup *group = [[MSGraphGroup alloc] initWithDictionary:[[collection value] objectAtIndex: 0] error:&nserror];
}];
[meDataTask execute];
SDK をプロジェクトに追加し、authProvider インスタンスを作成する 方法の詳細については、SDK のドキュメントを参照してください 。
GraphServiceClient graphClient = GraphServiceClient.builder().authenticationProvider( authProvider ).buildClient();
GroupCollectionPage groups = graphClient.groups()
.buildRequest()
.get();
GraphServiceClient graphClient = GraphServiceClient.builder().authenticationProvider( authProvider ).buildClient();
GroupCollectionPage groups = graphClient.groups()
.buildRequest()
.get();
SDK をプロジェクトに追加し、authProvider インスタンスを作成する 方法の詳細については、SDK のドキュメントを参照してください 。
//THE GO SDK IS IN PREVIEW. NON-PRODUCTION USE ONLY
graphClient := msgraphsdk.NewGraphServiceClient(requestAdapter)
result, err := graphClient.Groups().Get()
//THE GO SDK IS IN PREVIEW. NON-PRODUCTION USE ONLY
graphClient := msgraphsdk.NewGraphServiceClient(requestAdapter)
result, err := graphClient.Groups().Get()
SDK をプロジェクトに追加し、authProvider インスタンスを作成する 方法の詳細については、SDK のドキュメントを参照してください 。
応答
応答の例を次に示します。
注: 読みやすくするために、ここに示す応答オブジェクトは短縮されている場合があります。実際の呼び出しでは、各グループのすべての既定のプロパティが返されます。
HTTP/1.1 200 OK
Content-type: application/json
{
"@odata.context": "https://graph.microsoft.com/v1.0/$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.onmicrosoft.com",
"SMTP:golfassist@contoso.com"
],
"renewedDateTime": "2018-12-22T02:21:05Z",
"resourceBehaviorOptions": [],
"resourceProvisioningOptions": [],
"securityEnabled": false,
"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.onmicrosoft.com",
"SMTP:golftalk@contoso.com"
],
"renewedDateTime": "2018-11-19T20:29:40Z",
"resourceBehaviorOptions": [],
"resourceProvisioningOptions": [],
"securityEnabled": false,
"theme": null,
"visibility": null,
"onPremisesProvisioningErrors": []
}
]
}
例 2: フィルター処理されたグループの一覧を取得する (返されたオブジェクトの数も含む)
要求の例を次に示します。 この要求では、$count が要求にあるため、ConsistencyLevel ヘッダーを eventual に設定する必要があります。 ConsistencyLevel および $count の使用方法の詳細については、「Azure AD ディレクトリ オブジェクトの詳細クエリ機能 」を参照してください。
注: $countおよび$searchのクエリパラメーターは、現在 Azure ADB2C テナントでは使用できません。
要求
GET https://graph.microsoft.com/v1.0/groups?$count=true&$filter=hasMembersWithLicenseErrors+eq+true&$select=id,displayName
ConsistencyLevel: eventual
GraphServiceClient graphClient = new GraphServiceClient( authProvider );
var queryOptions = new List<QueryOption>()
{
new QueryOption("$count", "true")
};
var groups = await graphClient.Groups
.Request( queryOptions )
.Header("ConsistencyLevel","eventual")
.Filter("hasMembersWithLicenseErrors eq true")
.Select("id,displayName")
.GetAsync();
GraphServiceClient graphClient = new GraphServiceClient( authProvider );
var queryOptions = new List<QueryOption>()
{
new QueryOption("$count", "true")
};
var groups = await graphClient.Groups
.Request( queryOptions )
.Header("ConsistencyLevel","eventual")
.Filter("hasMembersWithLicenseErrors eq true")
.Select("id,displayName")
.GetAsync();
SDK をプロジェクトに追加し、authProvider インスタンスを作成する 方法の詳細については、SDK のドキュメントを参照してください 。
const options = {
authProvider,
};
const client = Client.init(options);
let groups = await client.api('/groups')
.header('ConsistencyLevel','eventual')
.filter('hasMembersWithLicenseErrors eq true')
.select('id,displayName')
.get();
const options = {
authProvider,
};
const client = Client.init(options);
let groups = await client.api('/groups')
.header('ConsistencyLevel','eventual')
.filter('hasMembersWithLicenseErrors eq true')
.select('id,displayName')
.get();
SDK をプロジェクトに追加し、authProvider インスタンスを作成する 方法の詳細については、SDK のドキュメントを参照してください 。
MSHTTPClient *httpClient = [MSClientFactory createHTTPClientWithAuthenticationProvider:authenticationProvider];
NSString *MSGraphBaseURL = @"https://graph.microsoft.com/v1.0/";
NSMutableURLRequest *urlRequest = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:[MSGraphBaseURL stringByAppendingString:@"/groups?$count=true&$filter=hasMembersWithLicenseErrors%20eq%20true&$select=id,displayName"]]];
[urlRequest setHTTPMethod:@"GET"];
[urlRequest setValue:@"eventual" forHTTPHeaderField:@"ConsistencyLevel"];
MSURLSessionDataTask *meDataTask = [httpClient dataTaskWithRequest:urlRequest
completionHandler: ^(NSData *data, NSURLResponse *response, NSError *nserror) {
NSError *jsonError = nil;
MSCollection *collection = [[MSCollection alloc] initWithData:data error:&jsonError];
MSGraphGroup *group = [[MSGraphGroup alloc] initWithDictionary:[[collection value] objectAtIndex: 0] error:&nserror];
}];
[meDataTask execute];
MSHTTPClient *httpClient = [MSClientFactory createHTTPClientWithAuthenticationProvider:authenticationProvider];
NSString *MSGraphBaseURL = @"https://graph.microsoft.com/v1.0/";
NSMutableURLRequest *urlRequest = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:[MSGraphBaseURL stringByAppendingString:@"/groups?$count=true&$filter=hasMembersWithLicenseErrors%20eq%20true&$select=id,displayName"]]];
[urlRequest setHTTPMethod:@"GET"];
[urlRequest setValue:@"eventual" forHTTPHeaderField:@"ConsistencyLevel"];
MSURLSessionDataTask *meDataTask = [httpClient dataTaskWithRequest:urlRequest
completionHandler: ^(NSData *data, NSURLResponse *response, NSError *nserror) {
NSError *jsonError = nil;
MSCollection *collection = [[MSCollection alloc] initWithData:data error:&jsonError];
MSGraphGroup *group = [[MSGraphGroup alloc] initWithDictionary:[[collection value] objectAtIndex: 0] error:&nserror];
}];
[meDataTask execute];
SDK をプロジェクトに追加し、authProvider インスタンスを作成する 方法の詳細については、SDK のドキュメントを参照してください 。
GraphServiceClient graphClient = GraphServiceClient.builder().authenticationProvider( authProvider ).buildClient();
LinkedList<Option> requestOptions = new LinkedList<Option>();
requestOptions.add(new HeaderOption("ConsistencyLevel", "eventual"));
GroupCollectionPage groups = graphClient.groups()
.buildRequest( requestOptions )
.filter("hasMembersWithLicenseErrors eq true")
.select("id,displayName")
.get();
GraphServiceClient graphClient = GraphServiceClient.builder().authenticationProvider( authProvider ).buildClient();
LinkedList<Option> requestOptions = new LinkedList<Option>();
requestOptions.add(new HeaderOption("ConsistencyLevel", "eventual"));
GroupCollectionPage groups = graphClient.groups()
.buildRequest( requestOptions )
.filter("hasMembersWithLicenseErrors eq true")
.select("id,displayName")
.get();
SDK をプロジェクトに追加し、authProvider インスタンスを作成する 方法の詳細については、SDK のドキュメントを参照してください 。
//THE GO SDK IS IN PREVIEW. NON-PRODUCTION USE ONLY
graphClient := msgraphsdk.NewGraphServiceClient(requestAdapter)
requestParameters := &msgraphsdk.GroupsRequestBuilderGetQueryParameters{
Count: true,
Filter: "hasMembersWithLicenseErrors%20eq%20true",
Select: "id,displayName",
}
headers := map[string]string{
"ConsistencyLevel": "eventual"
}
options := &msgraphsdk.GroupsRequestBuilderGetRequestConfiguration{
QueryParameters: requestParameters,
Headers: headers,
}
result, err := graphClient.Groups().GetWithRequestConfigurationAndResponseHandler(options, nil)
//THE GO SDK IS IN PREVIEW. NON-PRODUCTION USE ONLY
graphClient := msgraphsdk.NewGraphServiceClient(requestAdapter)
requestParameters := &msgraphsdk.GroupsRequestBuilderGetQueryParameters{
Count: true,
Filter: "hasMembersWithLicenseErrors%20eq%20true",
Select: "id,displayName",
}
headers := map[string]string{
"ConsistencyLevel": "eventual"
}
options := &msgraphsdk.GroupsRequestBuilderGetRequestConfiguration{
QueryParameters: requestParameters,
Headers: headers,
}
result, err := graphClient.Groups().GetWithRequestConfigurationAndResponseHandler(options, nil)
SDK をプロジェクトに追加し、authProvider インスタンスを作成する 方法の詳細については、SDK のドキュメントを参照してください 。
Import-Module Microsoft.Graph.Groups
Get-MgGroup -CountVariable CountVar -Filter "hasMembersWithLicenseErrors eq true" -Property "id,displayName" -ConsistencyLevel eventual
Import-Module Microsoft.Graph.Groups
Get-MgGroup -CountVariable CountVar -Filter "hasMembersWithLicenseErrors eq true" -Property "id,displayName" -ConsistencyLevel eventual
SDK をプロジェクトに追加し、authProvider インスタンスを作成する 方法の詳細については、SDK のドキュメントを参照してください 。
応答
要求したプロパティのみを含む応答の例を次に示します。
HTTP/1.1 200 OK
Content-type: application/json
{
"@odata.context":"https://graph.microsoft.com/v1.0/$metadata#groups(id,displayName)",
"@odata.count":2,
"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 の使用方法の詳細については、「Azure AD ディレクトリ オブジェクトの詳細クエリ機能 」を参照してください。
注: $countおよび$searchのクエリパラメーターは、現在 Azure ADB2C テナントでは使用できません。
GET https://graph.microsoft.com/v1.0/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 の使用方法の詳細については、「Azure AD ディレクトリ オブジェクトの詳細クエリ機能 」を参照してください。
注: $countおよび$searchのクエリパラメーターは、現在 Azure ADB2C テナントでは使用できません。
GET https://graph.microsoft.com/v1.0/groups?$filter=startswith(displayName, 'a')&$count=true&$top=1&$orderby=displayName
ConsistencyLevel: eventual
GraphServiceClient graphClient = new GraphServiceClient( authProvider );
var queryOptions = new List<QueryOption>()
{
new QueryOption("$count", "true")
};
var groups = await graphClient.Groups
.Request( queryOptions )
.Header("ConsistencyLevel","eventual")
.Filter("startswith(displayName, 'a')")
.OrderBy("displayName")
.Top(1)
.GetAsync();
GraphServiceClient graphClient = new GraphServiceClient( authProvider );
var queryOptions = new List<QueryOption>()
{
new QueryOption("$count", "true")
};
var contacts = await graphClient.Contacts
.Request( queryOptions )
.Header("ConsistencyLevel","eventual")
.Filter("startswith(displayName,'A')")
.OrderBy("displayName")
.Top(1)
.GetAsync();
SDK をプロジェクトに追加し、authProvider インスタンスを作成する 方法の詳細については、SDK のドキュメントを参照してください 。
const options = {
authProvider,
};
const client = Client.init(options);
let groups = await client.api('/groups')
.header('ConsistencyLevel','eventual')
.filter('startswith(displayName, \'a\')')
.orderby('displayName')
.top(1)
.get();
const options = {
authProvider,
};
const client = Client.init(options);
let devices = await client.api('/devices')
.header('ConsistencyLevel','eventual')
.filter('startswith(displayName, \'a\')')
.orderby('displayName')
.top(1)
.get();
SDK をプロジェクトに追加し、authProvider インスタンスを作成する 方法の詳細については、SDK のドキュメントを参照してください 。
MSHTTPClient *httpClient = [MSClientFactory createHTTPClientWithAuthenticationProvider:authenticationProvider];
NSString *MSGraphBaseURL = @"https://graph.microsoft.com/v1.0/";
NSMutableURLRequest *urlRequest = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:[MSGraphBaseURL stringByAppendingString:@"/groups?$filter=startswith(displayName,%20'a')&$count=true&$top=1&$orderby=displayName"]]];
[urlRequest setHTTPMethod:@"GET"];
[urlRequest setValue:@"eventual" forHTTPHeaderField:@"ConsistencyLevel"];
MSURLSessionDataTask *meDataTask = [httpClient dataTaskWithRequest:urlRequest
completionHandler: ^(NSData *data, NSURLResponse *response, NSError *nserror) {
NSError *jsonError = nil;
MSCollection *collection = [[MSCollection alloc] initWithData:data error:&jsonError];
MSGraphGroup *group = [[MSGraphGroup alloc] initWithDictionary:[[collection value] objectAtIndex: 0] error:&nserror];
}];
[meDataTask execute];
MSHTTPClient *httpClient = [MSClientFactory createHTTPClientWithAuthenticationProvider:authenticationProvider];
NSString *MSGraphBaseURL = @"https://graph.microsoft.com/v1.0/";
NSMutableURLRequest *urlRequest = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:[MSGraphBaseURL stringByAppendingString:@"/devices?$filter=startswith(displayName,%20'a')&$count=true&$top=1&$orderby=displayName"]]];
[urlRequest setHTTPMethod:@"GET"];
[urlRequest setValue:@"eventual" forHTTPHeaderField:@"ConsistencyLevel"];
MSURLSessionDataTask *meDataTask = [httpClient dataTaskWithRequest:urlRequest
completionHandler: ^(NSData *data, NSURLResponse *response, NSError *nserror) {
NSError *jsonError = nil;
MSCollection *collection = [[MSCollection alloc] initWithData:data error:&jsonError];
MSGraphDevice *device = [[MSGraphDevice alloc] initWithDictionary:[[collection value] objectAtIndex: 0] error:&nserror];
}];
[meDataTask execute];
SDK をプロジェクトに追加し、authProvider インスタンスを作成する 方法の詳細については、SDK のドキュメントを参照してください 。
GraphServiceClient graphClient = GraphServiceClient.builder().authenticationProvider( authProvider ).buildClient();
LinkedList<Option> requestOptions = new LinkedList<Option>();
requestOptions.add(new HeaderOption("ConsistencyLevel", "eventual"));
GroupCollectionPage groups = graphClient.groups()
.buildRequest( requestOptions )
.filter("startswith(displayName, 'a')")
.orderBy("displayName")
.top(1)
.get();
GraphServiceClient graphClient = GraphServiceClient.builder().authenticationProvider( authProvider ).buildClient();
LinkedList<Option> requestOptions = new LinkedList<Option>();
requestOptions.add(new HeaderOption("ConsistencyLevel", "eventual"));
DeviceCollectionPage devices = graphClient.devices()
.buildRequest( requestOptions )
.filter("startswith(displayName, 'a')")
.orderBy("displayName")
.top(1)
.get();
SDK をプロジェクトに追加し、authProvider インスタンスを作成する 方法の詳細については、SDK のドキュメントを参照してください 。
//THE GO SDK IS IN PREVIEW. NON-PRODUCTION USE ONLY
graphClient := msgraphsdk.NewGraphServiceClient(requestAdapter)
requestParameters := &msgraphsdk.GroupsRequestBuilderGetQueryParameters{
Filter: "startswith(displayName,%20'a')",
Count: true,
Top: 1,
Orderby: "displayName",
}
headers := map[string]string{
"ConsistencyLevel": "eventual"
}
options := &msgraphsdk.GroupsRequestBuilderGetRequestConfiguration{
QueryParameters: requestParameters,
Headers: headers,
}
result, err := graphClient.Groups().GetWithRequestConfigurationAndResponseHandler(options, nil)
//THE GO SDK IS IN PREVIEW. NON-PRODUCTION USE ONLY
graphClient := msgraphsdk.NewGraphServiceClient(requestAdapter)
requestParameters := &msgraphsdk.ContactsRequestBuilderGetQueryParameters{
Filter: "startswith(displayName,'A')",
Count: true,
Top: 1,
Orderby: "displayName",
}
headers := map[string]string{
"ConsistencyLevel": "eventual"
}
options := &msgraphsdk.ContactsRequestBuilderGetOptions{
Q: requestParameters,
H: headers,
}
result, err := graphClient.Contacts().Get(options)
SDK をプロジェクトに追加し、authProvider インスタンスを作成する 方法の詳細については、SDK のドキュメントを参照してください 。
Import-Module Microsoft.Graph.Groups
Get-MgGroup -Filter "startswith(displayName, 'a')" -CountVariable CountVar -Top 1 -Sort "displayName" -ConsistencyLevel eventual
Import-Module Microsoft.Graph.Identity.DirectoryManagement
Get-MgContact -Filter "startswith(displayName,'A')" -CountVariable CountVar -Top 1 -Sort "displayName" -ConsistencyLevel eventual
SDK をプロジェクトに追加し、authProvider インスタンスを作成する 方法の詳細については、SDK のドキュメントを参照してください 。
応答
応答の例を次に示します。
注: ここに示す応答オブジェクトは、読みやすさのために短縮されている場合があります。
HTTP/1.1 200 OK
Content-type: application/json
{
"@odata.context":"https://graph.microsoft.com/v1.0/$metadata#groups",
"@odata.count":1,
"value":[
{
"displayName":"a",
"mailNickname":"a241"
}
]
}
例 5: $search を使用して、表示名に「Video」の文字が含まれるグループを取得する (返されたオブジェクトの数も含む)
要求
要求の例を次に示します。 この要求では、$search が要求にあるため、ConsistencyLevel ヘッダーを eventual に設定する必要があります。 ConsistencyLevel および $count の使用方法の詳細については、「Azure AD ディレクトリ オブジェクトの詳細クエリ機能 」を参照してください。
注: $countおよび$searchのクエリパラメーターは、現在 Azure ADB2C テナントでは使用できません。
GET https://graph.microsoft.com/v1.0/groups?$search="displayName:Video"&$count=true
ConsistencyLevel: eventual
応答
応答の例を次に示します。
注: ここに示す応答オブジェクトは、読みやすさのために短縮されている場合があります。
HTTP/1.1 200 OK
Content-type: application/json
{
"@odata.context":"https://graph.microsoft.com/v1.0/$metadata#groups",
"@odata.count":1396,
"value":[
{
"displayName":"SFA Videos",
"mail":"SFAVideos@service.contoso.com",
"mailNickname":"SFAVideos"
}
]
}
例 6: $search を使用して、表示名に「Video」の文字が含まれるグループ、または説明に「prod」の文字を含むグループを取得する (返されたオブジェクトの数も含む)
要求
要求の例を次に示します。 この要求では、$search が要求にあるため、ConsistencyLevel ヘッダーを eventual に設定する必要があります。 ConsistencyLevel および $count の使用方法の詳細については、「Azure AD ディレクトリ オブジェクトの詳細クエリ機能 」を参照してください。
注: $countおよび$searchのクエリパラメーターは、現在 Azure ADB2C テナントでは使用できません。
GET https://graph.microsoft.com/v1.0/groups?$search="displayName:Video" OR "description:prod"&$orderby=displayName&$count=true
ConsistencyLevel: eventual
応答
応答の例を次に示します。
注: ここに示す応答オブジェクトは、読みやすさのために短縮されている場合があります。
HTTP/1.1 200 OK
Content-type: application/json
{
"@odata.context":"https://graph.microsoft.com/v1.0/$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"
}
]
}
例 7: 動的セキュリティ グループを一覧表示する
要求
membershipRuleProcessingState でフィルター処理して動的グループを取得する要求の例を次に示します。 groupTypes プロパティ (つまり、$filter=groupTypes/any(s:s eq 'DynamicMembership')) でフィルター処理することもできます。 この要求では、$filterクエリ パラメーターのnot演算子を使用するため、ConsistencyLevel ヘッダーを eventual および $count=true クエリ文字列に設定することが必要です。 ConsistencyLevel および $count の使用方法の詳細については、「Azure AD ディレクトリ オブジェクトの詳細クエリ機能 」を参照してください。
注: $countおよび$searchのクエリパラメーターは、現在 Azure ADB2C テナントでは使用できません。
GET https://graph.microsoft.com/v1.0/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
ConsistencyLevel: eventual
GraphServiceClient graphClient = new GraphServiceClient( authProvider );
var queryOptions = new List<QueryOption>()
{
new QueryOption("$count", "true")
};
var groups = await graphClient.Groups
.Request( queryOptions )
.Header("ConsistencyLevel","eventual")
.Filter("mailEnabled eq false and securityEnabled eq true and NOT(groupTypes/any(s:s eq 'Unified')) and membershipRuleProcessingState eq 'On'")
.Select("id,membershipRule,membershipRuleProcessingState")
.GetAsync();
GraphServiceClient graphClient = new GraphServiceClient( authProvider );
var queryOptions = new List<QueryOption>()
{
new QueryOption("$count", "true")
};
var groups = await graphClient.Groups
.Request( queryOptions )
.Header("ConsistencyLevel","eventual")
.Filter("mailEnabled eq false and securityEnabled eq true and NOT(groupTypes/any(s:s eq 'Unified')) and membershipRuleProcessingState eq 'On'")
.Select("id,membershipRule,membershipRuleProcessingState")
.GetAsync();
SDK をプロジェクトに追加し、authProvider インスタンスを作成する 方法の詳細については、SDK のドキュメントを参照してください 。
const options = {
authProvider,
};
const client = Client.init(options);
let groups = await client.api('/groups')
.header('ConsistencyLevel','eventual')
.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();
const options = {
authProvider,
};
const client = Client.init(options);
let groups = await client.api('/groups')
.header('ConsistencyLevel','eventual')
.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();
SDK をプロジェクトに追加し、authProvider インスタンスを作成する 方法の詳細については、SDK のドキュメントを参照してください 。
MSHTTPClient *httpClient = [MSClientFactory createHTTPClientWithAuthenticationProvider:authenticationProvider];
NSString *MSGraphBaseURL = @"https://graph.microsoft.com/v1.0/";
NSMutableURLRequest *urlRequest = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:[MSGraphBaseURL stringByAppendingString:@"/groups?$filter=mailEnabled%20eq%20false%20and%20securityEnabled%20eq%20true%20and%20NOT(groupTypes/any(s:s%20eq%20'Unified'))%20and%20membershipRuleProcessingState%20eq%20'On'&$count=true&$select=id,membershipRule,membershipRuleProcessingState"]]];
[urlRequest setHTTPMethod:@"GET"];
[urlRequest setValue:@"eventual" forHTTPHeaderField:@"ConsistencyLevel"];
MSURLSessionDataTask *meDataTask = [httpClient dataTaskWithRequest:urlRequest
completionHandler: ^(NSData *data, NSURLResponse *response, NSError *nserror) {
NSError *jsonError = nil;
MSCollection *collection = [[MSCollection alloc] initWithData:data error:&jsonError];
MSGraphGroup *group = [[MSGraphGroup alloc] initWithDictionary:[[collection value] objectAtIndex: 0] error:&nserror];
}];
[meDataTask execute];
MSHTTPClient *httpClient = [MSClientFactory createHTTPClientWithAuthenticationProvider:authenticationProvider];
NSString *MSGraphBaseURL = @"https://graph.microsoft.com/v1.0/";
NSMutableURLRequest *urlRequest = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:[MSGraphBaseURL stringByAppendingString:@"/groups?$filter=mailEnabled%20eq%20false%20and%20securityEnabled%20eq%20true%20and%20NOT(groupTypes/any(s:s%20eq%20'Unified'))%20and%20membershipRuleProcessingState%20eq%20'On'&$count=true&$select=id,membershipRule,membershipRuleProcessingState"]]];
[urlRequest setHTTPMethod:@"GET"];
[urlRequest setValue:@"eventual" forHTTPHeaderField:@"ConsistencyLevel"];
MSURLSessionDataTask *meDataTask = [httpClient dataTaskWithRequest:urlRequest
completionHandler: ^(NSData *data, NSURLResponse *response, NSError *nserror) {
NSError *jsonError = nil;
MSCollection *collection = [[MSCollection alloc] initWithData:data error:&jsonError];
MSGraphGroup *group = [[MSGraphGroup alloc] initWithDictionary:[[collection value] objectAtIndex: 0] error:&nserror];
}];
[meDataTask execute];
SDK をプロジェクトに追加し、authProvider インスタンスを作成する 方法の詳細については、SDK のドキュメントを参照してください 。
GraphServiceClient graphClient = GraphServiceClient.builder().authenticationProvider( authProvider ).buildClient();
LinkedList<Option> requestOptions = new LinkedList<Option>();
requestOptions.add(new HeaderOption("ConsistencyLevel", "eventual"));
GroupCollectionPage groups = graphClient.groups()
.buildRequest( requestOptions )
.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();
GraphServiceClient graphClient = GraphServiceClient.builder().authenticationProvider( authProvider ).buildClient();
LinkedList<Option> requestOptions = new LinkedList<Option>();
requestOptions.add(new HeaderOption("ConsistencyLevel", "eventual"));
GroupCollectionPage groups = graphClient.groups()
.buildRequest( requestOptions )
.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();
SDK をプロジェクトに追加し、authProvider インスタンスを作成する 方法の詳細については、SDK のドキュメントを参照してください 。
//THE GO SDK IS IN PREVIEW. NON-PRODUCTION USE ONLY
graphClient := msgraphsdk.NewGraphServiceClient(requestAdapter)
requestParameters := &msgraphsdk.GroupsRequestBuilderGetQueryParameters{
Filter: "mailEnabled%20eq%20false%20and%20securityEnabled%20eq%20true%20and%20NOT(groupTypes/any(s:s%20eq%20'Unified'))%20and%20membershipRuleProcessingState%20eq%20'On'",
Count: true,
Select: "id,membershipRule,membershipRuleProcessingState",
}
headers := map[string]string{
"ConsistencyLevel": "eventual"
}
options := &msgraphsdk.GroupsRequestBuilderGetRequestConfiguration{
QueryParameters: requestParameters,
Headers: headers,
}
result, err := graphClient.Groups().GetWithRequestConfigurationAndResponseHandler(options, nil)
//THE GO SDK IS IN PREVIEW. NON-PRODUCTION USE ONLY
graphClient := msgraphsdk.NewGraphServiceClient(requestAdapter)
requestParameters := &msgraphsdk.GroupsRequestBuilderGetQueryParameters{
Filter: "mailEnabled%20eq%20false%20and%20securityEnabled%20eq%20true%20and%20NOT(groupTypes/any(s:s%20eq%20'Unified'))%20and%20membershipRuleProcessingState%20eq%20'On'",
Count: true,
Select: "id,membershipRule,membershipRuleProcessingState",
}
headers := map[string]string{
"ConsistencyLevel": "eventual"
}
options := &msgraphsdk.GroupsRequestBuilderGetRequestConfiguration{
QueryParameters: requestParameters,
Headers: headers,
}
result, err := graphClient.Groups().GetWithRequestConfigurationAndResponseHandler(options, nil)
SDK をプロジェクトに追加し、authProvider インスタンスを作成する 方法の詳細については、SDK のドキュメントを参照してください 。
Import-Module Microsoft.Graph.Groups
Get-MgGroup -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" -ConsistencyLevel eventual
Import-Module Microsoft.Graph.Groups
Get-MgGroup -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" -ConsistencyLevel eventual
SDK をプロジェクトに追加し、authProvider インスタンスを作成する 方法の詳細については、SDK のドキュメントを参照してください 。
応答
応答の例を次に示します。
HTTP/1.1 200 OK
Content-type: application/json
{
"@odata.context": "https://graph.microsoft.com/v1.0/$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/v1.0/groups?$select=id,assignedLicenses&$filter=assignedLicenses/any()
GraphServiceClient graphClient = new GraphServiceClient( authProvider );
var groups = await graphClient.Groups
.Request()
.Filter("assignedLicenses/any()")
.Select("id,assignedLicenses")
.GetAsync();
GraphServiceClient graphClient = new GraphServiceClient( authProvider );
var groups = await graphClient.Groups
.Request()
.Filter("assignedLicenses/any()")
.Select("id,assignedLicenses")
.GetAsync();
SDK をプロジェクトに追加し、authProvider インスタンスを作成する 方法の詳細については、SDK のドキュメントを参照してください 。
const options = {
authProvider,
};
const client = Client.init(options);
let groups = await client.api('/groups')
.filter('assignedLicenses/any()')
.select('id,assignedLicenses')
.get();
const options = {
authProvider,
};
const client = Client.init(options);
let groups = await client.api('/groups')
.filter('assignedLicenses/any()')
.select('id,assignedLicenses')
.get();
SDK をプロジェクトに追加し、authProvider インスタンスを作成する 方法の詳細については、SDK のドキュメントを参照してください 。
MSHTTPClient *httpClient = [MSClientFactory createHTTPClientWithAuthenticationProvider:authenticationProvider];
NSString *MSGraphBaseURL = @"https://graph.microsoft.com/v1.0/";
NSMutableURLRequest *urlRequest = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:[MSGraphBaseURL stringByAppendingString:@"/groups?$select=id,assignedLicenses&$filter=assignedLicenses/any()"]]];
[urlRequest setHTTPMethod:@"GET"];
MSURLSessionDataTask *meDataTask = [httpClient dataTaskWithRequest:urlRequest
completionHandler: ^(NSData *data, NSURLResponse *response, NSError *nserror) {
NSError *jsonError = nil;
MSCollection *collection = [[MSCollection alloc] initWithData:data error:&jsonError];
MSGraphGroup *group = [[MSGraphGroup alloc] initWithDictionary:[[collection value] objectAtIndex: 0] error:&nserror];
}];
[meDataTask execute];
MSHTTPClient *httpClient = [MSClientFactory createHTTPClientWithAuthenticationProvider:authenticationProvider];
NSString *MSGraphBaseURL = @"https://graph.microsoft.com/v1.0/";
NSMutableURLRequest *urlRequest = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:[MSGraphBaseURL stringByAppendingString:@"/groups?$select=id,assignedLicenses&$filter=assignedLicenses/any()"]]];
[urlRequest setHTTPMethod:@"GET"];
MSURLSessionDataTask *meDataTask = [httpClient dataTaskWithRequest:urlRequest
completionHandler: ^(NSData *data, NSURLResponse *response, NSError *nserror) {
NSError *jsonError = nil;
MSCollection *collection = [[MSCollection alloc] initWithData:data error:&jsonError];
MSGraphGroup *group = [[MSGraphGroup alloc] initWithDictionary:[[collection value] objectAtIndex: 0] error:&nserror];
}];
[meDataTask execute];
SDK をプロジェクトに追加し、authProvider インスタンスを作成する 方法の詳細については、SDK のドキュメントを参照してください 。
GraphServiceClient graphClient = GraphServiceClient.builder().authenticationProvider( authProvider ).buildClient();
GroupCollectionPage groups = graphClient.groups()
.buildRequest()
.filter("assignedLicenses/any()")
.select("id,assignedLicenses")
.get();
GraphServiceClient graphClient = GraphServiceClient.builder().authenticationProvider( authProvider ).buildClient();
GroupCollectionPage groups = graphClient.groups()
.buildRequest()
.filter("assignedLicenses/any()")
.select("id,assignedLicenses")
.get();
SDK をプロジェクトに追加し、authProvider インスタンスを作成する 方法の詳細については、SDK のドキュメントを参照してください 。
//THE GO SDK IS IN PREVIEW. NON-PRODUCTION USE ONLY
graphClient := msgraphsdk.NewGraphServiceClient(requestAdapter)
requestParameters := &msgraphsdk.GroupsRequestBuilderGetQueryParameters{
Select: "id,assignedLicenses",
Filter: "assignedLicenses/any()",
}
options := &msgraphsdk.GroupsRequestBuilderGetRequestConfiguration{
QueryParameters: requestParameters,
}
result, err := graphClient.Groups().GetWithRequestConfigurationAndResponseHandler(options, nil)
//THE GO SDK IS IN PREVIEW. NON-PRODUCTION USE ONLY
graphClient := msgraphsdk.NewGraphServiceClient(requestAdapter)
requestParameters := &msgraphsdk.GroupsRequestBuilderGetQueryParameters{
Select: "id,assignedLicenses",
Filter: "assignedLicenses/any()",
}
options := &msgraphsdk.GroupsRequestBuilderGetRequestConfiguration{
QueryParameters: requestParameters,
}
result, err := graphClient.Groups().GetWithRequestConfigurationAndResponseHandler(options, nil)
SDK をプロジェクトに追加し、authProvider インスタンスを作成する 方法の詳細については、SDK のドキュメントを参照してください 。
Import-Module Microsoft.Graph.Groups
Get-MgGroup -Property "id,assignedLicenses" -Filter "assignedLicenses/any()"
Import-Module Microsoft.Graph.Groups
Get-MgGroup -Property "id,assignedLicenses" -Filter "assignedLicenses/any()"
SDK をプロジェクトに追加し、authProvider インスタンスを作成する 方法の詳細については、SDK のドキュメントを参照してください 。
応答
応答の例を次に示します。
HTTP/1.1 200 OK
Content-type: application/json
{
"@odata.context": "https://graph.microsoft.com/v1.0/$metadata#groups(id,assignedLicenses)",
"value": [
{
"id": "5caf712c-8483-4b3d-8384-d8da988c0ca4",
"assignedLicenses": [
{
"disabledPlans": [],
"skuId": "6fd2c87f-b296-42f0-b197-1e91e994b900"
}
]
},
{
"id": "aae8ec2a-5a08-4013-ae70-fafbb5c20de1",
"assignedLicenses": [
{
"disabledPlans": [
"7547a3fe-08ee-4ccb-b430-5077c5041653"
],
"skuId": "18181a46-0d4e-45cd-891e-60aabd171b4e"
}
]
},
{
"id": "e55bdaa0-e104-479a-979e-b0457fff6380",
"assignedLicenses": [
{
"disabledPlans": [
"7547a3fe-08ee-4ccb-b430-5077c5041653"
],
"skuId": "6fd2c87f-b296-42f0-b197-1e91e994b900"
}
]
}
]
}