Microsoft Graph更改Azure AD B2C用户密码不起作用
我正在尝试通过Microsoft Graph重置用户密码,代码运行,但没有更改用户密码。我的代码基于以下文档: https://learn.microsoft.com/en-us/graph/api/user-update?view=graph-raph-rest-1.0& amp; tabs = csharp
string GeneratedPassword = "Testing@12345";
//GeneratedPassword = letterOne + PasswordGenerator.Generate(8, 3) + $"{letterTwo}{NumberOne}";
var currentUser = users.Where(x => x.Mail == accountEmail).ToArray();
if (currentUser.Length!=0)
{
Console.WriteLine(currentUser[0].Id);
try
{
var user = new User
{
PasswordProfile = new PasswordProfile
{
ForceChangePasswordNextSignIn = false,
Password = GeneratedPassword
}
};
var response = graphServiceClient.Users[currentUser[0].Id]
.Request()
.UpdateAsync(user);
}
catch(Exception ex)
{
Console.WriteLine(ex);
}
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
需要更多的详细信息来充分了解问题,例如您得到的响应。有错误吗?
但是,我注意到您没有使用“ 等待”的关键字。
尝试以下操作:
您的用户最有可能“ UpdateAsync(用户)”操作没有执行,因为您不在等待“ request()”操作。因此,更新永远不会发生。
同样,需要更多的细节才能充分了解正在发生的事情。
More detail is required to fully understand the issue, such as the response you are getting. Is there any error?
However, I noticed that you did not use the "await" keyword.
Try this:
Most likely your user "UpdateAsync(user)" operation is not being executed because you are not awaiting the "Request()" operation. So, the update never happens.
Again, much more detail is required to fully understand what is happening.