private void GetDirectoryCerts(List <RecipientAddress> addressList, AmbiguousRecipientToResolve recipient) { List <string> list = new List <string>(addressList.Count); foreach (RecipientAddress recipientAddress in addressList) { list.Add(recipientAddress.RoutingAddress); } Result <ADRawEntry>[] array = this.RecipientSession.FindByLegacyExchangeDNs(list.ToArray(), CertificateManager.adrecipientProperties); if (Command.CurrentCommand != null) { Command.CurrentCommand.Context.ProtocolLogger.SetValue(ProtocolLoggerData.DomainController, this.recipientSession.LastUsedDc); } for (int i = 0; i < array.Length; i++) { Result <ADRawEntry> result = array[i]; if (result.Data != null) { ResolvedRecipient resolvedRecipient = recipient.ResolvedTo[addressList[i].Index]; if (CertificateManager.IsADDistributionList((RecipientType)result.Data[ADRecipientSchema.RecipientType])) { CertificateManager.ADDistributionListExpansion addistributionListExpansion = new CertificateManager.ADDistributionListExpansion(this, new ADRecipientExpansion(CertificateManager.adrecipientProperties, this.organizationId)); addistributionListExpansion.Expand(result.Data); resolvedRecipient.CertificateRecipientCount += addistributionListExpansion.Size; resolvedRecipient.CertificateCount += addistributionListExpansion.Certificates.Count; if (!resolvedRecipient.GlobalCertLimitWasHit && resolvedRecipient.Certificates.Count + addistributionListExpansion.Certificates.Count <= this.certificateSlotsLeft) { resolvedRecipient.Certificates.AddRange(addistributionListExpansion.Certificates.ToArray()); this.certificateSlotsLeft -= addistributionListExpansion.Certificates.Count; } else { resolvedRecipient.GlobalCertLimitWasHit = true; this.certificateSlotsLeft += resolvedRecipient.Certificates.Count; resolvedRecipient.Certificates.Clear(); } } else { resolvedRecipient.CertificateRecipientCount++; X509Certificate2 adrecipientCert = this.GetADRecipientCert(result.Data); if (adrecipientCert != null) { resolvedRecipient.CertificateCount++; if (!resolvedRecipient.GlobalCertLimitWasHit && this.certificateSlotsLeft <= 0) { resolvedRecipient.GlobalCertLimitWasHit = true; this.certificateSlotsLeft += resolvedRecipient.Certificates.Count; resolvedRecipient.Certificates.Clear(); } else if (!resolvedRecipient.GlobalCertLimitWasHit) { resolvedRecipient.Certificates.Add(adrecipientCert); this.certificateSlotsLeft--; } } } } } }
private void GetContactCert(ResolvedRecipient recipient) { RecipientAddress resolvedTo = recipient.ResolvedTo; if (resolvedTo.StoreObjectId == null) { return; } List <PropertyDefinition> list = new List <PropertyDefinition>(4); list.Add(ContactSchema.UserX509Certificates); bool flag = string.Equals(resolvedTo.RoutingType, "EX", StringComparison.OrdinalIgnoreCase); if (flag) { list.AddRange(CertificateManager.contactEmailProperties); } try { using (Item item = Item.Bind(this.mailboxSession, resolvedTo.StoreObjectId, list.ToArray())) { List <string> list2 = new List <string>(4); list2.Add(resolvedTo.RoutingAddress); if (flag) { foreach (PropertyDefinition propertyDefinition in CertificateManager.contactEmailProperties) { Participant participant = item.TryGetProperty(propertyDefinition) as Participant; if (participant != null && string.Equals(participant.RoutingType, "EX", StringComparison.OrdinalIgnoreCase) && string.Equals(participant.EmailAddress, resolvedTo.RoutingAddress, StringComparison.OrdinalIgnoreCase)) { list2.Add(participant.GetValueOrDefault <string>(ParticipantSchema.EmailAddressForDisplay)); break; } } } X509Certificate2 x509Certificate = this.FindBestCertificate(item.TryGetProperty(ContactSchema.UserX509Certificates) as byte[][], list2, true); if (x509Certificate != null) { recipient.CertificateCount++; if (!recipient.GlobalCertLimitWasHit && this.certificateSlotsLeft <= 0) { recipient.GlobalCertLimitWasHit = true; this.certificateSlotsLeft += recipient.Certificates.Count; recipient.Certificates.Clear(); } else if (!recipient.GlobalCertLimitWasHit) { recipient.Certificates.Add(x509Certificate); this.certificateSlotsLeft--; } } } } catch (ObjectNotFoundException) { AirSyncDiagnostics.TraceDebug <StoreObjectId>(ExTraceGlobals.RequestTracer, null, "Object Not Found while trying to retrieve the certificate: '{0}'", resolvedTo.StoreObjectId); } }
public int CompareTo(object value) { ResolvedRecipient resolvedRecipient = value as ResolvedRecipient; if (resolvedRecipient != null) { return(this.ResolvedTo.CompareTo(resolvedRecipient.ResolvedTo)); } throw new ArgumentException("object is not an ResolvedRecipient"); }
// Token: 0x06000370 RID: 880 RVA: 0x0001410C File Offset: 0x0001230C private AnrManager.LookupState GetNamesByAnrFromAD(string name, List <ResolvedRecipient> recipients) { IList <ABObject> addressBookObjects = null; OperationRetryManagerResult operationRetryManagerResult = AnrManager.retryManager.TryRun(delegate { addressBookObjects = this.GetAddressBookSession().FindByANR(name, 1000); }); if (operationRetryManagerResult.Succeeded) { using (IEnumerator <ABObject> enumerator = addressBookObjects.GetEnumerator()) { while (enumerator.MoveNext()) { ABObject abobject = enumerator.Current; if (abobject.CanEmail) { ResolvedRecipient resolvedRecipient = new ResolvedRecipient(new RecipientAddress { AddressOrigin = AddressOrigin.Directory, DisplayName = abobject.DisplayName, RoutingAddress = abobject.LegacyExchangeDN, RoutingType = "EX", SmtpAddress = abobject.EmailAddress }); ABContact abcontact = abobject as ABContact; if (abcontact != null) { resolvedRecipient.Picture = abcontact.Picture; } recipients.Add(resolvedRecipient); } } goto IL_F7; } } AirSyncDiagnostics.TraceError <Exception>(ExTraceGlobals.RequestTracer, 0, "AnrManager.GetNamesByAnrFromAD(): Exception thrown by FindByANR: {0}", operationRetryManagerResult.Exception); IL_F7: switch (recipients.Count) { case 0: return(AnrManager.LookupState.FoundNone); case 1: return(AnrManager.LookupState.FoundExact); default: return(AnrManager.LookupState.FoundMany); } }
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); }