简体   繁体   English

Microsoft AAD 组 - 使用 Microsoft Graph 获取“组”类型的成员

[英]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.

相关问题 Microsoft.Graph SDK 获取“组”类型组的成员 - Microsoft.Graph SDK Get members of the group of type 'Group' 从 Microsoft graph 获取 GROUP 类型的成员列表 - Get list of members of type GROUP from Microsoft graph 使用 Graph API 从 AAD 组中仅获取“GROUP”类型的成员数 - Get ONLY the count of members of 'GROUP' type from an AAD group using Graph API 通过 microsoft graph 从 azure 广告中获取组成员 - get group members from azure ad via microsoft graph Microsoft Graph API 筛选器组成员 - Microsoft Graph API filter Members of Group 如何获取用户的组名是使用 Microsoft Graph API 的成员? - How to get group names of the user is a member of using Microsoft Graph API? 如何使用 Microsoft Graph api 或类似的 API 获取联系人组 - how to get contact group using Microsoft Graph api or similier apis 对 Microsoft Graph API 执行 POST 请求以将成员添加到 AD 组 - Executing POST request for Microsoft Graph API to add members to an AD group 是否有可能使用 microsoft graph 删除组的多个成员? - Is there any posibility to delete multiple members of a group with microsoft graph? Microsoft Graph .NET客户端库:将成员和团队添加到组中 - Microsoft Graph .NET Client Library: Add members and team to a group
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM