private void RemoveTagFromExternalAddressEntry(ADObjectIdWithString entry, string[] tags, SmtpAddress externalRecipientToRemove, MultiValuedProperty <ADObjectIdWithString> supervisionList)
        {
            if (tags.Length == 1)
            {
                supervisionList.Remove(entry);
                return;
            }
            StringBuilder stringBuilder = new StringBuilder(entry.StringValue.Length - this.Tag.Length - 1);

            foreach (string text in tags)
            {
                if (!text.Equals(this.Tag, StringComparison.OrdinalIgnoreCase))
                {
                    if (stringBuilder.Length != 0)
                    {
                        stringBuilder.Append(SupervisionListEntryConstraint.Delimiter);
                    }
                    stringBuilder.Append(text);
                }
            }
            stringBuilder.Append(SupervisionListEntryConstraint.Delimiter);
            stringBuilder.Append(externalRecipientToRemove.ToString());
            ADObjectIdWithString item = new ADObjectIdWithString(stringBuilder.ToString(), entry.ObjectIdValue);

            supervisionList.Remove(entry);
            supervisionList.Add(item);
        }
        private void RemoveADRecipientSupervisionListEntry(bool isGroup, ADRecipient adRecipientToRemove)
        {
            MultiValuedProperty <ADObjectIdWithString> supervisionListForADRecipient = base.GetSupervisionListForADRecipient(isGroup);
            ADObjectIdWithString adobjectIdWithString = null;

            string[] array = null;
            PropertyValidationError propertyValidationError = base.FindADRecipientEntry(adRecipientToRemove, supervisionListForADRecipient, out adobjectIdWithString, out array);

            if (propertyValidationError != null)
            {
                return;
            }
            if (adobjectIdWithString != null)
            {
                foreach (string text in array)
                {
                    if (text.Equals(this.Tag, StringComparison.OrdinalIgnoreCase))
                    {
                        this.RemoveTagFromADRecipientEntry(adobjectIdWithString, array, supervisionListForADRecipient);
                        return;
                    }
                }
                base.WriteError(new RecipientTaskException(Strings.ErrorSupervisionEntryNotPresent(this.Entry.ToString(), this.Tag.ToLower())), (ErrorCategory)1003, null);
                return;
            }
            base.WriteError(new RecipientTaskException(Strings.ErrorSupervisionEntryNotPresent(this.Entry.ToString(), this.Tag.ToLower())), (ErrorCategory)1003, null);
        }
Exemplo n.º 3
0
        private void GetADRecipientEntries(ADRecipient dataObject, bool isGroup, List <SupervisionListEntry> results)
        {
            MultiValuedProperty <ADObjectIdWithString> multiValuedProperty = isGroup ? ((MultiValuedProperty <ADObjectIdWithString>)dataObject[ADRecipientSchema.DLSupervisionList]) : ((MultiValuedProperty <ADObjectIdWithString>)dataObject[ADRecipientSchema.InternalRecipientSupervisionList]);
            SupervisionRecipientType recipientType = isGroup ? SupervisionRecipientType.DistributionGroup : SupervisionRecipientType.IndividualRecipient;

            ADObjectId[] array = new ADObjectId[multiValuedProperty.Count];
            for (int i = 0; i < multiValuedProperty.Count; i++)
            {
                array[i] = multiValuedProperty[i].ObjectIdValue;
            }
            Result <ADRawEntry>[] array2 = base.TenantGlobalCatalogSession.ReadMultiple(array, new PropertyDefinition[]
            {
                ADObjectSchema.RawName
            });
            for (int j = 0; j < multiValuedProperty.Count; j++)
            {
                ADObjectIdWithString           adobjectIdWithString           = multiValuedProperty[j];
                SupervisionListEntryConstraint supervisionListEntryConstraint = new SupervisionListEntryConstraint(false);
                if (supervisionListEntryConstraint.Validate(adobjectIdWithString, null, null) == null)
                {
                    string[] array3 = adobjectIdWithString.StringValue.Split(new char[]
                    {
                        SupervisionListEntryConstraint.Delimiter
                    });
                    string entryName = (string)array2[j].Data[ADObjectSchema.Name];
                    foreach (string text in array3)
                    {
                        if (this.Tag == null || this.Tag.Equals(text, StringComparison.OrdinalIgnoreCase))
                        {
                            SupervisionListEntry item = null;
                            try
                            {
                                item = new SupervisionListEntry(entryName, text, recipientType);
                            }
                            catch (ArgumentNullException exception)
                            {
                                base.WriteError(exception, (ErrorCategory)1000, null);
                            }
                            results.Add(item);
                        }
                    }
                }
            }
        }
Exemplo n.º 4
0
        private void AddExternalRecipientSupervisionListEntry(SmtpAddress externalRecipientToAdd, ADObjectId configContainerId)
        {
            if (configContainerId == null)
            {
                base.WriteError(new ArgumentNullException("configContainerId"), (ErrorCategory)1000, null);
            }
            MultiValuedProperty <ADObjectIdWithString> supervisionListForExternalAddress = base.GetSupervisionListForExternalAddress();
            ADObjectIdWithString adobjectIdWithString = null;

            string[] array = null;
            PropertyValidationError propertyValidationError = base.FindExternalAddressEntry(externalRecipientToAdd, supervisionListForExternalAddress, out adobjectIdWithString, out array);

            if (propertyValidationError != null)
            {
                return;
            }
            if (adobjectIdWithString != null)
            {
                foreach (string text in array)
                {
                    if (text.Equals(this.Tag, StringComparison.OrdinalIgnoreCase))
                    {
                        base.WriteError(new RecipientTaskException(Strings.ErrorSupervisionEntryAlreadyPresent(this.Entry.ToString(), this.Tag.ToLower())), (ErrorCategory)1003, null);
                    }
                }
                string stringValue        = this.Tag.ToLower() + "," + adobjectIdWithString.StringValue;
                ADObjectIdWithString item = new ADObjectIdWithString(stringValue, adobjectIdWithString.ObjectIdValue);
                supervisionListForExternalAddress.Remove(adobjectIdWithString);
                supervisionListForExternalAddress.Add(item);
            }
            else
            {
                string stringValue2        = this.Tag.ToLower() + "," + externalRecipientToAdd.ToString();
                ADObjectIdWithString item2 = new ADObjectIdWithString(stringValue2, configContainerId);
                supervisionListForExternalAddress.Add(item2);
            }
            if (base.IsVerboseOn)
            {
                base.WriteVerbose(Strings.SupervisionListEntryAdded(this.Entry.ToString(), Strings.ExternalAddress, this.Tag));
            }
        }
Exemplo n.º 5
0
        private void AddADRecipientSupervisionListEntry(bool isGroup, ADRecipient adRecipientToAdd)
        {
            MultiValuedProperty <ADObjectIdWithString> supervisionListForADRecipient = base.GetSupervisionListForADRecipient(isGroup);
            ADObjectIdWithString adobjectIdWithString = null;

            string[] array = null;
            PropertyValidationError propertyValidationError = base.FindADRecipientEntry(adRecipientToAdd, supervisionListForADRecipient, out adobjectIdWithString, out array);

            if (propertyValidationError != null)
            {
                return;
            }
            if (adobjectIdWithString != null)
            {
                foreach (string text in array)
                {
                    if (text.Equals(this.Tag, StringComparison.OrdinalIgnoreCase))
                    {
                        base.WriteError(new RecipientTaskException(Strings.ErrorSupervisionEntryAlreadyPresent(this.Entry.ToString(), this.Tag.ToLower())), (ErrorCategory)1003, null);
                    }
                }
                string stringValue        = this.Tag.ToLower() + "," + adobjectIdWithString.StringValue;
                ADObjectIdWithString item = new ADObjectIdWithString(stringValue, adobjectIdWithString.ObjectIdValue);
                supervisionListForADRecipient.Remove(adobjectIdWithString);
                supervisionListForADRecipient.Add(item);
            }
            else
            {
                string stringValue2        = this.Tag.ToLower();
                ADObjectIdWithString item2 = new ADObjectIdWithString(stringValue2, adRecipientToAdd.Id);
                supervisionListForADRecipient.Add(item2);
            }
            if (base.IsVerboseOn)
            {
                base.WriteVerbose(Strings.SupervisionListEntryAdded(this.Entry.ToString(), isGroup ? Strings.DistributionGroup : Strings.IndividualRecipient, this.Tag));
            }
        }
Exemplo n.º 6
0
        protected PropertyValidationError FindExternalAddressEntry(SmtpAddress externalAddress, MultiValuedProperty <ADObjectIdWithString> supervisionList, out ADObjectIdWithString foundEntry, out string[] tags)
        {
            if (supervisionList == null)
            {
                base.WriteError(new ArgumentNullException("supervisionList"), (ErrorCategory)1000, null);
            }
            foundEntry = null;
            tags       = null;
            SupervisionListEntryConstraint supervisionListEntryConstraint = new SupervisionListEntryConstraint(true);
            PropertyValidationError        propertyValidationError        = null;

            string[] array = null;
            foreach (ADObjectIdWithString adobjectIdWithString in supervisionList)
            {
                propertyValidationError = supervisionListEntryConstraint.Validate(adobjectIdWithString, null, null);
                if (propertyValidationError != null)
                {
                    return(propertyValidationError);
                }
                array = adobjectIdWithString.StringValue.Split(new char[]
                {
                    SupervisionListEntryConstraint.Delimiter
                });
                SmtpAddress smtpAddress = new SmtpAddress(array[array.Length - 1]);
                if (smtpAddress.Equals(externalAddress))
                {
                    foundEntry = adobjectIdWithString;
                    break;
                }
            }
            if (foundEntry != null)
            {
                Array.Resize <string>(ref array, array.Length - 1);
                tags = array;
            }
            return(propertyValidationError);
        }
Exemplo n.º 7
0
        protected PropertyValidationError FindADRecipientEntry(ADRecipient adRecipient, MultiValuedProperty <ADObjectIdWithString> supervisionList, out ADObjectIdWithString foundEntry, out string[] tags)
        {
            if (adRecipient == null)
            {
                base.WriteError(new ArgumentNullException("adRecipient"), (ErrorCategory)1000, null);
            }
            if (supervisionList == null)
            {
                base.WriteError(new ArgumentNullException("supervisionList"), (ErrorCategory)1000, null);
            }
            foundEntry = null;
            tags       = null;
            foreach (ADObjectIdWithString adobjectIdWithString in supervisionList)
            {
                if (adobjectIdWithString.ObjectIdValue.Equals(adRecipient.Id))
                {
                    foundEntry = adobjectIdWithString;
                    break;
                }
            }
            PropertyValidationError propertyValidationError = null;

            if (foundEntry != null)
            {
                SupervisionListEntryConstraint supervisionListEntryConstraint = new SupervisionListEntryConstraint(false);
                propertyValidationError = supervisionListEntryConstraint.Validate(foundEntry, null, null);
                if (propertyValidationError != null)
                {
                    return(propertyValidationError);
                }
                tags = foundEntry.StringValue.Split(new char[]
                {
                    SupervisionListEntryConstraint.Delimiter
                });
            }
            return(propertyValidationError);
        }