// Token: 0x0600256D RID: 9581 RVA: 0x000D89FC File Offset: 0x000D6BFC
        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;
            }
            RecipientWellNode.RenderFlags renderFlags = flags & ~RecipientWellNode.RenderFlags.RenderCommas;
            bool   flag        = true;
            string smtpAddress = null;
            string alias       = null;
            int    num         = 0;
            MultiValuedProperty <string> addressList      = this.GetAddressList(type);
            IRecipientSession            recipientSession = Utilities.CreateADRecipientSession(ConsistencyMode.IgnoreInvalid, userContext);

            foreach (string text in addressList)
            {
                ADObjectId  adObjectId  = null;
                ADRecipient adrecipient = recipientSession.FindByLegacyExchangeDN(text);
                bool        flag2       = (flags & RecipientWellNode.RenderFlags.ReadOnly) != RecipientWellNode.RenderFlags.None;
                if (adrecipient != null)
                {
                    adObjectId  = adrecipient.Id;
                    smtpAddress = adrecipient.PrimarySmtpAddress.ToString();
                    if (flag2)
                    {
                        alias = adrecipient.Alias;
                    }
                    if (adrecipient is IADDistributionList)
                    {
                        num |= 1;
                    }
                    if (DirectoryAssistance.IsADRecipientRoom(adrecipient))
                    {
                        num |= 2;
                    }
                }
                if (wellNode(writer, userContext, (adrecipient != null) ? adrecipient.DisplayName : text.ToString(), smtpAddress, (adrecipient != null) ? adrecipient.LegacyExchangeDN : text.ToString(), "EX", alias, (adrecipient != null) ? AddressOrigin.Directory : AddressOrigin.Unknown, num, null, EmailAddressIndex.None, adObjectId, renderFlags, null, null) && flag)
                {
                    flag = false;
                    if ((flags & RecipientWellNode.RenderFlags.RenderCommas) != RecipientWellNode.RenderFlags.None)
                    {
                        renderFlags |= RecipientWellNode.RenderFlags.RenderCommas;
                    }
                }
            }
        }
Ejemplo n.º 2
0
 private static void AddADRecipients(ADRawEntry[] adRecipients, AnrManager.Options options, List <RecipientAddress> addresses)
 {
     if (adRecipients != null)
     {
         foreach (ADRawEntry adrawEntry in adRecipients)
         {
             RecipientType recipientType = (RecipientType)adrawEntry[ADRecipientSchema.RecipientType];
             if (recipientType == RecipientType.UserMailbox || recipientType == RecipientType.MailUniversalDistributionGroup || recipientType == RecipientType.MailUniversalSecurityGroup || recipientType == RecipientType.MailNonUniversalGroup || recipientType == RecipientType.MailUser || recipientType == RecipientType.MailContact || recipientType == RecipientType.DynamicDistributionGroup || recipientType == RecipientType.PublicFolder)
             {
                 bool   flag = Utilities.IsADDistributionList((MultiValuedProperty <string>)adrawEntry[ADObjectSchema.ObjectClass]);
                 string text = Utilities.NormalizePhoneNumber((string)adrawEntry[ADOrgPersonSchema.MobilePhone]);
                 if (!flag || !Utilities.IsFlagSet((int)options.RecipientBlockType, 1))
                 {
                     bool             isRoom           = DirectoryAssistance.IsADRecipientRoom((RecipientDisplayType?)adrawEntry[ADRecipientSchema.RecipientDisplayType]);
                     RecipientAddress recipientAddress = null;
                     if (!flag && options.IsDefaultRoutingType("MOBILE"))
                     {
                         if (!string.IsNullOrEmpty(text))
                         {
                             recipientAddress                = new RecipientAddress();
                             recipientAddress.RoutingType    = "MOBILE";
                             recipientAddress.RoutingAddress = text;
                         }
                         else if (options.OnlyAllowDefaultRoutingType)
                         {
                             goto IL_1BD;
                         }
                     }
                     if (recipientAddress == null)
                     {
                         recipientAddress                = new RecipientAddress();
                         recipientAddress.Alias          = (string)adrawEntry[ADRecipientSchema.Alias];
                         recipientAddress.RoutingAddress = (string)adrawEntry[ADRecipientSchema.LegacyExchangeDN];
                         recipientAddress.RoutingType    = "EX";
                         recipientAddress.SmtpAddress    = adrawEntry[ADRecipientSchema.PrimarySmtpAddress].ToString();
                     }
                     recipientAddress.AddressOrigin      = AddressOrigin.Directory;
                     recipientAddress.ADObjectId         = (ADObjectId)adrawEntry[ADObjectSchema.Id];
                     recipientAddress.IsRoom             = isRoom;
                     recipientAddress.DisplayName        = (string)adrawEntry[ADRecipientSchema.DisplayName];
                     recipientAddress.IsDistributionList = flag;
                     recipientAddress.RecipientType      = recipientType;
                     recipientAddress.SipUri             = InstantMessageUtilities.GetSipUri((ProxyAddressCollection)adrawEntry[ADRecipientSchema.EmailAddresses]);
                     recipientAddress.MobilePhoneNumber  = text;
                     addresses.Add(recipientAddress);
                 }
             }
             IL_1BD :;
         }
     }
 }
        // 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);
        }
Ejemplo n.º 4
0
        public static void AddRecipientsToDraft(string[] ids, Item draft, RecipientItemType type, UserContext userContext)
        {
            if (draft == null)
            {
                throw new ArgumentNullException("draft");
            }
            MessageItem      messageItem      = draft as MessageItem;
            CalendarItemBase calendarItemBase = draft as CalendarItemBase;

            if (messageItem == null && calendarItemBase == null)
            {
                throw new ArgumentException("The draft should be a MessageItem or a CalendarItemBase while it is now a " + draft.GetType().Name);
            }
            if (userContext == null)
            {
                throw new ArgumentNullException("usercontext");
            }
            if (ids == null || ids.Length == 0)
            {
                throw new ArgumentException("ids is null or empty.", "ids");
            }
            IRecipientSession recipientSession = Utilities.CreateADRecipientSession(ConsistencyMode.IgnoreInvalid, userContext);
            SortBy            sortBy           = new SortBy(ADRecipientSchema.DisplayName, SortOrder.Descending);
            RecipientCache    recipientCache   = AutoCompleteCache.TryGetCache(OwaContext.Current.UserContext);

            for (int i = 0; i < ids.Length; i++)
            {
                Guid          guidFromBase64String = Utilities.GetGuidFromBase64String(ids[i]);
                QueryFilter   filter = new ComparisonFilter(ComparisonOperator.Equal, ADObjectSchema.Guid, guidFromBase64String);
                ADRecipient[] array  = recipientSession.Find(null, QueryScope.SubTree, filter, sortBy, 1);
                if (array != null && array.Length != 0)
                {
                    Participant participant = new Participant(array[0]);
                    if (participant != null)
                    {
                        AddressBookHelper.AddParticipantToItem(draft, type, participant);
                        int recipientFlags = 0;
                        if (draft is CalendarItem && DirectoryAssistance.IsADRecipientRoom(array[0]))
                        {
                            recipientFlags = 2;
                        }
                        if (recipientCache != null && userContext.UserOptions.AddRecipientsToAutoCompleteCache)
                        {
                            string participantProperty = Utilities.GetParticipantProperty <string>(participant, ParticipantSchema.SmtpAddress, null);
                            recipientCache.AddEntry(array[0].DisplayName, participantProperty, array[0].LegacyExchangeDN, string.Empty, "EX", AddressOrigin.Directory, recipientFlags, null, EmailAddressIndex.None);
                        }
                    }
                }
            }
            if (recipientCache != null && recipientCache.IsDirty)
            {
                recipientCache.Commit(true);
            }
            if (messageItem != null)
            {
                AddressBookHelper.SaveItem(draft);
                return;
            }
            if (calendarItemBase != null)
            {
                EditCalendarItemHelper.CreateUserContextData(userContext, calendarItemBase);
            }
        }