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); } }
protected override void InternalValidate() { base.OptionalIdentityData.RootOrgDomainContainerId = this.RootOrgUSGContainerId; base.InternalValidate(); if (!this.BypassSecurityGroupManagerCheck) { ADObjectId user; base.TryGetExecutingUserId(out user); RoleGroupCommon.ValidateExecutingUserHasGroupManagementRights(user, base.DataObject, base.ExchangeRunspaceConfig, new Task.ErrorLoggerDelegate(base.WriteError)); } if (RoleGroupCommon.IsPrecannedRoleGroup(base.DataObject, this.ConfigurationSession, new Guid[0])) { base.WriteError(new TaskInvalidOperationException(Strings.ErrorCannotDeletePrecannedRoleGroup(base.DataObject.Name)), ExchangeErrorCategory.Client, null); } RoleAssignmentsGlobalConstraints roleAssignmentsGlobalConstraints = new RoleAssignmentsGlobalConstraints(this.ConfigurationSession, base.TenantGlobalCatalogSession, new Task.ErrorLoggerDelegate(base.WriteError)); roleAssignmentsGlobalConstraints.ValidateIsSafeToRemoveRoleGroup(base.DataObject, this.roleAssignmentResults, this); }