// Token: 0x060000C2 RID: 194 RVA: 0x000071B8 File Offset: 0x000053B8
        private static string GetSmtpAddressAndADObjectInfo(Participant recipient, AdRecipientBatchQuery adRecipientBatchQuery, out ADObjectId adObjectId, out int recipientAddressFlags, out int readItemType)
        {
            string result = string.Empty;

            recipientAddressFlags = 0;
            readItemType          = 1;
            adObjectId            = null;
            if (recipient.Origin is DirectoryParticipantOrigin)
            {
                ADRecipient adRecipient = adRecipientBatchQuery.GetAdRecipient(recipient.EmailAddress);
                if (adRecipient != null)
                {
                    adObjectId = adRecipient.Id;
                    result     = adRecipient.PrimarySmtpAddress.ToString();
                    if (adRecipient is IADDistributionList)
                    {
                        recipientAddressFlags |= 1;
                        readItemType           = 2;
                    }
                    else
                    {
                        readItemType = 1;
                    }
                    if (DirectoryAssistance.IsADRecipientRoom(adRecipient))
                    {
                        recipientAddressFlags |= 2;
                    }
                }
            }
            else if (recipient.Origin is StoreParticipantOrigin)
            {
                if (Utilities.IsMapiPDL(recipient.RoutingType))
                {
                    result = recipient.EmailAddress;
                    recipientAddressFlags |= 1;
                    readItemType           = 4;
                }
                else
                {
                    result       = recipient.EmailAddress;
                    readItemType = 3;
                }
            }
            else
            {
                result = recipient.EmailAddress;
            }
            return(result);
        }
        // Token: 0x0600313E RID: 12606 RVA: 0x00122B70 File Offset: 0x00120D70
        private static List <string> GetContactNamesFromLegacyDN(List <string> legacyDNs, UserContext userContext)
        {
            if (legacyDNs == null)
            {
                throw new ArgumentNullException("legacyDNs");
            }
            if (userContext == null)
            {
                throw new ArgumentNullException("userContext");
            }
            List <string>         list = new List <string>(legacyDNs.Count);
            AdRecipientBatchQuery adRecipientBatchQuery = new AdRecipientBatchQuery(userContext, legacyDNs.ToArray());

            for (int i = 0; i < legacyDNs.Count; i++)
            {
                ADRecipient adRecipient = adRecipientBatchQuery.GetAdRecipient(legacyDNs[i]);
                list.Add((adRecipient != null && !string.IsNullOrEmpty(adRecipient.DisplayName)) ? adRecipient.DisplayName : LocalizedStrings.GetNonEncoded(-1626952556));
            }
            return(list);
        }
        // Token: 0x0600313D RID: 12605 RVA: 0x00122B08 File Offset: 0x00120D08
        private static string GetContactNameFromLegacyDN(string legacyDN, UserContext userContext)
        {
            if (legacyDN == null)
            {
                throw new ArgumentNullException("legacyDN");
            }
            if (userContext == null)
            {
                throw new ArgumentNullException("userContext");
            }
            AdRecipientBatchQuery adRecipientBatchQuery = new AdRecipientBatchQuery(userContext, new string[]
            {
                legacyDN
            });
            ADRecipient adRecipient = adRecipientBatchQuery.GetAdRecipient(legacyDN);

            if (adRecipient == null || string.IsNullOrEmpty(adRecipient.DisplayName))
            {
                return(LocalizedStrings.GetNonEncoded(-1626952556));
            }
            return(adRecipient.DisplayName);
        }
        // Token: 0x060000BF RID: 191 RVA: 0x00006CF0 File Offset: 0x00004EF0
        protected override void RenderContents(TextWriter writer, RecipientWellType type, RecipientWellNode.RenderFlags flags)
        {
            if (!this.HasRecipients(type))
            {
                return;
            }
            AdRecipientBatchQuery     adRecipientBatchQuery = new AdRecipientBatchQuery(this.GetRecipientCollection(type), this.UserContext);
            IEnumerator <Participant> recipientCollection   = this.GetRecipientCollection(type);

            RecipientWellNode.RenderFlags renderFlags = flags & ~RecipientWellNode.RenderFlags.RenderCommas;
            bool flag = true;
            RecipientItemType recipientItemType = ItemRecipientWell.GetRecipientItemType(type);
            bool isWebPartRequest = OwaContext.Current.UserContext.IsWebPartRequest;
            int  num = 0;

            while (recipientCollection.MoveNext())
            {
                Participant            participant                = recipientCollection.Current;
                int                    recipientFlags             = 0;
                ADObjectId             adObjectId                 = null;
                int                    readItemType               = 1;
                string                 smtpAddressAndADObjectInfo = ItemRecipientWell.GetSmtpAddressAndADObjectInfo(participant, adRecipientBatchQuery, out adObjectId, out recipientFlags, out readItemType);
                StoreObjectId          storeObjectId              = null;
                StoreParticipantOrigin storeParticipantOrigin     = participant.Origin as StoreParticipantOrigin;
                if (storeParticipantOrigin != null)
                {
                    storeObjectId = storeParticipantOrigin.OriginItemId;
                }
                string idString = ItemRecipientWell.BuildRecipientIdString(recipientItemType, num++);
                if (RecipientWellNode.Render(this.UserContext, writer, participant.DisplayName, smtpAddressAndADObjectInfo, participant.EmailAddress, participant.RoutingType, RecipientAddress.ToAddressOrigin(participant), recipientFlags, readItemType, recipientItemType, adObjectId, storeObjectId, renderFlags, idString, isWebPartRequest) && flag)
                {
                    flag = false;
                    if ((flags & RecipientWellNode.RenderFlags.RenderCommas) != RecipientWellNode.RenderFlags.None)
                    {
                        renderFlags |= RecipientWellNode.RenderFlags.RenderCommas;
                    }
                }
            }
        }
        public void ExpandDistributionList()
        {
            ExTraceGlobals.MailCallTracer.TraceDebug((long)this.GetHashCode(), "RecipientWellEventHandler.ExpandDistributionList");
            RecipientInfo[]    array = (RecipientInfo[])base.GetParameter("Recips");
            List <Participant> list  = new List <Participant>();

            foreach (RecipientInfo recipientInfo in array)
            {
                if (recipientInfo.StoreObjectId == null || !Utilities.IsMapiPDL(recipientInfo.RoutingType))
                {
                    throw new OwaEventHandlerException("The requested recipient is not personal distribution list");
                }
                list.AddRange(DistributionList.ExpandDeep(base.UserContext.MailboxSession, recipientInfo.StoreObjectId));
            }
            using (List <Participant> .Enumerator enumerator = list.GetEnumerator())
            {
                AdRecipientBatchQuery adRecipientBatchQuery = new AdRecipientBatchQuery(enumerator, base.UserContext);
                bool flag = false;
                foreach (Participant participant in list)
                {
                    string            smtpAddress       = null;
                    string            sipUri            = null;
                    ADObjectId        adObjectId        = null;
                    StoreObjectId     storeObjectId     = null;
                    EmailAddressIndex emailAddressIndex = EmailAddressIndex.None;
                    string            mobilePhoneNumber = null;
                    if (participant.RoutingType == "EX")
                    {
                        ADRecipient adRecipient = adRecipientBatchQuery.GetAdRecipient(participant.EmailAddress);
                        if (adRecipient != null)
                        {
                            smtpAddress       = adRecipient.PrimarySmtpAddress.ToString();
                            adObjectId        = adRecipient.Id;
                            sipUri            = InstantMessageUtilities.GetSipUri((ProxyAddressCollection)adRecipient[ADRecipientSchema.EmailAddresses]);
                            mobilePhoneNumber = Utilities.NormalizePhoneNumber((string)adRecipient[ADOrgPersonSchema.MobilePhone]);
                        }
                    }
                    else
                    {
                        smtpAddress = participant.EmailAddress;
                        sipUri      = participant.EmailAddress;
                    }
                    RecipientAddress.RecipientAddressFlags recipientAddressFlags = RecipientAddress.RecipientAddressFlags.None;
                    if (participant.GetValueOrDefault <bool>(ParticipantSchema.IsDistributionList))
                    {
                        recipientAddressFlags |= RecipientAddress.RecipientAddressFlags.DistributionList;
                    }
                    else if (participant.GetValueOrDefault <bool>(ParticipantSchema.IsRoom))
                    {
                        recipientAddressFlags |= RecipientAddress.RecipientAddressFlags.Room;
                    }
                    StoreParticipantOrigin storeParticipantOrigin = participant.Origin as StoreParticipantOrigin;
                    if (storeParticipantOrigin != null)
                    {
                        storeObjectId     = storeParticipantOrigin.OriginItemId;
                        emailAddressIndex = storeParticipantOrigin.EmailAddressIndex;
                    }
                    RecipientWellNode.Render(this.Writer, base.UserContext, participant.DisplayName, smtpAddress, participant.EmailAddress, participant.RoutingType, participant.GetValueOrDefault <string>(ParticipantSchema.Alias), RecipientAddress.ToAddressOrigin(participant), (int)recipientAddressFlags, storeObjectId, emailAddressIndex, adObjectId, flag ? RecipientWellNode.RenderFlags.RenderCommas : RecipientWellNode.RenderFlags.None, sipUri, mobilePhoneNumber);
                    flag = true;
                }
            }
        }
        internal override void RenderContents(TextWriter writer, UserContext userContext, RecipientWellType type, RecipientWellNode.RenderFlags flags, RenderRecipientWellNode wellNode)
        {
            if (writer == null)
            {
                throw new ArgumentNullException("writer");
            }
            if (userContext == null)
            {
                throw new ArgumentNullException("userContext");
            }
            if (!this.HasRecipients(type))
            {
                return;
            }
            IEnumerator <Participant> recipientsCollection = this.GetRecipientsCollection(type);

            RecipientWellNode.RenderFlags renderFlags = flags & ~RecipientWellNode.RenderFlags.RenderCommas;
            bool flag  = true;
            bool flag2 = userContext.IsInstantMessageEnabled();

            Result <ADRawEntry>[] array = null;
            int num = 0;

            while (recipientsCollection.MoveNext())
            {
                Participant participant       = recipientsCollection.Current;
                string      smtpAddress       = null;
                string      alias             = null;
                string      text              = null;
                int         num2              = 0;
                ADObjectId  adObjectId        = null;
                string      mobilePhoneNumber = null;
                if (participant.RoutingType == "EX" && !string.IsNullOrEmpty(participant.EmailAddress))
                {
                    bool flag3 = (flags & RecipientWellNode.RenderFlags.ReadOnly) != RecipientWellNode.RenderFlags.None;
                    if (flag3)
                    {
                        alias = Utilities.GetParticipantProperty <string>(participant, ParticipantSchema.Alias, null);
                    }
                    bool participantProperty = Utilities.GetParticipantProperty <bool>(participant, ParticipantSchema.IsDistributionList, false);
                    if (participantProperty)
                    {
                        num2 |= 1;
                    }
                    bool participantProperty2 = Utilities.GetParticipantProperty <bool>(participant, ParticipantSchema.IsRoom, false);
                    if (participantProperty2)
                    {
                        num2 |= 2;
                    }
                    smtpAddress = Utilities.GetParticipantProperty <string>(participant, ParticipantSchema.SmtpAddress, null);
                    if (flag2 && !participantProperty && !participantProperty2)
                    {
                        text = Utilities.GetParticipantProperty <string>(participant, ParticipantSchema.SipUri, null);
                        if (text == null || text.Trim().Length == 0)
                        {
                            if (array == null)
                            {
                                array = AdRecipientBatchQuery.FindAdResultsByLegacyExchangeDNs(this.GetRecipientsCollection(type), userContext);
                            }
                            ADRawEntry data = array[num].Data;
                            if (data != null)
                            {
                                adObjectId = (ADObjectId)data[ADObjectSchema.Id];
                                text       = InstantMessageUtilities.GetSipUri((ProxyAddressCollection)data[ADRecipientSchema.EmailAddresses]);
                                if (text != null && text.Trim().Length == 0)
                                {
                                    text = null;
                                }
                            }
                        }
                    }
                    if (userContext.IsSmsEnabled)
                    {
                        if (array == null)
                        {
                            array = AdRecipientBatchQuery.FindAdResultsByLegacyExchangeDNs(this.GetRecipientsCollection(type), userContext);
                        }
                        ADRawEntry data2 = array[num].Data;
                        if (data2 != null)
                        {
                            mobilePhoneNumber = (string)data2[ADOrgPersonSchema.MobilePhone];
                        }
                    }
                    num++;
                }
                else if (participant.RoutingType == "SMTP")
                {
                    smtpAddress = participant.EmailAddress;
                    if (flag2)
                    {
                        text = participant.EmailAddress;
                    }
                }
                else if (string.CompareOrdinal(participant.RoutingType, "MAPIPDL") == 0)
                {
                    num2 |= 1;
                }
                StoreObjectId          storeObjectId          = null;
                EmailAddressIndex      emailAddressIndex      = EmailAddressIndex.None;
                StoreParticipantOrigin storeParticipantOrigin = participant.Origin as StoreParticipantOrigin;
                if (storeParticipantOrigin != null && storeParticipantOrigin.OriginItemId != null)
                {
                    storeObjectId     = storeParticipantOrigin.OriginItemId;
                    emailAddressIndex = storeParticipantOrigin.EmailAddressIndex;
                }
                if (wellNode(writer, userContext, participant.DisplayName, smtpAddress, participant.EmailAddress, participant.RoutingType, alias, RecipientAddress.ToAddressOrigin(participant), num2, storeObjectId, emailAddressIndex, adObjectId, renderFlags, text, mobilePhoneNumber) && flag)
                {
                    flag = false;
                    if ((flags & RecipientWellNode.RenderFlags.RenderCommas) != RecipientWellNode.RenderFlags.None)
                    {
                        renderFlags |= RecipientWellNode.RenderFlags.RenderCommas;
                    }
                }
            }
        }
 internal DistributionListDataSource(UserContext userContext, Hashtable properties, List <Participant> participants, ColumnId sortedColumn, SortOrder order) : base(properties)
 {
     using (List <Participant> .Enumerator enumerator = participants.GetEnumerator())
     {
         AdRecipientBatchQuery    adRecipientBatchQuery = new AdRecipientBatchQuery(enumerator, userContext);
         PropertyDefinition[]     requestedProperties   = base.GetRequestedProperties();
         object[][]               array      = new object[participants.Count][];
         Dictionary <string, int> dictionary = new Dictionary <string, int>();
         for (int i = 0; i < participants.Count; i++)
         {
             array[i] = new object[requestedProperties.Length];
             array[i][base.PropertyIndex(StoreObjectSchema.DisplayName)]  = participants[i].DisplayName;
             array[i][base.PropertyIndex(ParticipantSchema.EmailAddress)] = participants[i].EmailAddress;
             array[i][base.PropertyIndex(ParticipantSchema.RoutingType)]  = participants[i].RoutingType;
             string text2;
             if (participants[i].Origin is StoreParticipantOrigin)
             {
                 string text = ((StoreParticipantOrigin)participants[i].Origin).OriginItemId.ToBase64String();
                 if (Utilities.IsMapiPDL(participants[i].RoutingType))
                 {
                     array[i][base.PropertyIndex(StoreObjectSchema.ItemClass)]   = "IPM.DistList";
                     array[i][base.PropertyIndex(RecipientSchema.EmailAddrType)] = 0;
                     text2 = text;
                 }
                 else
                 {
                     int emailAddressIndex = (int)((StoreParticipantOrigin)participants[i].Origin).EmailAddressIndex;
                     array[i][base.PropertyIndex(StoreObjectSchema.ItemClass)]   = "IPM.Contact";
                     array[i][base.PropertyIndex(RecipientSchema.EmailAddrType)] = emailAddressIndex;
                     text2 = text + emailAddressIndex;
                 }
                 array[i][base.PropertyIndex(ItemSchema.RecipientType)]       = AddressOrigin.Store;
                 array[i][base.PropertyIndex(ContactSchema.Email1)]           = participants[i];
                 array[i][base.PropertyIndex(ParticipantSchema.OriginItemId)] = text;
             }
             else if (participants[i].Origin is DirectoryParticipantOrigin)
             {
                 ADRecipient adRecipient = adRecipientBatchQuery.GetAdRecipient(participants[i].EmailAddress);
                 if (adRecipient != null)
                 {
                     if (Utilities.IsADDistributionList(adRecipient.RecipientType))
                     {
                         array[i][base.PropertyIndex(StoreObjectSchema.ItemClass)] = "AD.RecipientType.Group";
                     }
                     else
                     {
                         array[i][base.PropertyIndex(StoreObjectSchema.ItemClass)] = "AD.RecipientType.User";
                     }
                     array[i][base.PropertyIndex(ContactSchema.Email1)] = new Participant(participants[i].DisplayName, adRecipient.PrimarySmtpAddress.ToString(), "SMTP");
                     text2 = Utilities.GetBase64StringFromADObjectId(adRecipient.Id);
                 }
                 else
                 {
                     text2 = "[ADUser]" + participants[i].DisplayName + participants[i].EmailAddress;
                     array[i][base.PropertyIndex(StoreObjectSchema.ItemClass)] = "AD.RecipientType.User";
                     array[i][base.PropertyIndex(ContactSchema.Email1)]        = participants[i];
                     string participantProperty = Utilities.GetParticipantProperty <string>(participants[i], ParticipantSchema.SmtpAddress, null);
                     if (participantProperty != null)
                     {
                         array[i][base.PropertyIndex(ParticipantSchema.RoutingType)]  = "SMTP";
                         array[i][base.PropertyIndex(ParticipantSchema.EmailAddress)] = participantProperty;
                     }
                 }
                 array[i][base.PropertyIndex(ItemSchema.RecipientType)] = AddressOrigin.Directory;
             }
             else
             {
                 if (!(participants[i].Origin is OneOffParticipantOrigin))
                 {
                     throw new ArgumentException("Invalid participant origin type.");
                 }
                 text2 = participants[i].RoutingType + ":" + participants[i].EmailAddress;
                 array[i][base.PropertyIndex(StoreObjectSchema.ItemClass)] = "OneOff";
                 array[i][base.PropertyIndex(ItemSchema.RecipientType)]    = AddressOrigin.OneOff;
                 array[i][base.PropertyIndex(ContactSchema.Email1)]        = participants[i];
             }
             if (dictionary.ContainsKey(text2))
             {
                 text2 += i;
             }
             dictionary[text2] = 1;
             array[i][base.PropertyIndex(ItemSchema.Id)] = text2;
         }
         Array.Sort <object[]>(array, new DistributionListDataSource.DistributionListMemberComparer(userContext.UserCulture, sortedColumn, order, this));
         base.Items      = array;
         base.StartRange = 0;
         base.EndRange   = array.Length - 1;
     }
 }
        // Token: 0x060000C0 RID: 192 RVA: 0x00006DF0 File Offset: 0x00004FF0
        protected override bool RenderAnrContents(TextWriter writer, UserContext userContext, RecipientWellType type, bool isTableStartRendered)
        {
            bool flag  = isTableStartRendered;
            bool flag2 = false;

            if (this.HasRecipients(type))
            {
                AdRecipientBatchQuery     adRecipientBatchQuery = new AdRecipientBatchQuery(this.GetRecipientCollection(type), this.UserContext);
                IEnumerator <Participant> recipientCollection   = this.GetRecipientCollection(type);
                string empty = string.Empty;
                int    num   = 0;
                List <RecipientAddress> list = new List <RecipientAddress>();
                RecipientItemType       recipientItemType = ItemRecipientWell.GetRecipientItemType(type);
                int num2 = 0;
                while (recipientCollection.MoveNext())
                {
                    Participant participant = recipientCollection.Current;
                    string      text        = ItemRecipientWell.BuildRecipientIdString(recipientItemType, num2++);
                    if (string.CompareOrdinal(participant.RoutingType, "MAPIPDL") != 0 && (string.IsNullOrEmpty(participant.EmailAddress) || string.IsNullOrEmpty(participant.RoutingType)) && !string.IsNullOrEmpty(participant.DisplayName))
                    {
                        num = 0;
                        ADObjectId adobjectId = null;
                        int        num3;
                        ItemRecipientWell.GetSmtpAddressAndADObjectInfo(participant, adRecipientBatchQuery, out adobjectId, out num, out num3);
                        StoreParticipantOrigin storeParticipantOrigin = participant.Origin as StoreParticipantOrigin;
                        if (storeParticipantOrigin != null)
                        {
                            StoreObjectId originItemId = storeParticipantOrigin.OriginItemId;
                        }
                        if (!flag)
                        {
                            writer.Write("<table cellspacing=0 cellpadding=0 class=\"anrot\" id=\"tblANR\"><tr><td class=\"msg\"><h1 tabindex=0>");
                            writer.Write(LocalizedStrings.GetHtmlEncoded(147143837));
                            writer.Write("</h1></td></tr><tr><td class=\"h100\"><table cellspacing=0 cellpadding=0 class=\"anrit\">");
                            flag = true;
                        }
                        if (!flag2)
                        {
                            string value = null;
                            if (this is CalendarItemRecipientWell)
                            {
                                switch (type)
                                {
                                case RecipientWellType.To:
                                    value = LocalizedStrings.GetHtmlEncoded(609567352);
                                    break;

                                case RecipientWellType.Cc:
                                    value = LocalizedStrings.GetHtmlEncoded(633037671);
                                    break;

                                case RecipientWellType.Bcc:
                                    value = LocalizedStrings.GetHtmlEncoded(-1107183092);
                                    break;
                                }
                            }
                            else
                            {
                                switch (type)
                                {
                                case RecipientWellType.To:
                                    value = LocalizedStrings.GetHtmlEncoded(-1105875540);
                                    break;

                                case RecipientWellType.Cc:
                                    value = LocalizedStrings.GetHtmlEncoded(701860997);
                                    break;

                                case RecipientWellType.Bcc:
                                    value = LocalizedStrings.GetHtmlEncoded(1482538735);
                                    break;
                                }
                            }
                            writer.Write("<tr><td class=\"hdr\" tabindex=0>");
                            writer.Write(value);
                            writer.Write("</td></tr>");
                            flag2 = true;
                        }
                        writer.Write("<tr><td class=\"rcpt\" nowrap><span tabindex=0>");
                        Utilities.CropAndRenderText(writer, participant.DisplayName, 24);
                        writer.Write("</span> [<a href=\"#\" title=\"");
                        writer.Write(Utilities.HtmlEncode(participant.DisplayName));
                        writer.Write("\" onClick=\"return onClkRmRcp('{0}')\">{1}</a>]", text, LocalizedStrings.GetHtmlEncoded(341226654));
                        writer.Write("</td></tr>");
                        list.Clear();
                        AnrManager.ResolveOneRecipient(participant.DisplayName, userContext, list);
                        if (list.Count == 0)
                        {
                            RecipientAddress recipientAddress = AnrManager.ResolveAnrStringToOneOffEmail(participant.DisplayName);
                            if (recipientAddress != null)
                            {
                                list.Add(recipientAddress);
                            }
                        }
                        int num4 = 0;
                        while (num4 < list.Count && num4 < 100)
                        {
                            RecipientAddress recipientAddress2 = list[num4];
                            if (recipientAddress2.DisplayName != null)
                            {
                                writer.Write("<tr><td><a href=\"#\" title=\"");
                                Utilities.HtmlEncode(recipientAddress2.DisplayName, writer);
                                if (recipientAddress2.SmtpAddress != null)
                                {
                                    writer.Write(" [");
                                    Utilities.HtmlEncode(recipientAddress2.SmtpAddress, writer);
                                    writer.Write("]");
                                }
                                writer.Write("\" onClick=\"return onClkAddAnr(this,'");
                                ResolvedRecipientDetail resolvedRecipientDetail = new ResolvedRecipientDetail(recipientAddress2);
                                resolvedRecipientDetail.RenderConcatenatedDetails(true, writer);
                                writer.Write("',");
                                writer.Write((int)recipientItemType);
                                writer.Write(",'");
                                writer.Write(text);
                                writer.Write("')\">");
                                Utilities.CropAndRenderText(writer, recipientAddress2.DisplayName, 24);
                                if (string.IsNullOrEmpty(recipientAddress2.DisplayName) && !string.IsNullOrEmpty(recipientAddress2.SmtpAddress))
                                {
                                    writer.Write("(");
                                    Utilities.CropAndRenderText(writer, recipientAddress2.SmtpAddress, 24);
                                    writer.Write(")");
                                }
                                writer.Write("</a></td></tr>");
                            }
                            num4++;
                        }
                    }
                }
            }
            return(flag);
        }