Not able to disable user account using accountEnabled=false

Ridhima Bhalerao 1 Reputation point
2020-09-02T16:01:40.197+00:00

Hello,

I am trying to use the 'update' Graph API to disable user's account. This is the REST API I am using:

https://graph.microsoft.com/v1.0/users/dummyuser[@](/users/na/?userId=990f8a56-0000-0006-0000-000000000000).com

Request Body:
{
"accountEnabled":"false"
}

Unfortunately I get the following response:

"code": "Authorization_RequestDenied",
"message": "Insufficient privileges to complete the operation."

I am using the client_id and client_secret to get the OAUTH token. Although, I can update any other field for the same user using the same API call.

Is there anything that I am missing? Any help is appreciated.

Thank you!

Microsoft Entra ID
Microsoft Entra ID
A Microsoft Entra identity service that provides identity management and access control capabilities. Replaces Azure Active Directory.
19,437 questions
{count} votes

5 answers

Sort by: Most helpful
  1. Carlos Castro Moreno 6 Reputation points
    2020-12-15T08:23:20.33+00:00

    Hi RidhimaBhalerao-8704,
    Could you check if the user you want to disable has a role assigned to him?

    In my case I can only change it to users who do not have any role assigned

    1 person found this answer helpful.

  2. JamesTran-MSFT 36,361 Reputation points Microsoft Employee
    2020-09-02T23:44:11.12+00:00

    @Ridhima Bhalerao
    Looking at your error message it looks like you might not have the correct permissions to disable the user's account. Are you trying to do this through Microsoft Graph Explorer?

    I wasn't able to replicate your issue but will post my findings below: Using the Microsoft Graph API

    Patch  
    https://graph.microsoft.com/v1.0/users/testuser1@.domain.onmicrosoft.com  
    Request Body - {"accountEnabled":"false"}  
    

    Once the command returned the appropriate response. I checked to make sure the account was actually disabled.

    Get  
    https://graph.microsoft.com/v1.0/users/testuser1@.domain.onmicrosoft.com?$select=accountEnabled  
    

    22218-accountdisabled.jpg

    Please let me know if you have any questions.
    Thank you for your time and patience throughout this issue!


  3. Bhanot Ravi 31 Reputation points
    2020-09-03T18:49:39.673+00:00

    Hi RidhimaBhalerao-8704,

    Can you verify if the user ID that you are using has got "User Administrator" role assigned, if not try giving this role to your ID and then try executing the command or Patch Query.

    User Administrator role has access to manage all aspects of users and groups.

    Thanks,
    Ravi


  4. Bhanot Ravi 31 Reputation points
    2020-09-04T18:50:30.23+00:00

    Thanks Ridhima for detailed answer. I would suggest let's wait for response from James as he is checking from Engineering team.

    Thanks,
    Ravi

    0 comments No comments

  5. Bhanot Ravi 31 Reputation points
    2020-09-09T18:31:32.71+00:00

    HI Ridhima,

    Could you please confirm if there is any progress.

    Thanks,
    Ravi

    0 comments No comments