public AzureADGroup GetGroup(string accessToken)
        {
            GroupEntity group = null;

            if (Group != null)
            {
                group = GroupsUtility.GetGroup(Group.Id, accessToken);
            }
            else if (!string.IsNullOrEmpty(GroupId))
            {
                group = GroupsUtility.GetGroup(GroupId, accessToken);
            }
            else if (!string.IsNullOrEmpty(DisplayName))
            {
                var groups = GroupsUtility.GetGroups(accessToken, DisplayName);
                if (groups == null || groups.Count == 0)
                {
                    groups = GroupsUtility.GetGroups(accessToken, mailNickname: DisplayName);
                }
                if (groups != null && groups.Any())
                {
                    group = groups.FirstOrDefault();
                }
            }
            if (group != null)
            {
                return(AzureADGroup.CreateFrom(group));
            }
            return(null);
        }
        public static Object getAllGroups()
        {
            String[]     list      = new String[4];
            List <Group> groupList = null;

            try
            {
                String connectionString = DatabaseConnections.getConnectionString("NARAYANA_CLIENT");
                using (SqlConnection connection = new SqlConnection(connectionString))
                {
                    connection.Open();
                    String sqlQuery = "SELECT * FROM " + GROUPS_TABLE;
                    using (SqlCommand command = new SqlCommand(sqlQuery, connection))
                    {
                        groupList = new List <Group>();
                        using (SqlDataReader reader = command.ExecuteReader())
                        {
                            while (reader.Read())
                            {
                                Console.Write(reader.GetString(1));
                                Group group = GroupsUtility.getGroupFormReader(reader);
                                groupList.Add(group);
                            }
                        }
                    }
                }
            }
            catch (InvalidOperationException e) { return(e); }
            catch (SqlException e) { return(e); }
            catch (Exception e) { return(e); }
            return(groupList);
        }
示例#3
0
        protected override void ExecuteCmdlet()
        {
            if (Identity != null)
            {
                AzureADGroup group = Identity.GetGroup(AccessToken);

                if (group != null)
                {
                    GroupsUtility.DeleteGroup(group.Id, AccessToken);
                }
            }
        }
示例#4
0
        protected override void ExecuteCmdlet()
        {
            AzureADGroup group = null;

            if (Identity != null)
            {
                group = Identity.GetGroup(AccessToken);
            }

            if (group != null)
            {
                GroupsUtility.RemoveGroupMembers(group.Id, Users, AccessToken);
            }
        }
        protected override void ExecuteCmdlet()
        {
            AzureADGroup group = null;

            if (Identity != null)
            {
                group = Identity.GetGroup(AccessToken);
            }

            if (group != null)
            {
                GroupsUtility.AddGroupOwners(group.Id, Users, AccessToken, RemoveExisting.ToBool());
            }
        }
示例#6
0
        protected override void ExecuteCmdlet()
        {
            AzureADGroup group = null;

            if (Identity != null)
            {
                group = Identity.GetGroup(AccessToken);
            }

            if (group != null)
            {
                GroupsUtility.ClearGroupOwners(group.Id, AccessToken);
            }
        }
        public AzureADGroup GetDeletedGroup(string accessToken)
        {
            GroupEntity group = null;

            if (Group != null)
            {
                group = GroupsUtility.GetDeletedGroup(Group.Id, accessToken);
            }
            else if (!string.IsNullOrEmpty(GroupId))
            {
                group = GroupsUtility.GetDeletedGroup(GroupId, accessToken);
            }

            return(AzureADGroup.CreateFrom(group));
        }
示例#8
0
 protected override void ExecuteCmdlet()
 {
     if (Identity != null)
     {
         var group = Identity.GetGroup(AccessToken);
         WriteObject(group);
     }
     else
     {
         var groups = GroupsUtility.GetGroups(AccessToken);
         if (groups.Any())
         {
             WriteObject(groups.Select(e => AzureADGroup.CreateFrom(e)), true);
         }
     }
 }
示例#9
0
        protected override void ExecuteCmdlet()
        {
            AzureADGroup group = null;

            if (Identity != null)
            {
                group = Identity.GetGroup(AccessToken);
            }

            if (group != null)
            {
                try
                {
                    GroupsUtility.UpdateGroup(
                        groupId: group.Id,
                        accessToken: AccessToken,
                        displayName: DisplayName,
                        description: Description,
                        owners: Owners,
                        members: Members,
                        mailEnabled: group.MailEnabled,
                        securityEnabled: group.SecurityEnabled
                        );

                    if (ParameterSpecified(nameof(HideFromAddressLists)) || ParameterSpecified(nameof(HideFromOutlookClients)))
                    {
                        // For this scenario a separate call needs to be made
                        Utilities.Microsoft365GroupsUtility.SetVisibilityAsync(HttpClient, AccessToken, new Guid(group.Id), HideFromAddressLists, HideFromOutlookClients).GetAwaiter().GetResult();
                    }
                }
                catch (Exception e)
                {
                    while (e.InnerException != null)
                    {
                        e = e.InnerException;
                    }
                    WriteError(new ErrorRecord(e, "GROUPUPDATEFAILED", ErrorCategory.InvalidOperation, this));
                }
            }
            else
            {
                WriteError(new ErrorRecord(new Exception("Group not found"), "GROUPNOTFOUND", ErrorCategory.ObjectNotFound, this));
            }
        }
示例#10
0
        protected override void ExecuteCmdlet()
        {
            AzureADGroup group = null;

            if (Identity != null)
            {
                group = Identity.GetGroup(AccessToken);
            }

            if (group != null)
            {
                // Get Owners of the group
                List <GroupUser> owners = GroupsUtility.GetGroupOwners(group.Convert(), AccessToken);
                if (owners.Any())
                {
                    WriteObject(owners.Select(o => AzureADGroupUser.CreateFrom(o)), true);
                }
            }
        }
示例#11
0
        protected override void ExecuteCmdlet()
        {
            if (PnPConnection.Current.ClientId == PnPConnection.PnPManagementShellClientId)
            {
                PnPConnection.Current.Scopes = new[] { "Group.ReadWrite.All" };
            }

            AzureADGroup group = null;

            if (Identity != null)
            {
                group = Identity.GetGroup(AccessToken);
            }

            if (group != null)
            {
                GroupsUtility.AddGroupMembers(group.Id, Users, AccessToken, RemoveExisting.ToBool());
            }
        }
        public ActionResult Put([FromBody] Group group)
        {
            String error;

            if (GroupsUtility.checkForValidGroup(out error, group))
            {
                Object result = GroupTable.updateGroup(group);
                Group  group1 = result as Group;
                if (null != group1)
                {
                    return(Ok(result));
                }
                else
                {
                    return(NotFound(result));
                }
            }
            else
            {
                return(NotFound(new ErrorText(error)));
            }
        }
        public static Object getGroupForId(int id)
        {
            Group group = null;

            try
            {
                String connectionString = DatabaseConnections.getConnectionString("NARAYANA_CLIENT");
                using (SqlConnection connection = new SqlConnection(connectionString))
                {
                    connection.Open();
                    String sqlQuery = "SELECT * FROM " + GROUPS_TABLE + " WHERE ID = " + id;
                    using (SqlCommand command = new SqlCommand(sqlQuery, connection))
                    {
                        using (SqlDataReader reader = command.ExecuteReader())
                        {
                            while (reader.Read())
                            {
                                Console.Write(reader.GetString(1));
                                group = GroupsUtility.getGroupFormReader(reader);
                            }
                        }
                    }
                }
            }
            catch (SqlException e) { return(e); }
            catch (InvalidOperationException e) { return(e); }
            catch (InvalidCastException e) { return(e); }
            catch (Exception e) { return(e); }

            if (null != group)
            {
                return(group);
            }
            else
            {
                return(new Exception("Student Not Found"));
            }
        }
示例#14
0
        protected override void ExecuteCmdlet()
        {
            if (MailNickname.Contains(" "))
            {
                throw new ArgumentException("MailNickname cannot contain spaces.");
            }
            bool forceCreation;

            if (!Force)
            {
                var existingGroup = GroupsUtility.GetGroups(AccessToken,
                                                            mailNickname: MailNickname,
                                                            endIndex: 1).Any();

                forceCreation = !existingGroup || ShouldContinue(string.Format(Resources.ForceCreationOfExistingGroup0, MailNickname), Resources.Confirm);
            }
            else
            {
                forceCreation = true;
            }

            if (forceCreation)
            {
                var group = GroupsUtility.CreateGroup(
                    displayName: DisplayName,
                    description: Description,
                    mailNickname: MailNickname,
                    accessToken: AccessToken,
                    owners: Owners,
                    members: Members,
                    securityEnabled: IsSecurityEnabled,
                    mailEnabled: IsMailEnabled);

                WriteObject(group);
            }
        }