[英]Microsoft graph change azure ad b2c user password not working
I am trying to reset users password through Microsoft Graph, the code runs but the user password is not changed.我正在尝试通过 Microsoft Graph 重置用户密码,代码运行但用户密码未更改。 my code is based on the following doc: https://docs.microsoft.com/en-us/graph/api/user-update?view=graph-rest-1.0&tabs=csharp
我的代码基于以下文档: https ://docs.microsoft.com/en-us/graph/api/user-update?view=graph-rest-1.0&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);
}
}
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.但是,我注意到您没有使用“ await ”关键字。
Try this:尝试这个:
var response = await graphServiceClient.Users[currentUser[0].Id]
.Request()
.UpdateAsync(user);
Most likely your user "UpdateAsync(user)" operation is not being executed because you are not awaiting the "Request()" operation.很可能您的用户“UpdateAsync(user)”操作没有被执行,因为您没有等待“Request()”操作。 So, the update never happens.
所以,更新永远不会发生。
Again, much more detail is required to fully understand what is happening.同样,需要更多细节才能完全了解正在发生的事情。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.