private static async Task DeleteGroup(string groupName)
        {
            AuthenticationConfig config = AuthenticationConfig.ReadFromJsonFile("appsettings.json");

            try
            {
                var groupId = MsGraphFacade.GetGroupObjectId(groupName).GetAwaiter().GetResult();

                var httpClient = new HttpClient();
                var apiCaller  = new ProtectedApiCallHelper(httpClient);
                await apiCaller.DeleteWebApiAndProcessResultASync($"{config.ApiUrl}v1.0/groups/{groupId}", Program.AuthenticationResult.AccessToken);
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex.Message);
            }
        }
Esempio n. 2
0
        static void Main(string[] args)
        {
            //EndpointAddress ep = new EndpointAddress("net.tcp://*****:*****@ Date/time: {DateTime.Now}");

            var mockui = new MsGraphFacade();

            //mockui.RunAadQuery("ReadAllUsers");
            //mockui.RunAadQuery("ReadAllGroups");

            // get the logged in user groups and roles with regards to other apps

            var grpName         = AadObjects.GroupName;
            var grpMailNickname = AadObjects.GroupMailNickname;
            var grpDescription  = AadObjects.GroupDescription;
            var jsonGroup       = $"{{'description': '{grpDescription}'," +
                                  $"'displayName': '{grpName}'," +
                                  @"'groupTypes': ['Unified']," +
                                  @"'mailEnabled': true," +
                                  $"'mailNickname': '{grpMailNickname}'," +
                                  "'securityEnabled': false}";
            var userOwner  = AadObjects.UserOwner;
            var userMember = AadObjects.UserMember;

            switch (action)
            {
            case "read_all_users":
                mockui.RunAadQuery("ReadAllUsers");
                logger.Info($"***** Command details: read_all_users");
                break;

            case "read_all_groups":
                mockui.RunAadQuery("ReadAllGroups");
                logger.Info($"***** Command details: read_all_users");
                break;

            case "create_group":
                mockui.RunAadQuery("CreateGroup", jsonGroup);
                logger.Info($"***** Command details: create_group, args:{jsonGroup}");
                break;

            case "add_owner_to_group":
                mockui.RunAadQuery("AddGroupOwner", grpName, userOwner);
                logger.Info($"***** Command details: add_owner_to_group, args:{grpName},{userOwner}");
                break;

            case "add_member_to_group":
                mockui.RunAadQuery("AddGroupMember", grpName, userMember);
                logger.Info($"***** Command details: add_member_to_group, args:{grpName},{userMember}");
                break;

            case "remove_member_from_group":
                mockui.RunAadQuery("RemoveGroupMember", grpName, userMember);
                logger.Info($"***** Command details: remove_member_from_group, args:{grpName},{userMember}");
                break;

            case "remove_owner_from_group":
                mockui.RunAadQuery("RemoveGroupOwner", grpName, userOwner);
                logger.Info($"***** Command details: remove_owner_from_group, args:{grpName},{userOwner}");
                break;

            case "delete_group":
                mockui.RunAadQuery("DeleteGroup", grpName);
                logger.Info($"***** Command details: delete_group, args:{grpName}");
                break;
            }
            logger.Info($"***** [IDM Service] Command ended @ Date/time: {DateTime.Now}{ Environment.NewLine}");
        }