How to reset password using Microsoft Graph Client SDK(C#)?

僤鯓⒐⒋嵵緔 提交于 2020-01-01 19:37:28

问题


How can a user reset his password using Microsoft Graph client. I am not able to find the right way to do it. Thanks.


回答1:


Tom is correct about this the Delegate Scope Directory.AccessAsUser.All allowing the signed-in user to change their password. The standard User.ReadWrite can update most properties, but it cannot update the user's password.

It is, however, a supported operation. The SDK includes the PasswordProfile class you need to pass into Graph. The syntax would look something like this:

await graphClient.Me.Request().UpdateAsync(new User() {
    PasswordProfile = new PasswordProfile() {
        Password = "newPassword",
        ForceChangePasswordNextSignIn = true
    }
});



回答2:


How can a user reset his password using Microsoft Graph client

Unfortuntly, it seems that we can't reset password with Microsoft Graph client currently. According to the Microsoft graph update user API, we required to use the delegated permission type: Directory.AccessAsUser.All.

When updating the passwordProfile property, the following permission is required: Directory.AccessAsUser.All.

Delegated permissions are used by apps that have a signed-in user present. For these apps either the user or an administrator consents to the permissions that the app requests and the app is delegated permission to act as the signed-in user when making calls to Microsoft Graph.



来源:https://stackoverflow.com/questions/50286384/how-to-reset-password-using-microsoft-graph-client-sdkc

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!