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;
 }
        protected override object InternalTryGetValue(PropertyBag.BasicPropertyStore propertyBag)
        {
            Participant.Builder builder = new Participant.Builder();
            bool flag = base.Get(propertyBag, builder);

            if (this.emailAddressForDisplayPropDef != null)
            {
                string valueOrDefault = propertyBag.GetValueOrDefault <string>(this.emailAddressForDisplayPropDef);
                if (!string.IsNullOrEmpty(valueOrDefault))
                {
                    builder[ParticipantSchema.EmailAddressForDisplay] = valueOrDefault;
                    if (Participant.RoutingTypeEquals(builder.RoutingType, "EX") && PropertyError.IsPropertyNotFound(builder.TryGetProperty(ParticipantSchema.SmtpAddress)) && SmtpAddress.IsValidSmtpAddress(valueOrDefault))
                    {
                        builder[ParticipantSchema.SmtpAddress] = valueOrDefault;
                    }
                }
            }
            if (!flag && PropertyError.IsPropertyNotFound(builder.TryGetProperty(ParticipantSchema.EmailAddressForDisplay)))
            {
                return(new PropertyError(this, PropertyErrorCode.NotFound));
            }
            byte[] valueOrDefault2 = propertyBag.GetValueOrDefault <byte[]>(InternalSchema.EntryId);
            if (valueOrDefault2 != null)
            {
                builder.Origin = new StoreParticipantOrigin(StoreObjectId.FromProviderSpecificId(valueOrDefault2), this.emailAddressIndex);
            }
            return(builder.ToParticipant());
        }
Example #3
0
        private static ProxyAddress GetLegacyProxyAddress(IRuleEvaluationContext context, byte[] entryId)
        {
            if (entryId.Length == 0)
            {
                context.TraceDebug("GetLegacyProxyAddress: entry ID is zero-length");
                return(null);
            }
            ParticipantEntryId participantEntryId = ParticipantEntryId.TryFromEntryId(entryId);

            context.TraceDebug <string>("GetLegacyProxyAddress: entry ID is {0}", participantEntryId.GetType().Name);
            Participant.Builder builder = new Participant.Builder();
            builder.SetPropertiesFrom(participantEntryId);
            Participant participant  = builder.ToParticipant();
            string      routingType  = participant.RoutingType;
            string      emailAddress = participant.EmailAddress;

            if (routingType != "EX" || string.IsNullOrEmpty(emailAddress))
            {
                context.TraceDebug <string, string>("GetLegacyProxyAddress: returning null, address is {0}:{1}", routingType ?? "(null)", emailAddress ?? "(null)");
                return(null);
            }
            ProxyAddress proxyAddress = ProxyAddress.Parse(routingType, emailAddress);

            if (proxyAddress is InvalidProxyAddress)
            {
                context.TraceDebug <string>("GetLegacyProxyAddress: legacyDN {0} is not valid", emailAddress);
                return(null);
            }
            context.TraceDebug <string>("GetLegacyProxyAddress: returning EX:{0}", emailAddress);
            return(proxyAddress);
        }
Example #4
0
 protected override object InternalTryGetValue(PropertyBag.BasicPropertyStore propertyBag)
 {
     Participant.Builder builder = new Participant.Builder();
     if (!this.Get(propertyBag, builder))
     {
         return(new PropertyError(this, PropertyErrorCode.NotFound));
     }
     return(builder.ToParticipant());
 }
Example #5
0
        internal static Participant GetParticipant(byte[] entryId)
        {
            ParticipantEntryId participantEntryId = ParticipantEntryId.TryFromEntryId(entryId);

            if (participantEntryId is UnrecognizedParticipantEntryId)
            {
                return(null);
            }
            Participant.Builder builder = new Participant.Builder();
            builder.SetPropertiesFrom(participantEntryId);
            return(builder.ToParticipant());
        }
Example #6
0
 protected override object InternalTryGetValue(PropertyBag.BasicPropertyStore propertyBag)
 {
     Participant.Builder builder = new Participant.Builder();
     if (base.Get(propertyBag, builder))
     {
         bool?valueAsNullable = propertyBag.GetValueAsNullable <bool>(InternalSchema.SendRichInfo);
         if (valueAsNullable != null)
         {
             builder[ParticipantSchema.SendRichInfo] = valueAsNullable.Value;
         }
         return(builder.ToParticipant());
     }
     return(new PropertyError(this, PropertyErrorCode.NotFound));
 }
Example #7
0
        private static string LegDNFromParticipantEntryId(byte[] entryId)
        {
            if (entryId == null || entryId.Length == 0)
            {
                return(null);
            }
            ADParticipantEntryId adparticipantEntryId = ParticipantEntryId.TryFromEntryId(entryId) as ADParticipantEntryId;

            if (adparticipantEntryId != null)
            {
                Participant.Builder builder = new Participant.Builder();
                builder.SetPropertiesFrom(adparticipantEntryId);
                return(builder.ToParticipant().EmailAddress);
            }
            return(null);
        }
        private void SendEscalateMessageToYammer(IMessageItem escalatedMessage, string yammerEscalateAddress, IMailboxSession mailboxSession)
        {
            foreach (Recipient recipient in escalatedMessage.Recipients)
            {
                recipient.Submitted = true;
                recipient[ItemSchema.Responsibility] = false;
            }
            this.SetUniqueBody(escalatedMessage, mailboxSession);
            Participant.Builder builder = new Participant.Builder
            {
                EmailAddress = yammerEscalateAddress,
                RoutingType  = "SMTP"
            };
            Recipient recipient2 = escalatedMessage.Recipients.Add(builder.ToParticipant(), RecipientItemType.Bcc);

            recipient2[ItemSchema.Responsibility] = true;
            this.SendEscalateMessage(escalatedMessage);
        }
Example #9
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());
        }
        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 #11
0
        private static byte[] ParticipanEntryIdFromLegDN(byte[] originalEntryId, string newLegDN)
        {
            if (originalEntryId == null || originalEntryId.Length == 0)
            {
                return(null);
            }
            ADParticipantEntryId adparticipantEntryId = ParticipantEntryId.TryFromEntryId(originalEntryId) as ADParticipantEntryId;

            if (adparticipantEntryId == null)
            {
                return(null);
            }
            Participant.Builder builder = new Participant.Builder();
            builder.SetPropertiesFrom(adparticipantEntryId);
            builder.EmailAddress = newLegDN;
            ParticipantEntryId participantEntryId = ParticipantEntryId.FromParticipant(builder.ToParticipant(), ParticipantEntryIdConsumer.RecipientTableSecondary);

            if (participantEntryId == null)
            {
                return(null);
            }
            return(participantEntryId.ToByteArray());
        }