예제 #1
0
        protected override void InternalValidate()
        {
            TaskLogger.LogEnter();
            base.InternalValidate();
            bool flag = false;

            if (base.Fields.IsModified(ADGroupSchema.Members))
            {
                if (this.DataObject.RoleGroupType == RoleGroupType.Linked)
                {
                    base.WriteError(new RecipientTaskException(Strings.ErrorLinkedRoleGroupCannotHaveMembers), (ErrorCategory)1000, null);
                }
                List <ADObjectId> list = null;
                SecurityPrincipalIdParameter[] parameters    = this.GetChangedValues(true);
                SecurityPrincipalIdParameter[] changedValues = this.GetChangedValues(false);
                if (this.Members == null || !this.Members.IsChangesOnlyCopy)
                {
                    flag = true;
                    if (this.Members != null)
                    {
                        parameters = this.Members.ToArray();
                    }
                    list = this.DataObject.Members.ToList <ADObjectId>();
                    this.DataObject.Members = new MultiValuedProperty <ADObjectId>();
                }
                SyncTaskHelper.ResolveModifiedMultiReferenceParameter <SecurityPrincipalIdParameter>("Members", "AddedMembers", parameters, new GetRecipientDelegate <SecurityPrincipalIdParameter>(this.GetRecipient), this.ReferenceErrorReporter, this.recipientIdsDictionary, this.recipientsDictionary, this.parameterDictionary);
                SyncTaskHelper.ValidateModifiedMultiReferenceParameter <ADGroup>("Members", "AddedMembers", this.DataObject, new ValidateRecipientWithBaseObjectDelegate <ADGroup>(MailboxTaskHelper.ValidateGroupMember), this.ReferenceErrorReporter, this.recipientsDictionary, this.parameterDictionary);
                SyncTaskHelper.AddModifiedRecipientIds("AddedMembers", SyncDistributionGroupSchema.Members, this.DataObject, this.recipientIdsDictionary);
                if (flag)
                {
                    MultiValuedProperty <ADObjectId> multiValuedProperty = new MultiValuedProperty <ADObjectId>();
                    foreach (ADObjectId item in list)
                    {
                        if (!this.DataObject.Members.Contains(item))
                        {
                            multiValuedProperty.Add(item);
                        }
                    }
                    this.recipientIdsDictionary["RemovedMembers"] = multiValuedProperty;
                }
                else
                {
                    SyncTaskHelper.ResolveModifiedMultiReferenceParameter <SecurityPrincipalIdParameter>("Members", "RemovedMembers", changedValues, new GetRecipientDelegate <SecurityPrincipalIdParameter>(this.GetRecipient), this.ReferenceErrorReporter, this.recipientIdsDictionary, this.recipientsDictionary, this.parameterDictionary);
                    SyncTaskHelper.RemoveModifiedRecipientIds("RemovedMembers", SyncDistributionGroupSchema.Members, this.DataObject, this.recipientIdsDictionary);
                }
            }
            MailboxTaskHelper.ValidateAddedMembers(base.TenantGlobalCatalogSession, this.DataObject, new Task.ErrorLoggerDelegate(base.WriteError), new DataAccessHelper.CategorizedGetDataObjectDelegate(base.GetDataObject <ADRecipient>));
            if (this.recipientIdsDictionary.ContainsKey("RemovedMembers") && this.recipientIdsDictionary["RemovedMembers"].Count > 0)
            {
                RoleAssignmentsGlobalConstraints roleAssignmentsGlobalConstraints = new RoleAssignmentsGlobalConstraints(this.ConfigurationSession, base.TenantGlobalCatalogSession, new Task.ErrorLoggerDelegate(base.WriteError));
                roleAssignmentsGlobalConstraints.ValidateIsSafeToRemoveRoleGroupMember(this.DataObject, new List <ADObjectId>(this.recipientIdsDictionary["RemovedMembers"]));
            }
            TaskLogger.LogExit();
        }
 protected override void PerformGroupMemberAction()
 {
     TaskLogger.LogEnter();
     MailboxTaskHelper.ValidateAndRemoveMember(base.TenantGlobalCatalogSession, this.DataObject, base.Member, null, false, new Task.TaskErrorLoggingDelegate(base.WriteError), new DataAccessHelper.GetDataObjectDelegate(base.GetDataObject <ADRecipient>));
     if (this.DataObject.Members.Changed)
     {
         ADRecipient adrecipient = (ADRecipient)base.GetDataObject <ADRecipient>(base.Member, base.TenantGlobalCatalogSession, this.DataObject.OrganizationId.OrganizationalUnit, null, new LocalizedString?(Strings.ErrorRecipientNotFound(base.Member.ToString())), new LocalizedString?(Strings.ErrorRecipientNotUnique(base.Member.ToString())));
         RoleAssignmentsGlobalConstraints roleAssignmentsGlobalConstraints = new RoleAssignmentsGlobalConstraints(this.ConfigurationSession, base.TenantGlobalCatalogSession, new Task.ErrorLoggerDelegate(base.WriteError));
         roleAssignmentsGlobalConstraints.ValidateIsSafeToRemoveRoleGroupMember(this.DataObject, new List <ADObjectId>
         {
             adrecipient.Id
         });
     }
     TaskLogger.LogExit();
 }