public void ValidateIsSafeToRemoveRoleGroupMember(ADGroup group, List <ADObjectId> membersToRemove)
        {
            if (group == null || membersToRemove == null)
            {
                return;
            }
            this.InitializeContextVariables();
            this.excludedFromEmptinessValidation.AddRange(membersToRemove);
            this.excludedFromAssignmentSearch.Add(group.Id);
            if (!this.IsGroupEmpty(group))
            {
                return;
            }
            this.excludedFromEmptinessValidation.Add(group.Id);
            string membersToRemove2 = RoleGroupCommon.NamesFromObjects(membersToRemove);
            bool   flag             = RoleGroupCommon.IsPrecannedRoleGroup(group, this.configurationSession, new Guid[]
            {
                RoleGroup.OrganizationManagement_InitInfo.WellKnownGuid
            });

            if (flag)
            {
                this.writeError(new TaskInvalidOperationException(Strings.ErrorCannedRoleGroupCannotBeEmpty(group.Name, membersToRemove2)), ExchangeErrorCategory.Client, null);
            }
            SharedConfiguration sharedConfiguration = SharedConfiguration.GetSharedConfiguration(group.OrganizationId);

            if (sharedConfiguration != null)
            {
                return;
            }
            Result <ExchangeRoleAssignment>[] directRoleAssignmentsForGroup = this.GetDirectRoleAssignmentsForGroup(group);
            if (directRoleAssignmentsForGroup != null)
            {
                foreach (Result <ExchangeRoleAssignment> result in directRoleAssignmentsForGroup)
                {
                    if (!this.IsSafeToRemoveDisableAssignmentFromGroup(result.Data))
                    {
                        this.writeError(new TaskInvalidOperationException(Strings.ErrorGroupCannotBeEmptyRoleAssignmentConstraint(group.Name, membersToRemove2, result.Data.Name, result.Data.Role.Name)), ExchangeErrorCategory.Client, null);
                    }
                }
            }
            ExchangeRoleAssignment exchangeRoleAssignment;

            if (!this.HierarchicalCheckForGroupEmptiness(group, out exchangeRoleAssignment))
            {
                this.writeError(new TaskInvalidOperationException(Strings.ErrorGroupCannotBeEmptyRoleAssignmentConstraint(group.Name, membersToRemove2, exchangeRoleAssignment.Name, exchangeRoleAssignment.Role.Name)), ExchangeErrorCategory.Client, null);
            }
            ADGroup adgroup = null;

            if (!this.HierarchicalCheckForCannedRoleGroups(group, out adgroup))
            {
                this.writeError(new TaskInvalidOperationException(Strings.ErrorCannedRoleGroupCannotBeEmpty(adgroup.Name, membersToRemove2)), ExchangeErrorCategory.Client, null);
            }
        }
Exemple #2
0
        private static string DumpMultiValuedPropertyWithChanges(MultiValuedPropertyBase mvp)
        {
            StringBuilder stringBuilder = new StringBuilder();

            object[] added   = mvp.Added;
            object[] removed = mvp.Removed;
            if (added.Length > 0)
            {
                stringBuilder.Append(MultiValuedProperty <string> .AddKeys[0]);
                stringBuilder.Append("=");
                stringBuilder.Append(RoleGroupCommon.NamesFromObjects(added));
                stringBuilder.Append(";");
            }
            if (removed.Length > 0)
            {
                stringBuilder.Append(MultiValuedProperty <string> .RemoveKeys[0]);
                stringBuilder.Append("=");
                stringBuilder.Append(RoleGroupCommon.NamesFromObjects(removed));
            }
            return(stringBuilder.ToString());
        }