コード例 #1
0
        // Token: 0x06000369 RID: 873 RVA: 0x00013A64 File Offset: 0x00011C64
        public void ResolveOneRecipient(string name, bool searchADFirst, AmbiguousRecipientToResolve recipient)
        {
            if (name == null)
            {
                throw new ArgumentNullException("name");
            }
            List <ResolvedRecipient> list  = new List <ResolvedRecipient>();
            List <ResolvedRecipient> list2 = new List <ResolvedRecipient>();
            string text;
            string text2;
            bool   flag = AnrManager.TryParseNameBeforeAnr(name, out text, out text2);

            if (searchADFirst)
            {
                switch (this.GetNamesByAnrFromAD(flag ? string.Format(CultureInfo.InvariantCulture, "{0}:{1}", new object[]
                {
                    text,
                    text2
                }) : name, list2))
                {
                case AnrManager.LookupState.FoundNone:
                {
                    AnrManager.LookupState namesByAnrFromContacts = this.GetNamesByAnrFromContacts(flag ? text2 : name, list);
                    recipient.ExactMatchFound = (namesByAnrFromContacts == AnrManager.LookupState.FoundExact);
                    break;
                }

                case AnrManager.LookupState.FoundExact:
                    recipient.ExactMatchFound = true;
                    break;

                case AnrManager.LookupState.FoundMany:
                    this.GetNamesByAnrFromContacts(flag ? text2 : name, list);
                    recipient.ExactMatchFound = false;
                    break;
                }
            }
            else
            {
                switch (this.GetNamesByAnrFromContacts(flag ? text2 : name, list))
                {
                case AnrManager.LookupState.FoundNone:
                {
                    AnrManager.LookupState namesByAnrFromAD = this.GetNamesByAnrFromAD(flag ? string.Format(CultureInfo.InvariantCulture, "{0}:{1}", new object[]
                        {
                            text,
                            text2
                        }) : name, list2);
                    recipient.ExactMatchFound = (namesByAnrFromAD == AnrManager.LookupState.FoundExact);
                    break;
                }

                case AnrManager.LookupState.FoundExact:
                    recipient.ExactMatchFound = true;
                    break;

                case AnrManager.LookupState.FoundMany:
                    this.GetNamesByAnrFromAD(flag ? string.Format(CultureInfo.InvariantCulture, "{0}:{1}", new object[]
                    {
                        text,
                        text2
                    }) : name, list2);
                    recipient.ExactMatchFound = false;
                    break;
                }
            }
            list.Sort();
            list2.Sort();
            list.AddRange(list2);
            int num = recipient.ExactMatchFound ? list.Count : Math.Min(this.nameLimit, list.Count);

            recipient.ResolvedNamesCount = list.Count;
            recipient.CompleteList       = (num == list.Count);
            list.RemoveRange(num, list.Count - num);
            recipient.ResolvedTo = list;
        }
コード例 #2
0
        internal override Command.ExecutionState ExecuteCommand()
        {
            this.ReadXmlRequest();
            this.InitializeResponseXmlDocument();
            CertificateManager certificateManager = new CertificateManager(base.User.ExchangePrincipal, base.MailboxSession, base.Context.Request.Culture.LCID, this.maxCertificates, this.SmimeConfiguration, base.User.OrganizationId);
            bool searchADFirst            = this.ShouldResolveToADFirst();
            List <ResolvedRecipient> list = null;

            if (this.availabilityOptions != null)
            {
                list = new List <ResolvedRecipient>(Math.Min(this.recipientsList.Count, Configuration.MaximumIdentityArraySize));
            }
            if (this.pictureOptions != null)
            {
                this.photoRetriever = new AirSyncPhotoRetriever(base.Context);
            }
            using (AnrManager anrManager = new AnrManager(base.User, base.MailboxSession, base.Context.Request.Culture.LCID, this.maxAmbiguousRecipients))
            {
                foreach (AmbiguousRecipientToResolve ambiguousRecipientToResolve in this.recipientsList)
                {
                    anrManager.ResolveOneRecipient(ambiguousRecipientToResolve.Name, searchADFirst, ambiguousRecipientToResolve);
                    if (ambiguousRecipientToResolve.ResolvedTo.Count != 0)
                    {
                        if (!ambiguousRecipientToResolve.ExactMatchFound)
                        {
                            goto IL_1C8;
                        }
                        ambiguousRecipientToResolve.Status = StatusCode.Success;
                        if (this.certificateRetrieval != ResolveRecipientsCommand.CertificateRetrievalType.None)
                        {
                            foreach (ResolvedRecipient resolvedRecipient in ambiguousRecipientToResolve.ResolvedTo)
                            {
                                resolvedRecipient.CertificateRetrieval = this.certificateRetrieval;
                            }
                            certificateManager.GetRecipientCerts(ambiguousRecipientToResolve);
                        }
                        if (this.availabilityOptions != null)
                        {
                            using (List <ResolvedRecipient> .Enumerator enumerator3 = ambiguousRecipientToResolve.ResolvedTo.GetEnumerator())
                            {
                                while (enumerator3.MoveNext())
                                {
                                    ResolvedRecipient resolvedRecipient2 = enumerator3.Current;
                                    if (list.Count < Configuration.MaximumIdentityArraySize)
                                    {
                                        list.Add(resolvedRecipient2);
                                    }
                                    else
                                    {
                                        resolvedRecipient2.AvailabilityStatus = StatusCode.AvailabilityTooManyRecipients;
                                    }
                                }
                                goto IL_1DC;
                            }
                            goto IL_1C8;
                        }
IL_1DC:
                        ambiguousRecipientToResolve.PictureOptions = this.pictureOptions;
                        continue;
IL_1C8:
                        ambiguousRecipientToResolve.Status = (ambiguousRecipientToResolve.CompleteList ? StatusCode.Sync_ProtocolVersionMismatch : StatusCode.Sync_InvalidSyncKey);
                        goto IL_1DC;
                    }
                    ambiguousRecipientToResolve.Status = StatusCode.Sync_ProtocolError;
                }
            }
            if (this.pictureOptions != null && base.Context.User.Features.IsEnabled(EasFeature.HDPhotos) && base.Context.Request.Version >= 160)
            {
                List <string> recipients = new List <string>();
                this.recipientsList.ForEach(delegate(AmbiguousRecipientToResolve recipient)
                {
                    if (recipient.Status == StatusCode.Success)
                    {
                        recipients.AddRange(from s in recipient.ResolvedTo
                                            select s.ResolvedTo.SmtpAddress);
                    }
                });
                this.photoRetriever.BeginGetThumbnailPhotoFromMailbox(recipients, this.pictureOptions.PhotoSize);
            }
            if (this.availabilityOptions != null && list.Count > 0)
            {
                AvailabilityQuery       availabilityQuery = this.CreateAvailabilityQuery(list);
                AvailabilityQueryResult result;
                if (this.QueryAvailability(availabilityQuery, list, out result))
                {
                    this.FillInAvailabilityData(list, result);
                }
            }
            this.BuildXmlResponse();
            return(Command.ExecutionState.Complete);
        }