Choose the permission or permissions marked as least privileged for this API. Use a higher privileged permission or permissions only if your app requires it. For details about delegated and application permissions, see Permission types. To learn more about these permissions, see the permissions reference.
Permission type
Least privileged permissions
Higher privileged permissions
Delegated (work or school account)
Directory.Read.All
Not available.
Delegated (personal Microsoft account)
Not supported.
Not supported.
Application
Directory.Read.All
Not available.
When an application queries a relationship that returns a directoryObject type collection, if it does not have permission to read a certain derived type (like device), members of that type are returned but with limited information. With this behavior, applications can request the least privileged permissions they need, rather than rely on the set of Directory.* permissions. For details, see Limited information returned for inaccessible member objects.
In the request body, provide a JSON object with the following parameters.
Parameter
Type
Description
ids
String collection
A collection of IDs for which to return objects. The IDs are GUIDs, represented as strings. You can specify up to 1000 IDs.
types
String collection
A collection of resource types that specifies the set of resource collections to search. If not specified, the default is directoryObject, which contains all of the resource types defined in the directory. Any object that derives from directoryObject may be specified in the collection; for example: user, group, and device objects.
// Code snippets are only available for the latest version. Current version is 5.x
// Dependencies
using Microsoft.Graph.DirectoryObjects.GetByIds;
var requestBody = new GetByIdsPostRequestBody
{
Ids = new List<string>
{
"84b80893-8749-40a3-97b7-68513b600544",
"5d6059b6-368d-45f8-91e1-8e07d485f1d0",
"0b944de3-e0fc-4774-a49a-b135213725ef",
"b75a5ab2-fe55-4463-bd31-d21ad555c6e0",
},
Types = new List<string>
{
"user",
"group",
"device",
},
};
// To initialize your graphClient, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=csharp
var result = await graphClient.DirectoryObjects.GetByIds.PostAsGetByIdsPostResponseAsync(requestBody);
// THE CLI IS IN PREVIEW. NON-PRODUCTION USE ONLY
mgc directory-objects get-by-ids post --body '{\
"ids": [\
"84b80893-8749-40a3-97b7-68513b600544",\
"5d6059b6-368d-45f8-91e1-8e07d485f1d0",\
"0b944de3-e0fc-4774-a49a-b135213725ef",\
"b75a5ab2-fe55-4463-bd31-d21ad555c6e0"\
],\
"types": [\
"user",\
"group",\
"device"\
]\
}\
'
// Code snippets are only available for the latest version. Current version is 6.x
GraphServiceClient graphClient = new GraphServiceClient(requestAdapter);
com.microsoft.graph.directoryobjects.getbyids.GetByIdsPostRequestBody getByIdsPostRequestBody = new com.microsoft.graph.directoryobjects.getbyids.GetByIdsPostRequestBody();
LinkedList<String> ids = new LinkedList<String>();
ids.add("84b80893-8749-40a3-97b7-68513b600544");
ids.add("5d6059b6-368d-45f8-91e1-8e07d485f1d0");
ids.add("0b944de3-e0fc-4774-a49a-b135213725ef");
ids.add("b75a5ab2-fe55-4463-bd31-d21ad555c6e0");
getByIdsPostRequestBody.setIds(ids);
LinkedList<String> types = new LinkedList<String>();
types.add("user");
types.add("group");
types.add("device");
getByIdsPostRequestBody.setTypes(types);
var result = graphClient.directoryObjects().getByIds().post(getByIdsPostRequestBody);