Graph API的 Entra ID在更新生日信息时抛出Microsoft.Office.Server.Directory.DirectoryObjectUnauthorizedAccessException
我已经尝试了所有方法,权限也正确,但在对 https://graph.microsoft.com/v1.0/users/{{userid}} 进行 patch 调用以更新 birtday 的值时,仍然遇到 Microsoft.Office.Server.Directory.DirectoryObjectUnauthorizedAccessException。
我的PATCH调用的请求体是:
{
"birthday": "1990-01-01T00:00:00Z"
}
请求头:
{
"Authorization": "Bearer {{accesstoken}}",
"Content-type": "application/json"
}
像在 employeeHireDate 上执行 patch 这样的其他调用都能正常工作,因此令牌看起来是正确的。
我查阅过其他问题,日期格式应该是正确的。
这些是我在Graph API上的应用权限:
Microsoft.Graph
- Directory.AccessAsUser.All (delegated)
- Directory.Read.All (application)
- Directory.ReadWrite.All (application)
- Sites.FullControl.All (application)
- User.EnableDisableAccount (application)
- User.ManageIdentities.All (application)
- User.Read (delegated)
- User.ReadAll (application)
- User.ReadWrite (delegated)
- User.ReadWriteAll (application)
SharePoint
- Sites.ReadWrite.All (application)
- User.ReadWrite.All (delegated)
它以前是可以工作的,但现在不再工作。这是一个Business EntraID账户。
我是不是漏掉了某些权限,还是微软取消了这个选项?
解决方案
文档 指出,birthday 不能被拥有应用程序权限的应用程序更新。
以下属性不能被只有应用程序权限的应用程序更新:aboutMe、birthday、employeeHireDate、interests、mySite、pastProjects、responsibilities、schools和 skills。
当然,它并没有解释为什么之前还能工作,以及为什么你现在可以更新 employeeHireDate。看起来像是Graph API那边的一个错误。
站内所有文章版权归属LeftHeroAI导航站,无授权禁止任何主体转载、抄袭、复制内容,亦不得私自架设镜像站点。一经侵权,本站将通过法律途径追责。