繁体   English   中英

Microsoft graph 更改 azure ad b2c 用户密码不起作用

[英]Microsoft graph change azure ad b2c user password not working

我正在尝试通过 Microsoft Graph 重置用户密码,代码运行但用户密码未更改。 我的代码基于以下文档: 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);
            }
        }

需要更多详细信息才能完全理解问题,例如您得到的响应。 有什么错误吗?

但是,我注意到您没有使用“ await ”关键字。

尝试这个:

var response = await graphServiceClient.Users[currentUser[0].Id]
                .Request()
                .UpdateAsync(user);

很可能您的用户“UpdateAsync(user)”操作没有被执行,因为您没有等待“Request()”操作。 所以,更新永远不会发生。

同样,需要更多细节才能完全了解正在发生的事情。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM