OpenTypes不支持打开导航属性。属性名称:'DirectoryDataService.changePassword'

问题描述 投票:0回答:2

显示错误当我尝试使用Microsoft.Azure.ActiveDirectory.GraphClient更新用户密码时

  user.ChangePasswordAsync(currentPassword, newPassword);
azure active-directory
2个回答
1
投票

使用以下代码可以正常使用它。

await activeDirectoryClient.Users["userObjectId"].ChangePasswordAsync("oldPassword", "newPassword");

要么

 var user = activeDirectoryClient.Users.GetByObjectId("userObjectId")
 await user.ChangePasswordAsync("oldPassword", "newPassword");

但我可以使用以下代码重现错误信息。

 var user =(User)activeDirectoryClient.Users.GetByObjectId("userObjectId").ExecuteAsync().Result;
 await user.ChangePasswordAsync("oldPassword", "newPassword");

我用fiddler捕获请求然后我发现400错误。请求网址是

https://graph.windows.net/{tenantId}/directoryObjects/{userId}/changePassword?api-version=1.6

但更改密码Graph API是

https://graph.windows.net/{tenantId}/users/<objectId>/changePassword or /users/userPrincipalName/changePassword

我认为这就是获取错误信息的原因。

enter image description here

注意:为登录用户调用changePassword操作以更改自己的密码。

我们也可以使用Microsoft图形SDK来做到这一点。有关更多信息,请参阅另一个SO thread


0
投票

您可以使用Microsoft Graph而不是Azure AD Graph吗?根据Microsoft,“我们强烈建议您使用Microsoft Graph而不是Azure AD Graph API来访问Azure Active Directory资源。”看看this

© www.soinside.com 2019 - 2024. All rights reserved.