我没有足够的权限来完成操作。如需休息密码

问题描述 投票:0回答:1
var client = graph.GetGraphClient();

try
{
    //get existing user
    var user = await GetGraphUser(userId, cancellationToken);

    //Ensure the PasswordProfile exists before attempting to update the password
    if (user.PasswordProfile == null)
    {
        user.PasswordProfile = new PasswordProfile
        {
            Password = newPassword,
            ForceChangePasswordNextSignIn = true
        };
    }
    else
    {
        // Update the password if PasswordProfile is present
        user.PasswordProfile.Password = newPassword;
        user.PasswordProfile.ForceChangePasswordNextSignIn = true;
    }
    await client.Users[userId].PatchAsync(user, cancellationToken: cancellationToken);
}
catch (Microsoft.Graph.Models.ODataErrors.ODataError ex)
{
    GraphExceptionsHandler.Handle(ex);
}

这是我的代码,我想使用图形客户端重置 entraId 中用户的密码。但我收到错误“权限不足”。我尝试了很多权限

我尝试了所有这些权限 enter image description here enter image description here

javascript microsoft-graph-api azure-ad-graph-api microsoft-entra-id
1个回答
0
投票

如果您代表用户进行身份验证,则登录用户必须至少具有 用户管理员 角色才能更改密码。

© www.soinside.com 2019 - 2024. All rights reserved.