Nov 13 2023 06:06 AM - edited Nov 14 2023 12:58 AM
Hi - I am using Java APIs to assign "Security Administrator".
The java code looks like this.
final DirectoryObject dirObjectCreated = Objects.requireNonNull(graphClient
.directoryRoles(ROLE_TEMPLATE_ID + "=" + SECURITY_ADMIN_TEMPLATE_ID)
.members()
.references())
.buildRequest()
.post(directoryObject);
This works fine.
When I try to remove this "Security Administrator", I am getting the error
Removing self from Global Administrator built-in role is not allowed.
I have tried following URL
Method: DELETE
URL: https://graph.microsoft.com/v1.0/roleManagement/directory/roleAssignments/y-RKG-FULL-ID
We prevent users from deleting their own Global Administrator role to avoid a scenario where a tenant has zero Global Administrators. Removing other roles assigned to self is allowed.
"roles": [
"Mail.ReadWrite",
"Domain.ReadWrite.All",
"Group.Read.All",
"Directory.Read.All",
"User.Read.All",
"Domain.Read.All",
"RoleManagement.ReadWrite.Directory",
"Application.Read.All"
]
Question: How can I remove "Security Administrator" role?
Nov 13 2023 07:46 AM
Nov 13 2023 07:58 AM
Yes I am. I can assure you that I am passing the correct ID.
I think the error message is generic if you try to remove any admin (Security Admin or Office Administrator etc)
Nov 13 2023 11:00 PM
Still, double-check things. I just tried to reproduce the issue, and I have no problem removing any additional roles assigned to the (only) Global admin. Only when trying to remove the GA role I get the error above.
Nov 14 2023 12:58 AM
Nov 14 2023 01:29 AM
Nov 14 2023 08:10 AM