Example #1
0
        private void SetEntryIds(ParticipantEntryId[] mainEntryIds, ParticipantEntryId[] oneOffEntryIds, byte[][] extraBytes)
        {
            bool flag = this.alwaysStream;

            byte[][] array = DistributionList.EncodeEntryIds(mainEntryIds);
            byte[][] value = DistributionList.EncodeEntryIds(oneOffEntryIds);
            this.computedChecksum = DistributionList.ComputeChecksum(array);
            if (!flag)
            {
                flag = DistributionList.NeedToStream(DistributionListSchema.Members, array);
            }
            if (!flag)
            {
                flag = DistributionList.NeedToStream(DistributionListSchema.OneOffMembers, value);
            }
            if (flag)
            {
                using (Stream stream = base.OpenPropertyStream(DistributionListSchema.DLStream, PropertyOpenMode.Create))
                {
                    DistributionList.SerializeEntryIdsOnStream(this.alwaysStream, stream, mainEntryIds, oneOffEntryIds, extraBytes);
                    this.SetFakeEntryInLegacyPDL();
                    goto IL_93;
                }
            }
            base.Delete(DistributionListSchema.DLStream);
            this[DistributionListSchema.Members]       = array;
            this[DistributionListSchema.OneOffMembers] = value;
IL_93:
            this[DistributionListSchema.DLChecksum] = (int)this.computedChecksum;
        }
        private Item BindToItemWithItemClass(StoreObjectId id, ICollection <PropertyDefinition> properties)
        {
            switch (id.ObjectType)
            {
            case StoreObjectType.Message:
                return(MessageItem.Bind(this.folder.Session, id, properties));

            case StoreObjectType.MeetingRequest:
                return(MeetingRequest.Bind(this.folder.Session, id, properties));

            case StoreObjectType.MeetingResponse:
                return(MeetingResponse.Bind(this.folder.Session, id, properties));

            case StoreObjectType.MeetingCancellation:
                return(MeetingCancellation.Bind(this.folder.Session, id, properties));

            case StoreObjectType.Contact:
                return(Contact.Bind(this.folder.Session, id, properties));

            case StoreObjectType.DistributionList:
                return(DistributionList.Bind(this.folder.Session, id, properties));

            case StoreObjectType.Task:
                return(Task.Bind(this.folder.Session, id, true, properties));

            case StoreObjectType.Post:
                return(PostItem.Bind(this.folder.Session, id, properties));

            case StoreObjectType.Report:
                return(ReportMessage.Bind(this.folder.Session, id, properties));
            }
            return(Item.Bind(this.folder.Session, id, properties));
        }
Example #3
0
 private static void ParseEntryIdStream(Stream dlStream, out ParticipantEntryId[] mainEntryIds, out ParticipantEntryId[] oneOffEntryIds, out byte[][] mainIds, out byte[][] extraBytes, out bool alwaysStream)
 {
     using (BinaryReader binaryReader = new BinaryReader(dlStream, Encoding.Unicode))
     {
         binaryReader.ReadUInt16();
         binaryReader.ReadUInt16();
         binaryReader.ReadInt32();
         int num = binaryReader.ReadInt32();
         alwaysStream = ((num & 1) == 1);
         int num2 = binaryReader.ReadInt32();
         if (num2 > StorageLimits.Instance.DistributionListMaxNumberOfEntries)
         {
             throw new CorruptDataException(ServerStrings.ExPDLCorruptOutlookBlob("TooManyEntries"));
         }
         binaryReader.ReadInt32();
         binaryReader.ReadInt32();
         binaryReader.ReadInt32();
         mainIds = new byte[num2][];
         byte[][] array = new byte[num2][];
         extraBytes = new byte[num2][];
         for (int i = 0; i < num2; i++)
         {
             int num3 = binaryReader.ReadInt32();
             mainIds[i]    = ((num3 > 0) ? binaryReader.ReadBytes(num3) : Array <byte> .Empty);
             num3          = binaryReader.ReadInt32();
             array[i]      = ((num3 > 0) ? binaryReader.ReadBytes(num3) : Array <byte> .Empty);
             num3          = binaryReader.ReadInt32();
             extraBytes[i] = ((num3 > 0) ? binaryReader.ReadBytes(num3) : Array <byte> .Empty);
         }
         mainEntryIds   = DistributionList.ParseEntryIds(mainIds);
         oneOffEntryIds = DistributionList.ParseEntryIds(array);
     }
 }
 internal DistributionListMember(DistributionList distributionList, ParticipantEntryId mainEntryId, OneOffParticipantEntryId oneOffEntryId, byte[] extraBytes) : this(distributionList, mainEntryId, oneOffEntryId)
 {
     if (extraBytes != null)
     {
         this.extraBytes = extraBytes;
     }
 }
        public static bool UpdateProperties(ICorePropertyBag propertyBag)
        {
            ParticipantEntryId[] array;
            ParticipantEntryId[] array2;
            byte[][]             array3;
            uint num;
            bool flag;

            DistributionList.GetEntryIds(propertyBag, out array, out array2, out array3, out num, out flag);
            return(false);
        }
 internal static DistributionListMember CopyFrom(DistributionList distributionList, DistributionListMember member)
 {
     if (member != null)
     {
         return(new DistributionListMember(distributionList, member.mainEntryId, member.oneOffEntryId));
     }
     if (member.Participant != null)
     {
         return(new DistributionListMember(distributionList, member.Participant));
     }
     throw new NotSupportedException(ServerStrings.ExCantCopyBadAlienDLMember);
 }
Example #7
0
        private void SetFakeEntryInLegacyPDL()
        {
            string             text = "Unknown";
            ParticipantEntryId participantEntryId = new OneOffParticipantEntryId(ClientStrings.LegacyPDLFakeEntry, text, text);

            byte[][] value = DistributionList.EncodeEntryIds(new ParticipantEntryId[]
            {
                participantEntryId
            });
            this[DistributionListSchema.Members]       = value;
            this[DistributionListSchema.OneOffMembers] = value;
        }
 internal DistributionListMember(DistributionList distributionList, Participant participant)
 {
     if (participant == null)
     {
         throw new ArgumentNullException("participant");
     }
     this.distributionList = distributionList;
     this.participant      = participant;
     this.memberStatus     = MemberStatus.Normal;
     this.mainEntryId      = ParticipantEntryId.FromParticipant(participant, ParticipantEntryIdConsumer.DLMemberList);
     if (this.mainEntryId == null)
     {
         throw new InvalidParticipantException(ServerStrings.ExOperationNotSupportedForRoutingType("DistributionList.Add", participant.RoutingType), ParticipantValidationStatus.OperationNotSupportedForRoutingType);
     }
 }
Example #9
0
        internal static void GetEntryIds(ICorePropertyBag propertyBag, out ParticipantEntryId[] mainEntryIds, out ParticipantEntryId[] oneOffEntryIds, out byte[][] extraBytes, out uint computedCheckSum, out bool alwaysStream)
        {
            mainEntryIds     = new ParticipantEntryId[0];
            oneOffEntryIds   = new ParticipantEntryId[0];
            extraBytes       = new byte[0][];
            computedCheckSum = 0U;
            alwaysStream     = false;
            PropertyError propertyError = propertyBag.TryGetProperty(DistributionListSchema.DLStream) as PropertyError;

            if (propertyError == null || PropertyError.IsPropertyValueTooBig(propertyError))
            {
                long num = -1L;
                try
                {
                    using (Stream stream = propertyBag.OpenPropertyStream(DistributionListSchema.DLStream, PropertyOpenMode.ReadOnly))
                    {
                        if (stream != null && stream.Length > 0L)
                        {
                            num = stream.Length;
                            byte[][] memberIds;
                            DistributionList.ParseEntryIdStream(stream, out mainEntryIds, out oneOffEntryIds, out memberIds, out extraBytes, out alwaysStream);
                            computedCheckSum = DistributionList.ComputeChecksum(memberIds);
                            return;
                        }
                        ExTraceGlobals.StorageTracer.TraceWarning <string>(0L, "DistributionList::GetEntryIds. DLStream property is {0}.", (stream == null) ? "null" : "empty");
                    }
                }
                catch (EndOfStreamException innerException)
                {
                    string          arg     = (propertyError == null) ? "<null>" : propertyError.ToLocalizedString();
                    LocalizedString message = ServerStrings.ExPDLCorruptOutlookBlob(string.Format("EndOfStreamException: propertyError={0}, streamLength={1}", arg, num.ToString()));
                    throw new CorruptDataException(message, innerException);
                }
                catch (OutOfMemoryException innerException2)
                {
                    throw new CorruptDataException(ServerStrings.ExPDLCorruptOutlookBlob("OutOfMemoryException"), innerException2);
                }
            }
            mainEntryIds     = DistributionList.ParseEntryIds(propertyBag.GetValueOrDefault <byte[][]>(DistributionListSchema.Members, DistributionList.EmptyEntryIds));
            oneOffEntryIds   = DistributionList.ParseEntryIds(propertyBag.GetValueOrDefault <byte[][]>(DistributionListSchema.OneOffMembers, DistributionList.EmptyEntryIds));
            extraBytes       = new byte[mainEntryIds.Length][];
            computedCheckSum = DistributionList.ComputeChecksum(propertyBag.GetValueOrDefault <byte[][]>(DistributionListSchema.Members, DistributionList.EmptyEntryIds));
        }
Example #10
0
        private void NormalizeADEntryIds(ParticipantEntryId[] mainEntryIds, ParticipantEntryId[] oneOffEntryIds)
        {
            List <string> list  = new List <string>();
            List <int>    list2 = new List <int>();

            for (int i = 0; i < mainEntryIds.Length; i++)
            {
                ADParticipantEntryId     adparticipantEntryId     = mainEntryIds[i] as ADParticipantEntryId;
                OneOffParticipantEntryId oneOffParticipantEntryId = (OneOffParticipantEntryId)oneOffEntryIds[i];
                if (adparticipantEntryId != null && (oneOffParticipantEntryId == null || adparticipantEntryId.IsDL == null))
                {
                    list.Add(adparticipantEntryId.LegacyDN);
                    list2.Add(i);
                }
                else if (oneOffParticipantEntryId != null && oneOffParticipantEntryId.EmailAddressType == "EX")
                {
                    list.Add(oneOffParticipantEntryId.EmailAddress);
                    list2.Add(i);
                }
            }
            if (list.Count > 0)
            {
                object[][] array = DistributionList.LookupInAD(() => base.Session.GetADRecipientSession(true, ConsistencyMode.IgnoreInvalid), list, DistributionList.adLookupProperties);
                for (int j = 0; j < list.Count; j++)
                {
                    if (array[j] != null)
                    {
                        int num = list2[j];
                        if (mainEntryIds[num] is ADParticipantEntryId && mainEntryIds[num].IsDL == null)
                        {
                            bool flag = DistributionList.IsDL((RecipientType)array[j][2]);
                            mainEntryIds[num] = new ADParticipantEntryId(list[j], new LegacyRecipientDisplayType?(flag ? LegacyRecipientDisplayType.DistributionList : LegacyRecipientDisplayType.MailUser), true);
                        }
                        OneOffParticipantEntryId oneOffParticipantEntryId2 = oneOffEntryIds[num] as OneOffParticipantEntryId;
                        oneOffEntryIds[num] = new OneOffParticipantEntryId((oneOffParticipantEntryId2 != null) ? oneOffParticipantEntryId2.EmailDisplayName : ((string)array[j][0]), array[j][1].ToString(), "SMTP");
                    }
                }
            }
        }
        internal DistributionListMember(DistributionList distributionList, ParticipantEntryId mainEntryId, OneOffParticipantEntryId oneOffEntryId)
        {
            this.distributionList = distributionList;
            this.memberStatus     = MemberStatus.Normal;
            Participant.Builder  builder = new Participant.Builder();
            ADParticipantEntryId adparticipantEntryId = mainEntryId as ADParticipantEntryId;

            if (adparticipantEntryId != null)
            {
                builder.SetPropertiesFrom(adparticipantEntryId);
                if (oneOffEntryId != null)
                {
                    builder.DisplayName = oneOffEntryId.EmailDisplayName;
                    if (!string.IsNullOrEmpty(oneOffEntryId.EmailAddress) && Participant.RoutingTypeEquals(oneOffEntryId.EmailAddressType, "SMTP"))
                    {
                        builder[ParticipantSchema.SmtpAddress] = oneOffEntryId.EmailAddress;
                    }
                }
                this.participant = builder.ToParticipant();
            }
            else
            {
                StoreParticipantEntryId storeParticipantEntryId = mainEntryId as StoreParticipantEntryId;
                if (storeParticipantEntryId != null && oneOffEntryId != null)
                {
                    builder.SetPropertiesFrom(oneOffEntryId);
                    builder.SetPropertiesFrom(storeParticipantEntryId);
                    this.participant = builder.ToParticipant();
                }
                else
                {
                    OneOffParticipantEntryId oneOffParticipantEntryId = mainEntryId as OneOffParticipantEntryId;
                    if (oneOffParticipantEntryId == null)
                    {
                        oneOffParticipantEntryId = oneOffEntryId;
                        this.memberStatus        = MemberStatus.Demoted;
                    }
                    if (oneOffParticipantEntryId != null)
                    {
                        builder.SetPropertiesFrom(oneOffParticipantEntryId);
                        this.participant = builder.ToParticipant();
                    }
                    else
                    {
                        this.memberStatus = MemberStatus.Unrecognized;
                    }
                }
            }
            if (this.mainEntryId == null)
            {
                this.mainEntryId = mainEntryId;
            }
            if (this.oneOffEntryId == null)
            {
                this.oneOffEntryId = oneOffEntryId;
            }
            ExTraceGlobals.StorageTracer.Information((long)this.GetHashCode(), "Loaded a {1} DL member \"{0}\". MainEntryId=\"{2}\", OneOffEntryId=\"{3}\"", new object[]
            {
                this.participant,
                this.memberStatus,
                this.mainEntryId,
                this.oneOffEntryId
            });
        }
Example #12
0
 public IDistributionList CreateDistributionList(IStoreSession session, StoreId contactFolderId)
 {
     return(DistributionList.Create((StoreSession)session, contactFolderId));
 }
Example #13
0
 public IDistributionList BindToDistributionList(IStoreSession session, StoreId storeId, ICollection <PropertyDefinition> propsToReturn)
 {
     return(DistributionList.Bind((StoreSession)session, storeId, propsToReturn));
 }
Example #14
0
 public IDistributionList BindToDistributionList(IStoreSession session, StoreId storeId)
 {
     return(DistributionList.Bind((StoreSession)session, storeId));
 }
Example #15
0
 public static Participant[] ExpandDeep(StoreSession storeSession, StoreObjectId distributionListId)
 {
     return(DistributionList.ExpandDeep(storeSession, distributionListId, false));
 }
Example #16
0
 private void GetEntryIds(out ParticipantEntryId[] mainEntryIds, out ParticipantEntryId[] oneOffEntryIds, out byte[][] extraBytes)
 {
     DistributionList.GetEntryIds(base.PropertyBag, out mainEntryIds, out oneOffEntryIds, out extraBytes, out this.computedChecksum, out this.alwaysStream);
 }
Example #17
0
 public new static DistributionList Bind(StoreSession session, StoreId storeId, params PropertyDefinition[] propsToReturn)
 {
     return(DistributionList.Bind(session, storeId, (ICollection <PropertyDefinition>)propsToReturn));
 }
Example #18
0
 public new static DistributionList Bind(StoreSession session, StoreId storeId)
 {
     return(DistributionList.Bind(session, storeId, null));
 }
Example #19
0
        private void PreprocessEntryIds(ParticipantEntryId[] mainEntryIds, ref ParticipantEntryId[] oneOffEntryIds)
        {
            OneOffParticipantEntryId[] array = new OneOffParticipantEntryId[mainEntryIds.Length];
            if (!this.ChecksumIsCurrent())
            {
                int i = 0;
                while (i < mainEntryIds.Length)
                {
                    StoreParticipantEntryId  storeParticipantEntryId  = mainEntryIds[i] as StoreParticipantEntryId;
                    OneOffParticipantEntryId oneOffParticipantEntryId = mainEntryIds[i] as OneOffParticipantEntryId;
                    if (storeParticipantEntryId != null)
                    {
                        try
                        {
                            using (Item item = Microsoft.Exchange.Data.Storage.Item.Bind(base.Session, storeParticipantEntryId.ToUniqueItemId(), ContactSchema.Instance.AutoloadProperties))
                            {
                                Contact          contact          = item as Contact;
                                DistributionList distributionList = item as DistributionList;
                                if (contact != null)
                                {
                                    Participant participant = contact.EmailAddresses[storeParticipantEntryId.EmailAddressIndex];
                                    if (participant != null)
                                    {
                                        Participant participant2 = new Participant(contact.DisplayName, participant.EmailAddress, participant.RoutingType, participant.Origin, Array <PropValue> .Empty);
                                        array[i] = (OneOffParticipantEntryId)ParticipantEntryId.FromParticipant(participant2, ParticipantEntryIdConsumer.SupportsNone);
                                    }
                                }
                                else if (distributionList != null)
                                {
                                    array[i] = (OneOffParticipantEntryId)ParticipantEntryId.FromParticipant(distributionList.GetAsParticipant(), ParticipantEntryIdConsumer.SupportsNone);
                                }
                            }
                            goto IL_F1;
                        }
                        catch (ObjectNotFoundException)
                        {
                            goto IL_F1;
                        }
                        goto IL_EA;
                    }
                    goto IL_EA;
IL_F1:
                    i++;
                    continue;
IL_EA:
                    if (oneOffParticipantEntryId != null)
                    {
                        array[i] = oneOffParticipantEntryId;
                        goto IL_F1;
                    }
                    goto IL_F1;
                }
            }
            else
            {
                for (int j = 0; j < mainEntryIds.Length; j++)
                {
                    array[j] = (oneOffEntryIds[j] as OneOffParticipantEntryId);
                }
            }
            OneOffParticipantEntryId[] array2 = (OneOffParticipantEntryId[])array.Clone();
            this.NormalizeADEntryIds(mainEntryIds, array2);
            bool flag = oneOffEntryIds.Length == array.Length;
            int  num  = 0;

            while (flag && num < oneOffEntryIds.Length)
            {
                OneOffParticipantEntryId oneOffParticipantEntryId2 = oneOffEntryIds[num] as OneOffParticipantEntryId;
                if (oneOffParticipantEntryId2 == null)
                {
                    flag = false;
                }
                else if (array2[num] != null)
                {
                    flag = ParticipantComparer.EmailAddressIgnoringRoutingType.Equals(array2[num].ToParticipant(), oneOffParticipantEntryId2.ToParticipant());
                }
                num++;
            }
            for (int k = 0; k < array.Length; k++)
            {
                if (array[k] == null)
                {
                    if (array2[k] != null)
                    {
                        array[k] = array2[k];
                    }
                    else if (flag)
                    {
                        array[k] = (OneOffParticipantEntryId)oneOffEntryIds[k];
                    }
                }
            }
            oneOffEntryIds = array;
        }
Example #20
0
        public static Participant[] ExpandDeep(StoreSession storeSession, StoreObjectId distributionListId, bool shouldAddNonExistPDL)
        {
            Dictionary <StoreObjectId, Participant> dictionary = new Dictionary <StoreObjectId, Participant>();
            Queue <StoreObjectId> queue = new Queue <StoreObjectId>();
            List <Participant>    list  = new List <Participant>();

            queue.Enqueue(distributionListId);
            while (queue.Count > 0)
            {
                StoreObjectId    storeObjectId    = queue.Dequeue();
                DistributionList distributionList = null;
                try
                {
                    distributionList = DistributionList.Bind(storeSession, storeObjectId);
                }
                catch (ObjectNotFoundException arg)
                {
                    if (storeSession.ItemBinder != null)
                    {
                        Item item = storeSession.ItemBinder.BindItem(storeObjectId, IdConverter.IsFromPublicStore(storeObjectId), IdConverter.GetParentIdFromMessageId(storeObjectId));
                        distributionList = (item as DistributionList);
                        if (item != null && distributionList == null)
                        {
                            item.Dispose();
                        }
                    }
                    if (distributionList == null)
                    {
                        ExTraceGlobals.StorageTracer.TraceDebug <ObjectNotFoundException>(0L, "DistributionList::ExpandDeep. A PDL member in PDL doesn't exist. Ignore it and continue to expand other members. Exception = {0}.", arg);
                        if (shouldAddNonExistPDL && dictionary.ContainsKey(storeObjectId))
                        {
                            list.Add(new Participant(dictionary[storeObjectId].DisplayName, null, "MAPIPDL"));
                        }
                    }
                }
                if (distributionList != null)
                {
                    using (distributionList)
                    {
                        foreach (DistributionListMember distributionListMember in distributionList)
                        {
                            if (!(distributionListMember.Participant == null))
                            {
                                if (distributionListMember.IsDistributionList() == true && distributionListMember.Participant.Origin is StoreParticipantOrigin && distributionListMember.Participant.ValidationStatus == ParticipantValidationStatus.NoError)
                                {
                                    StoreObjectId originItemId = ((StoreParticipantOrigin)distributionListMember.Participant.Origin).OriginItemId;
                                    if (!dictionary.ContainsKey(originItemId) && !originItemId.Equals(distributionListId))
                                    {
                                        queue.Enqueue(originItemId);
                                        dictionary.Add(originItemId, distributionListMember.Participant);
                                    }
                                }
                                else
                                {
                                    list.Add(distributionListMember.Participant);
                                }
                            }
                        }
                    }
                }
            }
            return(list.ToArray());
        }