[英]Microsoft AAD Group - get members of 'group' type using Microsoft Graph
Is there a way to get only members of type 'microsoft.graph.group' on running https://graph.microsoft.com/v1.0/groups/[groupid]/transitivemembers/microsoft.graph.group in C#?有没有办法在 C# 中运行https://graph.microsoft.com/v1.0/groups/[groupid]/transitivemembers/microsoft.graph.group时只获取“microsoft.graph.group”类型的成员? The below code:
下面的代码:
var members = graphClient.Groups[objectId.ToString()].Members.Request().GetAsync()
.ConfigureAwait(false).GetAwaiter().GetResult();
do
{
var directoryObjects = members.CurrentPage.ToList();
foreach (var member in directoryObjects)
{
if (member is Microsoft.Graph.User)
{
var a = new AzureADUser { ObjectId = Guid.Parse((member as Microsoft.Graph.User).Id) };
users.Add(a);
}
else if (member is Microsoft.Graph.Group)
{
var b = Guid.Parse((member as Microsoft.Graph.Group).Id);
groups.Add(b);
}
}
}
while (members.NextPageRequest != null && (members = members.NextPageRequest.GetAsync().ConfigureAwait(false).GetAwaiter().GetResult()).Count > 0);
returns all types of members and I have to check the type of each member to get the list of groups.返回所有类型的成员,我必须检查每个成员的类型以获取组列表。 Is there a way to make the graph call to return only members of type 'microsoft.graph.group' ?
有没有办法让图形调用只返回'microsoft.graph.group'类型的成员? If that's possible, is the cost associated to call graph to get all members v/s members of type 'microsoft.graph.group' the same?
如果可能的话,调用 graph 以获取所有成员与“microsoft.graph.group”类型的成员相关的成本是否相同?
For checking the List group transitive members you can Use the microsoft.graph.group OData cast to get only members that are groups:要检查列表组传递成员,您可以使用 microsoft.graph.group OData 强制转换来仅获取属于组的成员:
GraphServiceClient graphClient = new GraphServiceClient( authProvider );
var queryOptions = new List<QueryOption>()
{
new QueryOption("$count", "true")
};
var group = await graphClient.Groups["{group-id}"].TransitiveMembers
.Request( queryOptions )
.Header("ConsistencyLevel","eventual")
.GetAsync();
Please refer this document for more details: https://docs.microsoft.com/en-us/graph/api/group-list-transitivemembers?view=graph-rest-1.0&tabs=csharp#example-3-use-the-microsoftgraphgroup-odata-cast-to-get-only-members-that-are-groups .有关更多详细信息,请参阅此文档: https ://docs.microsoft.com/en-us/graph/api/group-list-transitivemembers?view=graph-rest-1.0&tabs=csharp#example-3-use-the -microsoftgraphgroup-odata-cast-to-get-only-members-that-are-groups 。
Hope this helps.希望这可以帮助。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.