Share via

Microsoft graph下的更新用户操作

hany 1 Reputation point
2021-04-16T08:55:21.443+00:00

您好,我在使用应用程序API对用户的密码进行更新时,提示权限不足,请问是否意味着应用程序权限不支持更新user的passwordProfile,错误提示如下
{
"error": {
"code": "Authorization_RequestDenied",
"message": "Insufficient privileges to complete the operation.",
"innerError": {
"date": "2021-04-16T08:26:49",
"request-id": "40cceaa0-fba4-495a-82d8-23d2eec3177e",
"client-request-id": "40cceaa0-fba4-495a-82d8-23d2eec3177e"
}
}
}

Microsoft Security | Microsoft Entra | Microsoft Entra ID
0 comments No comments

1 answer

Sort by: Most helpful
  1. AmanpreetSingh-MSFT 56,971 Reputation points Moderator
    2021-04-19T09:43:47.187+00:00

    HI @hany · Thank you for reaching out.

    If you are using application context to perform this action, make sure the application is assigned with User Administrator role (Azure AD > Roles and Administrators > User Administrator). If you are trying to reset the password of Global Admin of your tenant, you need to assign the application with the Global Administrator role because User Administrator can only reset password for limited administrators and not Global Administrators.

    Once the Role is assigned to the application, acquire a new token under application context and make below call with the token in Authorization header:

    Call

    PATCH https://graph.microsoft.com/v1.0/users/USERNAME@YOUR_TENANT.onmicrosoft.com  
    

    Body:

    {   
        "passwordProfile": {  
              "forceChangePasswordNextSignIn": true,  
              "password": "P@$$w0rd3333"  
         }  
    }  
    

    If you still get the same error, please try after few minutes as it might take some time for the changes to take effect.

    -----------------------------------------------------------------------------------------------------------

    Please "Accept the answer" if the information helped you. This will help us and others in the community as well.

    Was this answer helpful?


Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.