我原本计划使用 Azure AD Graph API,但后来在 Microsoft 文档中注意到有关使用 Microsoft Graph API 的建议。
是否提供了更改用户密码的文档?
string result = Task.Run(async() => { return await GetAccessToken(); }).GetAwaiter().GetResult();
var graphserviceClient = new GraphServiceClient(
new DelegateAuthenticationProvider(
(requestMessage) =>
{
requestMessage.Headers.Authorization = new AuthenticationHeaderValue("bearer", result);
return Task.FromResult(0);
}));
var changePasswordRequest = graphserviceClient.Me.ChangePassword("oldpassword", "newpassword");
但我认为这还不够。有可用的文档吗?
你可以更新passwordProfile
属性来更改当前用户的密码。请参考下面的代码:
await graphClient.Me.Request().UpdateAsync(new User
{
PasswordProfile = new PasswordProfile
{
Password = "YourPassword",
ForceChangePasswordNextSignIn = false
},
});
并根据文档,执行此 API 需要以下范围之一:User.ReadWrite
User.ReadWrite.All
Directory.ReadWrite.All
.
Edit:
The 文档已更新以下注释:
更新时passwordProfile
属性,需要以下范围:Directory.AccessAsUser.All
.
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)