Skip to content

Commit 59562fe

Browse files
authored
Merge pull request #26093 from microsoftgraph/group-post-members-403error-scenarios
Add 403 Unauthorized scenarios for group POST members
2 parents 6ef766b + a064cdc commit 59562fe

File tree

3 files changed

+39
-30
lines changed

3 files changed

+39
-30
lines changed

.vscode/settings.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
{
22
"githubPullRequests.ignoredPullRequestBranches": [
3+
"main",
34
"main",
45
"main",
56
"main"

api-reference/beta/api/group-post-members.md

Lines changed: 19 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -33,20 +33,21 @@ The following table shows the least privileged permission that's required by eac
3333
| [servicePrincipal](../resources/group.md) | GroupMember.ReadWrite.All and Application.ReadWrite.All | Not supported. | GroupMember.ReadWrite.All and Application.ReadWrite.All |
3434
| [user](../resources/user.md) | GroupMember.ReadWrite.All | Not supported. | GroupMember.ReadWrite.All |
3535

36-
In delegated scenarios, the signed-in user must also be assigned a supported [Microsoft Entra role](/entra/identity/role-based-access-control/permissions-reference?toc=%2Fgraph%2Ftoc.json) or a custom role with the `microsoft.directory/groups/members/update` role permission. The following roles are the least privileged roles that are supported for this operation, except for role-assignable groups:
37-
38-
- Group owners
39-
- Directory Writers
40-
- Groups Administrator
41-
- Identity Governance Administrator
42-
- User Administrator
43-
- Exchange Administrator - only for Microsoft 365 groups
44-
- SharePoint Administrator - only for Microsoft 365 groups
45-
- Teams Administrator - only for Microsoft 365 groups
46-
- Yammer Administrator - only for Microsoft 365 groups
47-
- Intune Administrator - only for security groups
48-
49-
To add members to a role-assignable group, the app must also be assigned the *RoleManagement.ReadWrite.Directory* permission and the calling user must be assigned a supported Microsoft Entra role. *Privileged Role Administrator* is the least privileged role that is supported for this operation.
36+
> [!IMPORTANT]
37+
> In delegated scenarios, the signed-in user must also be assigned a supported [Microsoft Entra role](/entra/identity/role-based-access-control/permissions-reference?toc=%2Fgraph%2Ftoc.json) or a custom role with the `microsoft.directory/groups/members/update` role permission. The following roles are the least privileged roles that are supported for this operation, except for role-assignable groups:
38+
>
39+
> - Group owners
40+
> - Directory Writers
41+
> - Groups Administrator
42+
> - Identity Governance Administrator
43+
> - User Administrator
44+
> - Exchange Administrator - only for Microsoft 365 groups
45+
> - SharePoint Administrator - only for Microsoft 365 groups
46+
> - Teams Administrator - only for Microsoft 365 groups
47+
> - Yammer Administrator - only for Microsoft 365 groups
48+
> - Intune Administrator - only for security groups
49+
>
50+
> To add members to a role-assignable group, the app must also be assigned the *RoleManagement.ReadWrite.Directory* permission and the calling user must be assigned a supported Microsoft Entra role. *Privileged Role Administrator* is the least privileged role that is supported for this operation.
5051
5152
## HTTP request
5253

@@ -74,7 +75,10 @@ If using the **directoryObjects** reference, that is, `https://graph.microsoft.c
7475

7576
## Response
7677

77-
If successful, this method returns a `204 No Content` response code. It returns a `400 Bad Request` response code when the object is already a member of the group or is unsupported as a group member. It returns a `404 Not Found` response code when the object being added doesn't exist.
78+
If successful, this method returns a `204 No Content` response code. It returns a `400 Bad Request` response code when the object is already a member of the group or is unsupported as a group member. It returns a `404 Not Found` response code when the object being added doesn't exist. It returns `403 Unauthorized` in one of the following scenarios:
79+
- You're attempting to add a member to a [group that can't be managed through Microsoft Graph](../resources/groups-overview.md#group-types-in-microsoft-entra-id-and-microsoft-graph). This API supports only security and Microsoft 365 groups.
80+
- You're attempting to add a member you don't have permissions to add. Refer to the preceding [Permissions](#permissions) section for the permissions required to add different member types.
81+
- You're attempting to add a member to a role-assignable group and you don't have the required permissions.
7882

7983
## Example
8084

api-reference/v1.0/api/group-post-members.md

Lines changed: 19 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -31,20 +31,21 @@ The following table shows the least privileged permission that's required by eac
3131
| [servicePrincipal](../resources/group.md) | GroupMember.ReadWrite.All and Application.ReadWrite.All | Not supported. | GroupMember.ReadWrite.All and Application.ReadWrite.All |
3232
| [user](../resources/user.md) | GroupMember.ReadWrite.All | Not supported. | GroupMember.ReadWrite.All |
3333

34-
In delegated scenarios, the signed-in user must also be assigned a supported [Microsoft Entra role](/entra/identity/role-based-access-control/permissions-reference?toc=%2Fgraph%2Ftoc.json) or a custom role with the `microsoft.directory/groups/members/update` role permission. The following least privileged roles are supported for this operation, except for role-assignable groups:
35-
36-
- Group owners
37-
- Directory Writers
38-
- Groups Administrator
39-
- Identity Governance Administrator
40-
- User Administrator
41-
- Exchange Administrator - only for Microsoft 365 groups
42-
- SharePoint Administrator - only for Microsoft 365 groups
43-
- Teams Administrator - only for Microsoft 365 groups
44-
- Yammer Administrator - only for Microsoft 365 groups
45-
- Intune Administrator - only for security groups
46-
47-
To add members to a role-assignable group, the app must also be assigned the *RoleManagement.ReadWrite.Directory* permission and the calling user must be assigned a supported Microsoft Entra role. *Privileged Role Administrator* is the least privileged role that is supported for this operation.
34+
> [!IMPORTANT]
35+
> In delegated scenarios, the signed-in user must also be assigned a supported [Microsoft Entra role](/entra/identity/role-based-access-control/permissions-reference?toc=%2Fgraph%2Ftoc.json) or a custom role with the `microsoft.directory/groups/members/update` role permission. The following roles are the least privileged roles that are supported for this operation, except for role-assignable groups:
36+
>
37+
> - Group owners
38+
> - Directory Writers
39+
> - Groups Administrator
40+
> - Identity Governance Administrator
41+
> - User Administrator
42+
> - Exchange Administrator - only for Microsoft 365 groups
43+
> - SharePoint Administrator - only for Microsoft 365 groups
44+
> - Teams Administrator - only for Microsoft 365 groups
45+
> - Yammer Administrator - only for Microsoft 365 groups
46+
> - Intune Administrator - only for security groups
47+
>
48+
> To add members to a role-assignable group, the app must also be assigned the *RoleManagement.ReadWrite.Directory* permission and the calling user must be assigned a supported Microsoft Entra role. *Privileged Role Administrator* is the least privileged role that is supported for this operation.
4849
4950
## HTTP request
5051

@@ -72,7 +73,10 @@ If using the **directoryObjects** reference, that is, `https://graph.microsoft.c
7273

7374
## Response
7475

75-
If successful, this method returns a `204 No Content` response code. It returns a `400 Bad Request` response code when the object is already a member of the group or is unsupported as a group member. It returns a `404 Not Found` response code when the object being added doesn't exist.
76+
If successful, this method returns a `204 No Content` response code. It returns a `400 Bad Request` response code when the object is already a member of the group or is unsupported as a group member. It returns a `404 Not Found` response code when the object being added doesn't exist. It returns `403 Unauthorized` in one of the following scenarios:
77+
- You're attempting to add a member to a [group that can't be managed through Microsoft Graph](../resources/groups-overview.md#group-types-in-microsoft-entra-id-and-microsoft-graph). This API supports only security and Microsoft 365 groups.
78+
- You're attempting to add a member you don't have permissions to add. Refer to the preceding [Permissions](#permissions) section for the permissions required to add different member types.
79+
- You're attempting to add a member to a role-assignable group and you don't have the required permissions.
7680

7781
## Examples
7882

0 commit comments

Comments
 (0)