Пример #1
0
        private async Task <bool> IsAuthorized(string action)
        {
            bool result   = false;
            var  mygroups = await _graphServiceClient.Me.MemberOf.Request().GetAsync();

            HomeHelper helper = new HomeHelper();

            result = helper.IsAdmin(mygroups);

            return(result);
        }
Пример #2
0
        private async Task <SortedDictionary <string, string> > GetGroupMembers(SortedDictionary <string, string> groups)
        {
            //https://docs.microsoft.com/en-us/graph/api/group-list-members
            SortedDictionary <string, string> users = new SortedDictionary <string, string>();
            HomeHelper helper = new HomeHelper();

            foreach (string s in groups.Values)
            {
                var members = await _graphServiceClient.Groups[s].Members
                              .Request()
                              .GetAsync();

                users = helper.UsersToDictionary(users, members);
            }

            return(users);
        }
Пример #3
0
        public async Task <IActionResult> ManageGroups()
        {
            if (await IsAuthorized("ManageGroups"))
            {
                var transitivegroups = await _graphServiceClient.Me.TransitiveMemberOf.Request().GetAsync();

                HomeHelper helper = new HomeHelper();
                SortedDictionary <string, string> groups = new SortedDictionary <string, string>();
                ViewData["transitivegroups"] = helper.TransitiveGroupsToDictionary(groups, transitivegroups);
            }
            else
            {
                return(RedirectToAction("Index", "Home"));
            }

            return(View());
        }