Microsoft Graph Api - 更新 PasswordProfile 在 null 时不起作用
Microsoft Graph Api - updating PasswordProfile not working when null
我有一个 b2c 环境设置并链接到一个允许用户注册的应用程序。
我想按计划运行 进行的其中一个过程是更新用户的 PasswordProfile,以便在某些情况下我可以强制用户在下次尝试登录时更改密码。
如文档所述 (https://docs.microsoft.com/en-us/graph/api/user-update?view=graph-rest-1.0&tabs=csharp#permissions),我已添加并同意访问 Microsoft Graph 的应用程序的 Directory.AccessAsUser.All
(委派)权限。
要求:
https://graph.microsoft.com/v1.0/users/{userId}
{
"passwordProfile": {
"forceChangePasswordNextSignIn": true
}
}
当我在 C# 代码中或通过 Postman 运行 执行此操作时,它 return 出现以下错误消息:
"error": {
"code": "Authorization_RequestDenied",
"message": "Insufficient privileges to complete the operation.",
...
但是我已经能够通过 https://developer.microsoft.com/en-us/graph/graph-explorer 运行 相同的请求,在那里我已经能够更新用户的 PasswordProfile。
奇怪的是,如果我然后 return 到 C# 代码或 Postman,并且 运行 对我的 SAME 用户执行相同的操作在 Graph Explorer 中更新,现在可以使用了。
因此,我似乎设置了正确的权限,但我只能在 PasswordProfile 尚未为空时更新它。但是,当通过 B2C 屏幕注册时创建用户时,此时 PasswordProfile 设置为 null。
有人遇到过这个吗?或者能够重现这个?
我需要将应用程序添加为 'Global Administrator',详见此处接受的答案:
我有一个 b2c 环境设置并链接到一个允许用户注册的应用程序。
我想按计划运行 进行的其中一个过程是更新用户的 PasswordProfile,以便在某些情况下我可以强制用户在下次尝试登录时更改密码。
如文档所述 (https://docs.microsoft.com/en-us/graph/api/user-update?view=graph-rest-1.0&tabs=csharp#permissions),我已添加并同意访问 Microsoft Graph 的应用程序的 Directory.AccessAsUser.All
(委派)权限。
要求:
https://graph.microsoft.com/v1.0/users/{userId}
{
"passwordProfile": {
"forceChangePasswordNextSignIn": true
}
}
当我在 C# 代码中或通过 Postman 运行 执行此操作时,它 return 出现以下错误消息:
"error": {
"code": "Authorization_RequestDenied",
"message": "Insufficient privileges to complete the operation.",
...
但是我已经能够通过 https://developer.microsoft.com/en-us/graph/graph-explorer 运行 相同的请求,在那里我已经能够更新用户的 PasswordProfile。
奇怪的是,如果我然后 return 到 C# 代码或 Postman,并且 运行 对我的 SAME 用户执行相同的操作在 Graph Explorer 中更新,现在可以使用了。
因此,我似乎设置了正确的权限,但我只能在 PasswordProfile 尚未为空时更新它。但是,当通过 B2C 屏幕注册时创建用户时,此时 PasswordProfile 设置为 null。
有人遇到过这个吗?或者能够重现这个?
我需要将应用程序添加为 'Global Administrator',详见此处接受的答案: