使用 Azure Graph 添加组作为组的成员 API

Adding a Group as a member of a Group using Azure Graph API

我正在将 Azure Graph API 与 Azure AD B2C 一起使用,我正在尝试将一个组添加为组的成员

我已经成功地对 Azure Graph API 进行了一系列其他调用,包括将用户添加为组成员。

这是我正在打的电话 URL:

POST https://graph.windows.net/{tenant}/groups/{groupId}/$links/members?api-version=1.6

正文:

{
    "url": "https://graph.windows.net/{tenant}/directoryObjects/{groupToAdd}"
}

我收到以下错误:

{
    "odata.error": {
        "code": "Request_BadRequest",
        "message": {
            "lang": "en",
            "value": "An invalid operation was included in the following modified references: 'members'."
        },
        "requestId": "2545d9bf-68c9-44bf-a9ba-1a2976e0c055",
        "date": "2019-09-11T03:11:37"
    }
}

当使用用户的 ObjectId 但使用组时,完全相同的调用有效。

可能相关,查看组时 Azure 中缺少“组成员资格”

更新: 当我第一次发布这个问题时,我遗漏了一条重要信息。这是针对 Azure Active Directory B2C

的 Graph API 调用

the "Group Memberships" is missing in Azure when viewing a Group

在我的站点中,组成员资格仍在 Azure AD 组选项卡中,我使用以下代码并成功将组添加为组的成员。

https://graph.windows.net/tenantId/groups/securityGroupObjectId/$links/members  
{
    "url": "https://graph.windows.net/tenantId/groups/securityGroupObjectIdToAdd"
}

注意:确保 securityGroupObjectIdToAdd 是正确的 objectId。应该是az ad group list返回的objectId,和传送门里面的object ID不一样!参考这个issue.

Azure Active Directory B2C 实例中不能有嵌套组

参见:AAD B2C Limitations and restrictions

Nested group memberships aren't supported in Azure AD B2C tenants. There are no plans to add this capability.