【发布时间】:2021-06-21 15:55:14
【问题描述】:
我在 .NET Blazor 项目中使用 Graph API 来获取组的所有成员。除非该组有其他组作为成员而不仅仅是用户,否则它会很好地工作。我使用的代码如下:
var groups = await GraphServiceClient.Groups.Request()
.Filter($"mail+eq+'{email}'")
.Expand("members")
.GetAsync(); //get the member groups by email, then include member information
var members = groups.FirstOrDefault().Members.ToList(); //get the first group (there should be only one) and convert it to list
return members.Select(s => ((User)s).DisplayName).ToList(); //cast the items to User and get the display name, then return this list
当我尝试将组投射到用户时失败。当然,我可以使用.Where 过滤掉这些组,但是我会错过它们包含的用户。
如何获取所有子组的成员(尽可能多的级别)并一次性返回?
【问题讨论】:
标签: c# .net microsoft-graph-api blazor