Пример #1
0
        private void AddX500ProxyAddressIfNeeded(List <PropertyUpdateXML> updates, ADUser user, string legacyDN, string userCorrespondingToLegDn)
        {
            Exception ex = null;

            try
            {
                CustomProxyAddress customProxyAddress = new CustomProxyAddress((CustomProxyAddressPrefix)ProxyAddressPrefix.X500, legacyDN, false);
                if (!user.EmailAddresses.Contains(customProxyAddress))
                {
                    PropertyUpdateXML.Add(updates, ADRecipientSchema.EmailAddresses, customProxyAddress.ToString(), PropertyUpdateOperation.AddValues);
                }
            }
            catch (ArgumentException ex2)
            {
                ex = ex2;
            }
            catch (LocalizedException ex3)
            {
                ex = ex3;
            }
            if (ex != null)
            {
                LocalizedString localizedString = MrsStrings.RecipientInvalidLegDN(userCorrespondingToLegDn, legacyDN ?? "<empty>");
                base.Report.Append(localizedString, ex, ReportEntryFlags.None);
                base.Warnings.Add(localizedString);
            }
        }
        // Token: 0x06002F23 RID: 12067 RVA: 0x0010FD4C File Offset: 0x0010DF4C
        private RecipientWellEventHandler.ADRecipientProperties GetADRecipientProperties(ADObjectId adObjectId, string routingAddress, string routingType)
        {
            if (string.IsNullOrEmpty(routingAddress))
            {
                throw new ArgumentNullException("routingAddress");
            }
            if (string.IsNullOrEmpty(routingType))
            {
                throw new ArgumentNullException("routingType");
            }
            IRecipientSession recipientSession = Utilities.CreateADRecipientSession(Culture.GetUserCulture().LCID, true, ConsistencyMode.IgnoreInvalid, true, base.UserContext);
            ADRecipient       adrecipient      = null;

            RecipientWellEventHandler.ADRecipientProperties result = default(RecipientWellEventHandler.ADRecipientProperties);
            if (string.Equals(routingType, "EX", StringComparison.Ordinal))
            {
                try
                {
                    CustomProxyAddress proxyAddress = new CustomProxyAddress((CustomProxyAddressPrefix)ProxyAddressPrefix.LegacyDN, routingAddress, true);
                    adrecipient = recipientSession.FindByProxyAddress(proxyAddress);
                    goto IL_FB;
                }
                catch (NonUniqueRecipientException ex)
                {
                    ExTraceGlobals.CoreTracer.TraceDebug <string>((long)this.GetHashCode(), "GetADRecipientProperties: NonUniqueRecipientException was thrown by FindByProxyAddress: {0}", ex.Message);
                    throw new OwaEventHandlerException("Unable to retrieve properties.", LocalizedStrings.GetNonEncoded(-1953304495));
                }
            }
            if (string.Equals(routingType, "SMTP", StringComparison.Ordinal))
            {
                try
                {
                    SmtpProxyAddress proxyAddress2 = new SmtpProxyAddress(routingAddress, true);
                    adrecipient = recipientSession.FindByProxyAddress(proxyAddress2);
                }
                catch (NonUniqueRecipientException ex2)
                {
                    ExTraceGlobals.CoreTracer.TraceDebug <string>(0L, "GetADRecipientProperties: NonUniqueRecipientException was thrown by FindByProxyAddress: {0}", ex2.Message);
                    throw new OwaEventHandlerException("Unable to retrieve properties.", LocalizedStrings.GetNonEncoded(-1953304495));
                }
            }
IL_FB:
            if (adrecipient == null && adObjectId != null)
            {
                adrecipient = recipientSession.Read(adObjectId);
            }
            if (adrecipient == null)
            {
                throw new OwaEventHandlerException("Unable to retrieve properties.", LocalizedStrings.GetNonEncoded(-1953304495));
            }
            IADOrgPerson iadorgPerson = adrecipient as IADOrgPerson;

            if (iadorgPerson != null)
            {
                result.Office = iadorgPerson.Office;
                result.Phone  = iadorgPerson.Phone;
                if (adrecipient.Id == null)
                {
                    throw new OwaEventHandlerException("Unable to retrieve id for AD Recipient.", LocalizedStrings.GetNonEncoded(-1953304495));
                }
                result.Id = DirectoryAssistance.ToHtmlString(adrecipient.Id);
            }
            return(result);
        }
Пример #3
0
        // Token: 0x06002C63 RID: 11363 RVA: 0x000F738C File Offset: 0x000F558C
        private Stream GetADPictureStream(string email, string routingType)
        {
            IRecipientSession recipientSession = Utilities.CreateADRecipientSession(ConsistencyMode.IgnoreInvalid, base.UserContext);

            byte[] array      = null;
            bool   flag       = string.Equals(email, base.UserContext.ExchangePrincipal.LegacyDn, StringComparison.OrdinalIgnoreCase);
            string stringHash = Utilities.GetStringHash(email);
            bool   flag2      = DisplayPictureUtility.IsInRecipientsNegativeCache(stringHash);

            if (!flag2 || flag)
            {
                ProxyAddress proxyAddress = null;
                try
                {
                    if (string.Equals(routingType, "EX", StringComparison.Ordinal))
                    {
                        proxyAddress = new CustomProxyAddress((CustomProxyAddressPrefix)ProxyAddressPrefix.LegacyDN, email, true);
                    }
                    else if (string.Equals(routingType, "SMTP", StringComparison.Ordinal))
                    {
                        proxyAddress = new SmtpProxyAddress(email, true);
                    }
                    if (proxyAddress != null)
                    {
                        if (Globals.ArePerfCountersEnabled)
                        {
                            OwaSingleCounters.SenderPhotosTotalLDAPCalls.Increment();
                        }
                        ADRawEntry adrawEntry = recipientSession.FindByProxyAddress(proxyAddress, new PropertyDefinition[]
                        {
                            ADRecipientSchema.ThumbnailPhoto
                        });
                        if (adrawEntry != null)
                        {
                            array = (adrawEntry[ADRecipientSchema.ThumbnailPhoto] as byte[]);
                        }
                    }
                    goto IL_10F;
                }
                catch (NonUniqueRecipientException ex)
                {
                    ExTraceGlobals.CoreTracer.TraceDebug <string>(0L, "GetADPictureStream: NonUniqueRecipientException was thrown by FindByProxyAddress: {0}", ex.Message);
                    throw new OwaEventHandlerException("Unable to retrieve recipient data.", LocalizedStrings.GetNonEncoded(-1953304495));
                }
            }
            if (Globals.ArePerfCountersEnabled)
            {
                OwaSingleCounters.SenderPhotosDataFromNegativeCacheCount.Increment();
            }
IL_10F:
            bool flag3 = array != null && array.Length > 0;

            if (flag)
            {
                base.UserContext.HasPicture = new bool?(flag3);
            }
            if (flag3)
            {
                if (Globals.ArePerfCountersEnabled)
                {
                    OwaSingleCounters.SenderPhotosTotalLDAPCallsWithPicture.Increment();
                }
                if (flag2)
                {
                    DisplayPictureUtility.RecipientsNegativeCache.Remove(stringHash);
                }
                return(new MemoryStream(array));
            }
            if (!flag2)
            {
                int num = DisplayPictureUtility.RecipientsNegativeCache.AddAndCount(stringHash, DateTime.UtcNow);
                if (Globals.ArePerfCountersEnabled)
                {
                    OwaSingleCounters.SenderPhotosNegativeCacheCount.RawValue = (long)num;
                }
            }
            return(new MemoryStream());
        }