Exemple #1
0
        private static void ExpandADGroup(List<Tuple<string, IDirectoryObject>> DirectoryObjects, IGroupFetcher retrievedGroupFetcher)
        {
            IPagedCollection<IDirectoryObject> GroupMembers = retrievedGroupFetcher.Members.ExecuteAsync().Result;

            do
            {
                List<IDirectoryObject> directoryObjects = GroupMembers.CurrentPage.ToList();

                foreach (IDirectoryObject directoryObject in directoryObjects)
                {
                    if (directoryObject is User)
                    {
                        DirectoryObjects.Add(Tuple.Create("user", directoryObject));
                    }
                    if (directoryObject is Contact)
                    {
                        DirectoryObjects.Add(Tuple.Create("contact", directoryObject));
                    }
                    if (directoryObject is Group)
                    {
                        DirectoryObjects.Add(Tuple.Create("group", directoryObject));
                        ExpandADGroup(DirectoryObjects, (IGroupFetcher)directoryObject);
                    }
                }
                GroupMembers = GroupMembers.GetNextPageAsync().Result;
            } while (GroupMembers != null);
        }
 public static async Task<IUser[]> GetGroupMembersAsync(this GraphService service, IGroupFetcher groupFetcher)
 {
     var collection = await groupFetcher.members.ExecuteAsync();
     return (await collection.GetAllAsnyc())
         .OfType<IUser>().ToArray();
 }