Exemplo n.º 1
0
        public static RecipientAddress ResolveAnrStringToOneOffEmail(string name, AnrManager.Options options)
        {
            if (name == null)
            {
                throw new ArgumentNullException("name");
            }
            RecipientAddress recipientAddress = null;
            Participant      participant;

            if (AnrManager.TryParseParticipant(name, options, out participant) && (!options.OnlyAllowDefaultRoutingType || options.IsDefaultRoutingType(participant.RoutingType)))
            {
                recipientAddress                   = new RecipientAddress();
                recipientAddress.DisplayName       = participant.DisplayName;
                recipientAddress.AddressOrigin     = RecipientAddress.ToAddressOrigin(participant);
                recipientAddress.RoutingAddress    = (AnrManager.IsMobileNumberInput(participant, options) ? participant.DisplayName : participant.EmailAddress);
                recipientAddress.RoutingType       = participant.RoutingType;
                recipientAddress.SmtpAddress       = ((participant.RoutingType == "SMTP") ? participant.EmailAddress : null);
                recipientAddress.MobilePhoneNumber = ((participant.RoutingType == "MOBILE") ? participant.EmailAddress : null);
                StoreParticipantOrigin storeParticipantOrigin = participant.Origin as StoreParticipantOrigin;
                if (storeParticipantOrigin != null)
                {
                    recipientAddress.StoreObjectId     = storeParticipantOrigin.OriginItemId;
                    recipientAddress.EmailAddressIndex = storeParticipantOrigin.EmailAddressIndex;
                }
            }
            return(recipientAddress);
        }
Exemplo n.º 2
0
        // Token: 0x06000B95 RID: 2965 RVA: 0x00050E2C File Offset: 0x0004F02C
        public static bool IsInternalToOrganization(string email, UserContext userContext)
        {
            RecipientAddress recipientAddress = AnrManager.ResolveAnrString(email, new AnrManager.Options
            {
                ResolveOnlyFromAddressBook = true
            }, userContext);

            return(recipientAddress != null && recipientAddress.AddressOrigin == AddressOrigin.Directory && recipientAddress.RecipientType != RecipientType.MailUser && recipientAddress.RecipientType != RecipientType.MailContact);
        }
Exemplo n.º 3
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 :;
         }
     }
 }
Exemplo n.º 4
0
 public static void ResolveOneRecipient(string name, UserContext userContext, List <RecipientAddress> addresses, AnrManager.Options options)
 {
     if (name == null)
     {
         throw new ArgumentNullException("name");
     }
     if (userContext == null)
     {
         throw new ArgumentNullException("userContext");
     }
     if (addresses == null)
     {
         throw new ArgumentNullException("addresses");
     }
     AnrManager.NameParsingResult parsingResult = AnrManager.ParseNameBeforeAnr(name, options);
     if (!options.ResolveOnlyFromAddressBook && userContext.IsFeatureEnabled(Feature.Contacts))
     {
         AnrManager.GetNamesByAnrFromContacts(userContext, parsingResult, options, addresses);
     }
     AnrManager.GetNamesByAnrFromAD(userContext, parsingResult, options, addresses);
     if (AnrManager.IsMobileNumberInput(parsingResult, options) && addresses.Count > 0)
     {
         bool flag = false;
         foreach (RecipientAddress address in addresses)
         {
             if (AnrManager.IsMobileAddressExactMatch(parsingResult, address))
             {
                 flag = true;
                 break;
             }
         }
         if (!flag)
         {
             RecipientAddress recipientAddress = AnrManager.ResolveAnrStringToOneOffEmail(name, options);
             if (recipientAddress != null)
             {
                 addresses.Add(recipientAddress);
             }
         }
     }
     addresses.Sort();
 }
Exemplo n.º 5
0
        // Token: 0x060012DA RID: 4826 RVA: 0x00071A44 File Offset: 0x0006FC44
        public int CompareTo(object value)
        {
            RecipientAddress recipientAddress = value as RecipientAddress;

            if (recipientAddress == null)
            {
                throw new ArgumentException("object is not an RecipientAddress");
            }
            if (this.displayName != null && recipientAddress.DisplayName != null)
            {
                return(this.displayName.CompareTo(recipientAddress.DisplayName));
            }
            if (this.displayName == null && recipientAddress.DisplayName != null)
            {
                return(-1);
            }
            if (this.displayName != null && recipientAddress.DisplayName == null)
            {
                return(1);
            }
            return(0);
        }
Exemplo n.º 6
0
        private static void AddContacts(UserContext userContext, AnrManager.Options options, PropertyDefinition[] properties, object[][] results, List <RecipientAddress> addresses)
        {
            if (results != null && results.GetLength(0) > 0)
            {
                int i = 0;
                while (i < results.GetLength(0))
                {
                    object[]    results2    = results[i];
                    Participant participant = null;
                    string      displayName = null;
                    string      text        = Utilities.NormalizePhoneNumber(AnrManager.FindFromResultsMapping(ContactSchema.MobilePhone, properties, results2) as string);
                    VersionedId versionedId = AnrManager.FindFromResultsMapping(ItemSchema.Id, properties, results2) as VersionedId;
                    if (!options.ResolveAgainstAllContacts && !options.IsDefaultRoutingType("MOBILE"))
                    {
                        participant = (AnrManager.FindFromResultsMapping(ContactBaseSchema.AnrViewParticipant, properties, results2) as Participant);
                        displayName = participant.DisplayName;
                        goto IL_1AB;
                    }
                    Participant participant2 = AnrManager.FindFromResultsMapping(DistributionListSchema.AsParticipant, properties, results2) as Participant;
                    if (participant2 != null)
                    {
                        participant = participant2;
                        displayName = participant.DisplayName;
                        goto IL_1AB;
                    }
                    if (options.IsDefaultRoutingType("MOBILE"))
                    {
                        if (!string.IsNullOrEmpty(text))
                        {
                            displayName = (AnrManager.FindFromResultsMapping(StoreObjectSchema.DisplayName, properties, results2) as string);
                            participant = new Participant(displayName, text, "MOBILE", new StoreParticipantOrigin(versionedId), new KeyValuePair <PropertyDefinition, object> [0]);
                        }
                        else if (options.OnlyAllowDefaultRoutingType)
                        {
                            goto IL_339;
                        }
                    }
                    if (!(participant == null))
                    {
                        goto IL_1AB;
                    }
                    Participant participant3 = AnrManager.FindFromResultsMapping(ContactSchema.Email1, properties, results2) as Participant;
                    Participant participant4 = AnrManager.FindFromResultsMapping(ContactSchema.Email2, properties, results2) as Participant;
                    Participant participant5 = AnrManager.FindFromResultsMapping(ContactSchema.Email3, properties, results2) as Participant;
                    if (participant3 != null && !string.IsNullOrEmpty(participant3.EmailAddress))
                    {
                        participant = participant3;
                        displayName = participant.DisplayName;
                        goto IL_1AB;
                    }
                    if (participant4 != null && !string.IsNullOrEmpty(participant4.EmailAddress))
                    {
                        participant = participant4;
                        displayName = participant.DisplayName;
                        goto IL_1AB;
                    }
                    if (participant5 != null && !string.IsNullOrEmpty(participant5.EmailAddress))
                    {
                        participant = participant5;
                        displayName = participant.DisplayName;
                        goto IL_1AB;
                    }
                    goto IL_1AB;
IL_339:
                    i++;
                    continue;
IL_1AB:
                    RecipientAddress recipientAddress  = new RecipientAddress();
                    recipientAddress.MobilePhoneNumber = text;
                    recipientAddress.DisplayName       = displayName;
                    recipientAddress.AddressOrigin     = AddressOrigin.Store;
                    if (participant != null)
                    {
                        if (Utilities.IsMapiPDL(participant.RoutingType) && Utilities.IsFlagSet((int)options.RecipientBlockType, 2))
                        {
                            goto IL_339;
                        }
                        recipientAddress.RoutingType       = participant.RoutingType;
                        recipientAddress.EmailAddressIndex = ((StoreParticipantOrigin)participant.Origin).EmailAddressIndex;
                        if (!string.IsNullOrEmpty(participant.EmailAddress))
                        {
                            recipientAddress.RoutingAddress = participant.EmailAddress;
                            if (string.CompareOrdinal(recipientAddress.RoutingType, "EX") == 0)
                            {
                                string text2 = participant.TryGetProperty(ParticipantSchema.SmtpAddress) as string;
                                if (string.IsNullOrEmpty(text2))
                                {
                                    IRecipientSession recipientSession = Utilities.CreateADRecipientSession(Culture.GetUserCulture().LCID, true, ConsistencyMode.IgnoreInvalid, true, userContext);
                                    ADRecipient       adrecipient      = null;
                                    try
                                    {
                                        adrecipient = recipientSession.FindByLegacyExchangeDN(recipientAddress.RoutingAddress);
                                    }
                                    catch (NonUniqueRecipientException ex)
                                    {
                                        ExTraceGlobals.CoreTracer.TraceDebug <string>(0L, "AnrManager.GetNamesByAnrFromContacts: NonUniqueRecipientException was thrown by FindByLegacyExchangeDN: {0}", ex.Message);
                                    }
                                    if (adrecipient == null || adrecipient.HiddenFromAddressListsEnabled)
                                    {
                                        goto IL_339;
                                    }
                                    recipientAddress.SmtpAddress = adrecipient.PrimarySmtpAddress.ToString();
                                }
                                else
                                {
                                    recipientAddress.SmtpAddress = text2;
                                }
                            }
                            else if (string.CompareOrdinal(recipientAddress.RoutingType, "SMTP") == 0)
                            {
                                recipientAddress.SmtpAddress = recipientAddress.RoutingAddress;
                            }
                        }
                    }
                    if (Utilities.IsMapiPDL(recipientAddress.RoutingType))
                    {
                        recipientAddress.IsDistributionList = true;
                    }
                    if (versionedId != null)
                    {
                        recipientAddress.StoreObjectId = versionedId.ObjectId;
                    }
                    addresses.Add(recipientAddress);
                    goto IL_339;
                }
            }
        }
Exemplo n.º 7
0
        private static bool IsMobileAddressExactMatch(AnrManager.NameParsingResult parsingResult, RecipientAddress address)
        {
            if (!parsingResult.ParsedSuccessfully)
            {
                return(false);
            }
            if (!Utilities.IsMobileRoutingType(parsingResult.RoutingType))
            {
                return(false);
            }
            if (!Utilities.IsMobileRoutingType(address.RoutingType))
            {
                return(false);
            }
            E164Number objA = null;
            E164Number objB = null;

            return(E164Number.TryParse(parsingResult.RoutingAddress, out objA) && E164Number.TryParse(address.RoutingAddress, out objB) && object.Equals(objA, objB));
        }