获取成员对象

命名空间:microsoft.graph

返回用户、组、服务主体、组织联系人、设备或目录对象是其中一个成员的组、管理单元和目录角色的所有 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}/getMemberObjects

用户的成员身份

POST /me/getMemberObjects
POST /users/{id | userPrincipalName}/getMemberObjects

组的成员身份

POST /groups/{id}/getMemberObjects

服务主体的成员身份

POST /servicePrincipals/{id}/getMemberObjects

组织联系人的成员身份

POST /contacts/{id}/getMemberObjects

设备的成员身份

POST /devices/{id}/getMemberObjects

请求标头

名称 说明
Authorization Bearer {token}。必需。
Content-Type application/json

请求正文

在请求正文中,提供具有以下参数的 JSON 对象。

参数 类型 说明
securityEnabledOnly Boolean true 指定仅返回实体是成员的安全组; false 指定应返回实体是成员的所有组、管理单元和目录角色。

响应

如果成功,此方法在响应正文中返回 200 OK 响应代码和 String 集合对象。

示例

请求
POST https://graph.microsoft.com/v1.0/directoryObjects/{object-id}/getMemberObjects
Content-type: application/json

{
  "securityEnabledOnly": true
}
响应

注意: 为了提高可读性,可能缩短了此处显示的响应对象。

HTTP/1.1 200 OK
Content-type: application/json

{
    "@odata.context": "https://graph.microsoft.com/v1.0/$metadata#Collection(Edm.String)",
    "value": [
        "fee2c45b-915a-4a64-b130-f4eb9e75525e",
        "4fe90ae7-065a-478b-9400-e0a0e1cbd540",
        "c9ee2d50-9e8a-4352-b97c-4c2c99557c22",
        "e0c3beaf-eeb4-43d8-abc5-94f037a65697"
    ]
}