繁体   English   中英

MS Graph SDK - 为任何用户分配许可证

[英]MS Graph SDK - assigning license to any user

我想描述的MS图形API中使用assignLicense功能在这里

当我使用SDK时,我正在查看使用的C#示例

graphServiceClient.Me.AssignLicense

但是,graphServiceClient.Me是指登录用户..我在服务器端应用程序,所以.Me是应用程序,而不是用户,我没有看到指定Id / UserPrincipalName发送的方法请求适当的用户。

有关如何在使用GraphServiceClient时注入正确的id / upn的任何想法?

管理我自己搞清楚

graphServiceClient.Users[id].AssignLicense 

是要走的路..不知道如何用upn做,但用户的ID工作正常。

您不能将Me与应用程序范围一起使用(即仅限应用程序的方案)。 “Me”只是当前经过身份验证的用户的别名,由于您没有经过身份验证的用户,因此Graph无法知道您要解决的用户。

您需要通过iduserPrincipalName显式指定用户:

await graphClient
  .Users["id"]
  .AssignLicense(licensesToAdd, licensesToRemove) 
  .Request()      
  .PostAsync();

await graphClient
  .Users["upn@domain.onmicrosoft.com"]
  .AssignLicense(licensesToAdd, licensesToRemove) 
  .Request()      
  .PostAsync();

请注意, licensesToAddList<AssignedLicense>licensesToRemoveList<Guid>

暂无
暂无

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

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