Ejemplo n.º 1
0
 private void ParseMapiProperties()
 {
     base.Clear();
     if (this.blob != null)
     {
         IList <ParticipantEntryId> list;
         try
         {
             list = ParticipantEntryId.FromFlatEntryList(this.blob);
         }
         catch (CorruptDataException)
         {
             this.isCorrectionNeeded = true;
             throw;
         }
         string[] array = null;
         if (this.names != null)
         {
             array = this.names.Split(new char[]
             {
                 ';'
             });
             if (array.Length != list.Count)
             {
                 array = null;
             }
         }
         int num = 0;
         foreach (ParticipantEntryId participantEntryId in list)
         {
             Participant.Builder builder = new Participant.Builder();
             string text = null;
             if (array != null)
             {
                 text = array[num].Trim();
             }
             num++;
             if (participantEntryId is OneOffParticipantEntryId || participantEntryId is ADParticipantEntryId)
             {
                 builder.SetPropertiesFrom(participantEntryId);
             }
             else
             {
                 this.isCorrectionNeeded = true;
                 if (text == null)
                 {
                     continue;
                 }
                 builder.EmailAddress = text;
                 builder.RoutingType  = "SMTP";
             }
             if (text != null)
             {
                 builder.DisplayName = text;
             }
             base.Items.Add(builder.ToParticipant());
         }
     }
     this.isListChanged = false;
 }
Ejemplo n.º 2
0
 internal static byte[] ToFlatEntryList(ICollection <ParticipantEntryId> entryIds)
 {
     return(ParticipantEntryId.TranslateExceptions <byte[]>(delegate
     {
         byte[] bytes;
         using (ParticipantEntryId.Writer writer = new ParticipantEntryId.Writer())
         {
             writer.Write(entryIds.Count);
             ParticipantEntryId.Bookmark bookmark = writer.PlaceBookmark <int>(new ParticipantEntryId.WriterMethod <int>(writer.Write), 0);
             ParticipantEntryId.Bookmark currentBookmark = writer.CurrentBookmark;
             foreach (ParticipantEntryId participantEntryId in entryIds)
             {
                 if (participantEntryId == null)
                 {
                     throw new ArgumentNullException("entryIds");
                 }
                 ParticipantEntryId.Bookmark bookmark2 = writer.PlaceBookmark <int>(new ParticipantEntryId.WriterMethod <int>(writer.Write), 0);
                 ParticipantEntryId.Bookmark currentBookmark2 = writer.CurrentBookmark;
                 participantEntryId.Serialize(writer);
                 int num = (int)(writer.CurrentBookmark - currentBookmark2);
                 writer.WriteBookmark <int>(bookmark2, num);
                 writer.WritePadding(num, 4);
             }
             writer.WriteBookmark <int>(bookmark, (int)(writer.CurrentBookmark - currentBookmark));
             bytes = writer.GetBytes();
         }
         return bytes;
     }));
 }
Ejemplo n.º 3
0
        protected override void InternalSetValue(PropertyBag.BasicPropertyStore propertyBag, object value)
        {
            Participant        participant        = (Participant)value;
            ParticipantEntryId participantEntryId = ParticipantEntryId.FromParticipant(participant, this.entryIdConsumer);

            propertyBag.Update(this.displayNamePropDef, participant.DisplayName);
            propertyBag.Update(this.emailAddressPropDef, participant.EmailAddress);
            propertyBag.Update(this.routingTypePropDef, participant.RoutingType);
            propertyBag.Update(this.entryIdPropDef, (participantEntryId != null) ? participantEntryId.ToByteArray() : null);
            if (this.smtpAddressPropDef != null)
            {
                propertyBag.Update(this.smtpAddressPropDef, participant.TryGetProperty(ParticipantSchema.SmtpAddress));
            }
            if (this.sipUriPropDef != null)
            {
                propertyBag.Update(this.sipUriPropDef, participant.TryGetProperty(ParticipantSchema.SipUri));
            }
            if (this.sidPropDef != null)
            {
                propertyBag.Update(this.sidPropDef, participant.TryGetProperty(ParticipantSchema.ParticipantSID));
            }
            if (this.guidPropDef != null)
            {
                propertyBag.Update(this.guidPropDef, participant.TryGetProperty(ParticipantSchema.ParticipantGuid));
            }
        }
 internal DistributionListMember(DistributionList distributionList, ParticipantEntryId mainEntryId, OneOffParticipantEntryId oneOffEntryId, byte[] extraBytes) : this(distributionList, mainEntryId, oneOffEntryId)
 {
     if (extraBytes != null)
     {
         this.extraBytes = extraBytes;
     }
 }
        protected override void InternalSetValue(PropertyBag.BasicPropertyStore propertyBag, object value)
        {
            Participant        participant        = (Participant)value;
            ParticipantEntryId participantEntryId = ParticipantEntryId.FromParticipant(participant, ParticipantEntryIdConsumer.ContactEmailSlot);

            propertyBag.SetValueWithFixup(base.DisplayNamePropertyDefinition, participant.DisplayName ?? string.Empty);
            propertyBag.SetValueWithFixup(base.EmailAddressPropertyDefinition, participant.EmailAddress ?? string.Empty);
            propertyBag.SetValueWithFixup(base.RoutingTypePropertyDefinition, participant.RoutingType ?? string.Empty);
            if (this.emailAddressForDisplayPropDef != null)
            {
                AtomicStorePropertyDefinition propertyDefinition = this.emailAddressForDisplayPropDef;
                string propertyValue;
                if ((propertyValue = participant.GetValueOrDefault <string>(ParticipantSchema.EmailAddressForDisplay)) == null)
                {
                    propertyValue = (participant.EmailAddress ?? string.Empty);
                }
                propertyBag.SetValueWithFixup(propertyDefinition, propertyValue);
            }
            if (participantEntryId != null)
            {
                propertyBag.SetValueWithFixup(base.EntryIdPropertyDefinition, participantEntryId.ToByteArray());
                return;
            }
            propertyBag.Delete(base.EntryIdPropertyDefinition);
        }
Ejemplo n.º 6
0
 private void CalculateMapiProperties()
 {
     if (!this.isListChanged && !this.isCorrectionNeeded)
     {
         return;
     }
     if (base.Count == 0)
     {
         this.names = null;
         this.blob  = null;
     }
     else
     {
         ParticipantEntryId[] array  = new ParticipantEntryId[base.Count];
         int           num           = 0;
         StringBuilder stringBuilder = new StringBuilder(base.Count * 16);
         foreach (Participant participant in this)
         {
             if (num != 0)
             {
                 stringBuilder.Append(';');
             }
             array[num++] = ParticipantEntryId.FromParticipant(participant, ParticipantEntryIdConsumer.SupportsADParticipantEntryId);
             stringBuilder.Append(participant.DisplayName);
         }
         this.blob  = ParticipantEntryId.ToFlatEntryList(array);
         this.names = stringBuilder.ToString();
     }
     this.isListChanged       = false;
     this.isCorrectionNeeded  = false;
     this.isPropertiesChanged = true;
 }
Ejemplo n.º 7
0
 internal ADParticipantEntryId TryGetParticipantEntryId(byte[] memberEntryId)
 {
     if (memberEntryId != null)
     {
         return(ParticipantEntryId.TryFromEntryId(memberEntryId) as ADParticipantEntryId);
     }
     return(null);
 }
Ejemplo n.º 8
0
 private static ParticipantEntryId[] ParseEntryIds(byte[][] entryIds)
 {
     ParticipantEntryId[] array = new ParticipantEntryId[entryIds.Length];
     for (int i = 0; i < entryIds.Length; i++)
     {
         array[i] = ParticipantEntryId.TryFromEntryId(entryIds[i]);
     }
     return(array);
 }
Ejemplo n.º 9
0
        protected override void InternalSetValue(PropertyBag.BasicPropertyStore propertyBag, object value)
        {
            base.InternalSetValue(propertyBag, value);
            Participant        participant        = (Participant)value;
            ParticipantEntryId participantEntryId = ParticipantEntryId.FromParticipant(participant, ParticipantEntryIdConsumer.RecipientTablePrimary);

            if (participantEntryId != null)
            {
                propertyBag.SetValueWithFixup(InternalSchema.EntryId, participantEntryId.ToByteArray());
            }
            else
            {
                propertyBag.Delete(InternalSchema.EntryId);
            }
            RecipientDisplayType?      valueAsNullable  = participant.GetValueAsNullable <RecipientDisplayType>(ParticipantSchema.DisplayTypeEx);
            LegacyRecipientDisplayType?valueAsNullable2 = participant.GetValueAsNullable <LegacyRecipientDisplayType>(ParticipantSchema.DisplayType);

            if (participant.RoutingType != null)
            {
                propertyBag.Update(InternalSchema.TransmitableDisplayName, participant.DisplayName);
                if (valueAsNullable2 == null)
                {
                    valueAsNullable2 = new LegacyRecipientDisplayType?(LegacyRecipientDisplayType.MailUser);
                }
            }
            else
            {
                propertyBag.Delete(InternalSchema.TransmitableDisplayName);
            }
            AtomicStorePropertyDefinition displayTypeExInternal = InternalSchema.DisplayTypeExInternal;
            RecipientDisplayType?         recipientDisplayType  = valueAsNullable;

            propertyBag.Update(displayTypeExInternal, (recipientDisplayType != null) ? new int?((int)recipientDisplayType.GetValueOrDefault()) : null);
            AtomicStorePropertyDefinition displayType = InternalSchema.DisplayType;
            LegacyRecipientDisplayType?   legacyRecipientDisplayType = valueAsNullable2;

            propertyBag.Update(displayType, (legacyRecipientDisplayType != null) ? new int?((int)legacyRecipientDisplayType.GetValueOrDefault()) : null);
            if (valueAsNullable2 != null)
            {
                if (valueAsNullable2 == LegacyRecipientDisplayType.DistributionList || valueAsNullable2 == LegacyRecipientDisplayType.PersonalDistributionList)
                {
                    propertyBag.SetValueWithFixup(InternalSchema.ObjectType, 8);
                }
                else
                {
                    propertyBag.SetValueWithFixup(InternalSchema.ObjectType, 6);
                }
            }
            else
            {
                propertyBag.Delete(InternalSchema.ObjectType);
            }
            propertyBag.SetValueWithFixup(InternalSchema.SendRichInfo, participant.GetValueOrDefault <bool>(ParticipantSchema.SendRichInfo));
            propertyBag.Update(InternalSchema.SendInternetEncoding, participant.GetValueAsNullable <int>(ParticipantSchema.SendInternetEncoding));
        }
Ejemplo n.º 10
0
 internal static IList <ParticipantEntryId> FromFlatEntryList(byte[] bytes)
 {
     return(ParticipantEntryId.TranslateExceptions <IList <ParticipantEntryId> >(delegate
     {
         IList <ParticipantEntryId> result;
         using (ParticipantEntryId.Reader reader = new ParticipantEntryId.Reader(bytes))
         {
             result = ParticipantEntryId.FromFlatEntryList(reader);
         }
         return result;
     }));
 }
Ejemplo n.º 11
0
 internal static ParticipantEntryId FromEntryId(byte[] bytes)
 {
     return(ParticipantEntryId.TranslateExceptions <ParticipantEntryId>(delegate
     {
         ParticipantEntryId result;
         using (ParticipantEntryId.Reader reader = new ParticipantEntryId.Reader(bytes))
         {
             result = ParticipantEntryId.FromEntryId(null, reader);
         }
         return result;
     }));
 }
Ejemplo n.º 12
0
 internal void ProcessAndReturnEntryIds(out ParticipantEntryId[] mainEntryIds, out ParticipantEntryId[] oneOffEntryIds, out byte[][] extraBytes)
 {
     mainEntryIds   = new ParticipantEntryId[this.members.Count];
     oneOffEntryIds = new ParticipantEntryId[this.members.Count];
     extraBytes     = new byte[this.members.Count][];
     for (int i = 0; i < this.members.Count; i++)
     {
         mainEntryIds[i]   = this.members[i].MainEntryId;
         oneOffEntryIds[i] = this.members[i].OneOffEntryId;
         extraBytes[i]     = this.members[i].ExtraBytes;
     }
     this.PostprocessEntryIds(mainEntryIds, oneOffEntryIds);
 }
Ejemplo n.º 13
0
        public static ParticipantEntryId TryFromEntryId(byte[] bytes)
        {
            if (bytes == null)
            {
                throw new ArgumentNullException("bytes");
            }
            ParticipantEntryId result;

            using (ParticipantEntryId.Reader reader = new ParticipantEntryId.Reader(bytes))
            {
                result = ParticipantEntryId.TryFromEntryId(reader);
            }
            return(result);
        }
Ejemplo n.º 14
0
 private static ParticipantEntryId TryFromEntryId(ParticipantEntryId.Reader reader)
 {
     try
     {
         return(ParticipantEntryId.TranslateExceptions <ParticipantEntryId>(() => ParticipantEntryId.FromEntryId(null, reader)));
     }
     catch (NotSupportedException)
     {
     }
     catch (CorruptDataException)
     {
     }
     reader.BaseStream.Position = 0L;
     return(new UnrecognizedParticipantEntryId(reader.ReadBytes(reader.BytesRemaining)));
 }
 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);
     }
 }
Ejemplo n.º 16
0
 protected bool Get(PropertyBag.BasicPropertyStore propertyBag, Participant.Builder participantBuilder)
 {
     byte[] valueOrDefault = propertyBag.GetValueOrDefault <byte[]>(this.entryIdPropDef);
     if (valueOrDefault != null)
     {
         participantBuilder.SetPropertiesFrom(ParticipantEntryId.TryFromEntryId(valueOrDefault));
     }
     participantBuilder.DisplayName  = propertyBag.GetValueOrDefault <string>(this.displayNamePropDef, participantBuilder.DisplayName);
     participantBuilder.EmailAddress = propertyBag.GetValueOrDefault <string>(this.emailAddressPropDef, participantBuilder.EmailAddress);
     participantBuilder.RoutingType  = propertyBag.GetValueOrDefault <string>(this.routingTypePropDef, participantBuilder.RoutingType);
     if (this.smtpAddressPropDef != null)
     {
         string valueOrDefault2 = propertyBag.GetValueOrDefault <string>(this.smtpAddressPropDef);
         if (!string.IsNullOrEmpty(valueOrDefault2))
         {
             participantBuilder[ParticipantSchema.SmtpAddress] = valueOrDefault2;
         }
     }
     if (this.sipUriPropDef != null)
     {
         string valueOrDefault3 = propertyBag.GetValueOrDefault <string>(this.sipUriPropDef);
         if (!string.IsNullOrEmpty(valueOrDefault3))
         {
             participantBuilder[ParticipantSchema.SipUri] = valueOrDefault3;
         }
     }
     if (this.sidPropDef != null)
     {
         byte[] valueOrDefault4 = propertyBag.GetValueOrDefault <byte[]>(this.sidPropDef);
         if (valueOrDefault4 != null)
         {
             participantBuilder[ParticipantSchema.ParticipantSID] = valueOrDefault4;
         }
     }
     if (this.guidPropDef != null)
     {
         byte[] valueOrDefault5 = propertyBag.GetValueOrDefault <byte[]>(this.guidPropDef);
         if (valueOrDefault5 != null)
         {
             participantBuilder[ParticipantSchema.ParticipantGuid] = valueOrDefault5;
         }
     }
     return(!string.IsNullOrEmpty(participantBuilder.DisplayName) || !string.IsNullOrEmpty(participantBuilder.EmailAddress));
 }
Ejemplo n.º 17
0
        private static IList <ParticipantEntryId> FromFlatEntryList(ParticipantEntryId.Reader reader)
        {
            int num = reader.ReadInt32();

            reader.ReadInt32();
            IList <ParticipantEntryId> list = new List <ParticipantEntryId>();

            for (int i = 0; i < num; i++)
            {
                int num2 = reader.ReadInt32();
                list.Add(ParticipantEntryId.TryFromEntryId(reader.TearNext(num2)));
                if (reader.BytesRemaining != 0)
                {
                    reader.ReadPadding(num2, 4);
                }
            }
            reader.EnsureEnd();
            return(list);
        }
Ejemplo n.º 18
0
        public static ParticipantEntryId FromParticipant(Participant participant, ParticipantEntryIdConsumer consumer)
        {
            if (participant == null)
            {
                throw new ArgumentNullException("participant");
            }
            EnumValidator.ThrowIfInvalid <ParticipantEntryIdConsumer>(consumer);
            ParticipantEntryId participantEntryId = null;

            foreach (ParticipantEntryId.TryFromParticipantDelegate tryFromParticipantDelegate in ParticipantEntryId.tryFromParticipantChain)
            {
                participantEntryId = tryFromParticipantDelegate(participant, consumer);
                if (participantEntryId != null)
                {
                    break;
                }
            }
            return(participantEntryId);
        }
Ejemplo n.º 19
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));
        }
Ejemplo n.º 20
0
        protected override object InternalTryGetValue(PropertyBag.BasicPropertyStore propertyBag)
        {
            Participant.Builder builder = new Participant.Builder();
            byte[] valueOrDefault       = propertyBag.GetValueOrDefault <byte[]>(InternalSchema.EntryId);
            if (valueOrDefault != null)
            {
                builder.SetPropertiesFrom(ParticipantEntryId.TryFromEntryId(valueOrDefault));
            }
            builder.DisplayName = (propertyBag.GetValueOrDefault <string>(InternalSchema.TransmitableDisplayName) ?? builder.DisplayName);
            if (!base.Get(propertyBag, builder))
            {
                return(new PropertyError(this, PropertyErrorCode.NotFound));
            }
            RecipientDisplayType?valueAsNullable = propertyBag.GetValueAsNullable <RecipientDisplayType>(InternalSchema.DisplayTypeExInternal);

            if (valueAsNullable != null)
            {
                builder[ParticipantSchema.DisplayTypeEx] = valueAsNullable.Value;
                builder.Origin = (builder.Origin ?? new DirectoryParticipantOrigin());
            }
            else if (PropertyError.IsPropertyNotFound(builder.TryGetProperty(ParticipantSchema.DisplayType)))
            {
                LegacyRecipientDisplayType?valueAsNullable2 = propertyBag.GetValueAsNullable <LegacyRecipientDisplayType>(InternalSchema.DisplayType);
                ObjectType?valueAsNullable3 = propertyBag.GetValueAsNullable <ObjectType>(InternalSchema.ObjectType);
                if (valueAsNullable2 != null)
                {
                    if (valueAsNullable2 != LegacyRecipientDisplayType.MailUser)
                    {
                        builder[ParticipantSchema.DisplayType] = (int)valueAsNullable2.Value;
                    }
                }
                else if (valueAsNullable3 != null && valueAsNullable3 == ObjectType.MAPI_DISTLIST)
                {
                    builder[ParticipantSchema.DisplayType] = 1;
                }
            }
            builder.SetOrDeleteProperty(ParticipantSchema.SendRichInfo, Util.NullIf <object>(propertyBag.GetValueAsNullable <bool>(InternalSchema.SendRichInfo), false));
            builder.SetOrDeleteProperty(ParticipantSchema.SendInternetEncoding, propertyBag.GetValueAsNullable <int>(InternalSchema.SendInternetEncoding));
            return(builder.ToParticipant());
        }
Ejemplo n.º 21
0
 private void AddPermissionEntriesForAddOrModify(MapiAclTableAdapter mapiAclTableAdapter)
 {
     foreach (Permission permission in this.permissions.Values)
     {
         byte[] array = null;
         if (permission.Origin == PermissionOrigin.New)
         {
             if (permission.Principal.Type == PermissionSecurityPrincipal.SecurityPrincipalType.ADRecipientPrincipal)
             {
                 ParticipantEntryId participantEntryId = ParticipantEntryId.FromParticipant(new Participant(permission.Principal.ADRecipient), ParticipantEntryIdConsumer.SupportsADParticipantEntryId);
                 array = participantEntryId.ToByteArray();
             }
             else if (permission.Principal.Type == PermissionSecurityPrincipal.SecurityPrincipalType.ExternalUserPrincipal)
             {
                 ExternalUser externalUser = permission.Principal.ExternalUser;
                 byte[]       array2       = new byte[externalUser.Sid.BinaryLength];
                 externalUser.Sid.GetBinaryForm(array2, 0);
                 array = MapiStore.GetAddressBookEntryIdFromLocalDirectorySID(array2);
             }
             if (array != null)
             {
                 mapiAclTableAdapter.AddPermissionEntry(array, permission.MemberRights);
             }
         }
         else if (permission.IsDirty)
         {
             mapiAclTableAdapter.ModifyPermissionEntry(permission.MemberId, permission.MemberRights);
         }
     }
     if (this.anonymousMemberPermission != null && this.anonymousMemberPermission.IsDirty)
     {
         mapiAclTableAdapter.ModifyPermissionEntry(this.anonymousMemberPermission.MemberId, this.anonymousMemberPermission.MemberRights);
     }
     if (this.defaultMemberPermission != null && this.defaultMemberPermission.IsDirty)
     {
         mapiAclTableAdapter.ModifyPermissionEntry(this.defaultMemberPermission.MemberId, this.defaultMemberPermission.MemberRights);
     }
 }
        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
            });
        }
Ejemplo n.º 23
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;
        }
Ejemplo n.º 24
0
        private static ParticipantEntryId FromEntryId(ParticipantEntryId.WabEntryFlag?wrapperFlags, ParticipantEntryId.Reader reader)
        {
            Guid a = reader.ReadEntryHeader();

            if (a == ParticipantEntryId.OneOffProviderGuid)
            {
                using (ParticipantEntryId.Reader reader2 = reader.TearRest())
                {
                    return(new OneOffParticipantEntryId(reader2));
                }
            }
            if (a == ParticipantEntryId.WabProviderGuid)
            {
                ParticipantEntryId.WabEntryFlag wabEntryFlag = (ParticipantEntryId.WabEntryFlag)reader.ReadByte();
                switch ((byte)(wabEntryFlag & ParticipantEntryId.WabEntryFlag.ObjectTypeMask))
                {
                case 0:
                case 5:
                case 6:
                    break;

                case 1:
                case 2:
                    goto IL_D0;

                case 3:
                case 4:
                    using (ParticipantEntryId.Reader reader3 = reader.TearRest())
                    {
                        return(new StoreParticipantEntryId(wabEntryFlag, reader3));
                    }
                    break;

                default:
                    goto IL_D0;
                }
                if (wrapperFlags != null)
                {
                    throw new CorruptDataException(ServerStrings.ExInvalidParticipantEntryId);
                }
                using (ParticipantEntryId.Reader reader4 = reader.TearRest())
                {
                    return(ParticipantEntryId.FromEntryId(new ParticipantEntryId.WabEntryFlag?(wabEntryFlag), reader4));
                }
IL_D0:
                throw new NotSupportedException(ServerStrings.ExInvalidWABObjectType(wabEntryFlag & ParticipantEntryId.WabEntryFlag.ObjectTypeMask));
            }
            if (a == ParticipantEntryId.ExchangeProviderGuid)
            {
                using (ParticipantEntryId.Reader reader5 = reader.TearRest())
                {
                    return(new ADParticipantEntryId(wrapperFlags, reader5));
                }
            }
            if (a == ParticipantEntryId.OlabProviderGuid)
            {
                using (ParticipantEntryId.Reader reader6 = reader.TearRest())
                {
                    return(new StoreParticipantEntryId(reader6));
                }
            }
            throw new NotSupportedException(ServerStrings.ExUnsupportedABProvider(a.ToString(), string.Empty));
        }