directoryObject:checkMemberObjects
本文内容
命名空间:microsoft.graph
重要
Microsoft Graph版本下的 /beta API 可能会发生更改。 不支持在生产应用程序中使用这些 API。 若要确定 API 是否在 v1.0 中可用,请使用 版本 选择器。
检查组 ID、管理单元 ID 或目录角色 ID 列表中的成员身份,以检查指定的用户、组、服务主体、组织联系人、设备或目录对象的 ID。 此方法是可传递的。
权限
要调用此 API,需要以下权限之一。要了解详细信息,包括如何选择权限的信息,请参阅权限 。
目录对象的成员身份
权限类型
权限(从最低特权到最高特权)
委派(工作或学校帐户)
Directory.Read.All
委派(个人 Microsoft 帐户)
不支持。
应用程序
Directory.Read.All
用户的成员身份
权限类型
权限(从最低特权到最高特权)
委派(工作或学校帐户)
User.Read、User.Read.All、Directory.Read.All、User.ReadWrite.All、Directory.ReadWrite.All
委派(个人 Microsoft 帐户)
不支持。
应用程序
User.Read.All、Directory.Read.All、User.ReadWrite.All、Directory.ReadWrite.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
设备的成员身份
权限类型
权限(从最低特权到最高特权)
委派(工作或学校帐户)
Device.Read.All、Directory.Read.All、Directory.ReadWrite.All
委派(个人 Microsoft 帐户)
不支持。
应用程序
Device.Read.All、Device.ReadWrite.All、Directory.Read.All、Directory.ReadWrite.All
HTTP 请求
目录对象的成员身份。
POST /directoryObjects/{id}/checkMemberObjects
用户的成员身份。
POST /me/checkMemberObjects
POST /users/{id | userPrincipalName}/checkMemberObjects
组的成员身份。
POST /groups/{id}/checkMemberObjects
服务主体的成员身份。
POST /servicePrincipals/{id}/checkMemberObjects
组织联系人的成员身份。
POST /contacts/{id}/checkMemberObjects
设备的成员身份。
POST /devices/{id}/checkMemberObjects
名称
说明
Authorization
持有者 {token}
Content-Type
application/json
请求正文
在请求正文中,提供具有以下参数的 JSON 对象。
参数
类型
说明
ids
String collection
包含要检查成员身份的目录角色的组、目录角色、管理单元或 roleTemplate ID 的对象 ID 的集合。 最多可指定 20 个对象。
响应
如果成功,此方法在响应 200 OK 正文中返回 响应代码和新 String 集合对象。
示例
下面是如何调用此 API 的示例。
请求
下面展示了示例请求。
POST https://graph.microsoft.com/beta/me/checkMemberObjects
Content-type: application/json
{
"ids": [
"80a963dd-84af-4eb8-b2a6-781e444d4fb0",
"62e90394-69f5-4237-9190-012177145e10",
"86a64f51-3a64-4cc6-a8c8-6b8f000c0f52",
"ac38546e-ddf3-437a-ac5c-27a94cd7a0f1"
]
}
GraphServiceClient graphClient = new GraphServiceClient( authProvider );
var ids = new List<String>()
{
"80a963dd-84af-4eb8-b2a6-781e444d4fb0",
"62e90394-69f5-4237-9190-012177145e10",
"86a64f51-3a64-4cc6-a8c8-6b8f000c0f52",
"ac38546e-ddf3-437a-ac5c-27a94cd7a0f1"
};
await graphClient.Me
.CheckMemberObjects(ids)
.Request()
.PostAsync();
const options = {
authProvider,
};
const client = Client.init(options);
const string = {
ids: [
'80a963dd-84af-4eb8-b2a6-781e444d4fb0',
'62e90394-69f5-4237-9190-012177145e10',
'86a64f51-3a64-4cc6-a8c8-6b8f000c0f52',
'ac38546e-ddf3-437a-ac5c-27a94cd7a0f1'
]
};
await client.api('/me/checkMemberObjects')
.version('beta')
.post(string);
MSHTTPClient *httpClient = [MSClientFactory createHTTPClientWithAuthenticationProvider:authenticationProvider];
NSString *MSGraphBaseURL = @"https://graph.microsoft.com/beta/";
NSMutableURLRequest *urlRequest = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:[MSGraphBaseURL stringByAppendingString:@"/me/checkMemberObjects"]]];
[urlRequest setHTTPMethod:@"POST"];
[urlRequest setValue:@"application/json" forHTTPHeaderField:@"Content-Type"];
NSMutableDictionary *payloadDictionary = [[NSMutableDictionary alloc] init];
NSMutableArray *idsList = [[NSMutableArray alloc] init];
[idsList addObject: @"80a963dd-84af-4eb8-b2a6-781e444d4fb0"];
[idsList addObject: @"62e90394-69f5-4237-9190-012177145e10"];
[idsList addObject: @"86a64f51-3a64-4cc6-a8c8-6b8f000c0f52"];
[idsList addObject: @"ac38546e-ddf3-437a-ac5c-27a94cd7a0f1"];
payloadDictionary[@"ids"] = idsList;
NSData *data = [NSJSONSerialization dataWithJSONObject:payloadDictionary options:kNilOptions error:&error];
[urlRequest setHTTPBody:data];
MSURLSessionDataTask *meDataTask = [httpClient dataTaskWithRequest:urlRequest
completionHandler: ^(NSData *data, NSURLResponse *response, NSError *nserror) {
//Request Completed
}];
[meDataTask execute];
GraphServiceClient graphClient = GraphServiceClient.builder().authenticationProvider( authProvider ).buildClient();
LinkedList<String> idsList = new LinkedList<String>();
idsList.add("80a963dd-84af-4eb8-b2a6-781e444d4fb0");
idsList.add("62e90394-69f5-4237-9190-012177145e10");
idsList.add("86a64f51-3a64-4cc6-a8c8-6b8f000c0f52");
idsList.add("ac38546e-ddf3-437a-ac5c-27a94cd7a0f1");
graphClient.me()
.checkMemberObjects(DirectoryObjectCheckMemberObjectsParameterSet
.newBuilder()
.withIds(idsList)
.build())
.buildRequest()
.post();
//THE GO SDK IS IN PREVIEW. NON-PRODUCTION USE ONLY
graphClient := msgraphsdk.NewGraphServiceClient(requestAdapter)
requestBody := msgraphsdk.NewIdsRequestBody()
requestBody.SetIds( []String {
"80a963dd-84af-4eb8-b2a6-781e444d4fb0",
"62e90394-69f5-4237-9190-012177145e10",
"86a64f51-3a64-4cc6-a8c8-6b8f000c0f52",
"ac38546e-ddf3-437a-ac5c-27a94cd7a0f1",
}
result, err := graphClient.Me().CheckMemberObjects().Post(requestBody)
Import-Module Microsoft.Graph.Users.Actions
$params = @{
Ids = @(
"80a963dd-84af-4eb8-b2a6-781e444d4fb0"
"62e90394-69f5-4237-9190-012177145e10"
"86a64f51-3a64-4cc6-a8c8-6b8f000c0f52"
"ac38546e-ddf3-437a-ac5c-27a94cd7a0f1"
)
}
# A UPN can also be used as -UserId.
Confirm-MgUserMemberObject -UserId $userId -BodyParameter $params
响应
下面展示了示例响应。
注意: 为了提高可读性,可能缩短了此处显示的响应对象。
HTTP/1.1 200 OK
Content-type: application/json
{
"value": [
"80a963dd-84af-4eb8-b2a6-781e444d4fb0",
"62e90394-69f5-4237-9190-012177145e10"
]
}