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); } }
// Token: 0x0600036F RID: 879 RVA: 0x00013FA4 File Offset: 0x000121A4 private void ExpandPDL(RecipientAddress address, List <ResolvedRecipient> recipients) { Participant[] array; try { array = DistributionList.ExpandDeep(this.mailboxSession, address.StoreObjectId); } catch (ObjectNotFoundException) { return; } foreach (Participant participant in array) { StoreParticipantOrigin storeParticipantOrigin = participant.Origin as StoreParticipantOrigin; if (storeParticipantOrigin != null) { StoreObjectId originItemId = storeParticipantOrigin.OriginItemId; RecipientAddress recipientAddress; try { recipientAddress = this.ConstructStoreRecipientAddress(participant, participant.DisplayName, originItemId); } catch (ObjectNotFoundException) { goto IL_FF; } if (recipientAddress != null) { recipients.Add(new ResolvedRecipient(recipientAddress)); } } else { RecipientAddress recipientAddress2 = new RecipientAddress(); recipientAddress2.RoutingType = participant.RoutingType; recipientAddress2.SmtpAddress = (participant.TryGetProperty(ParticipantSchema.SmtpAddress) as string); recipientAddress2.DisplayName = participant.DisplayName; recipientAddress2.RoutingAddress = participant.EmailAddress; if (!string.IsNullOrEmpty(recipientAddress2.RoutingType) && participant.RoutingType == "EX") { recipientAddress2.AddressOrigin = AddressOrigin.Directory; } else { recipientAddress2.AddressOrigin = AddressOrigin.OneOff; } if (recipientAddress2.SmtpAddress != null) { recipients.Add(new ResolvedRecipient(recipientAddress2)); } } IL_FF :; } }
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); }
internal void GetRecipientCerts(AmbiguousRecipientToResolve recipient) { List <RecipientAddress> list = new List <RecipientAddress>(recipient.ResolvedTo.Count); int num = -1; foreach (ResolvedRecipient resolvedRecipient in recipient.ResolvedTo) { RecipientAddress resolvedTo = resolvedRecipient.ResolvedTo; num = (resolvedTo.Index = num + 1); switch (resolvedTo.AddressOrigin) { case AddressOrigin.Store: resolvedRecipient.CertificateRecipientCount++; this.GetContactCert(resolvedRecipient); break; case AddressOrigin.Directory: if (this.exchangePrincipal.MailboxInfo.IsAggregated) { resolvedRecipient.CertificateRecipientCount++; } else { list.Add(resolvedTo); } break; default: resolvedRecipient.CertificateRecipientCount++; break; } } if (list.Count > 0) { this.GetDirectoryCerts(list, recipient); } }
// Token: 0x06000371 RID: 881 RVA: 0x00014240 File Offset: 0x00012440 private AnrManager.LookupState GetNamesByAnrFromContacts(string name, List <ResolvedRecipient> recipients) { if (this.mailboxSession.GetDefaultFolderId(DefaultFolderType.Contacts) == null) { return(AnrManager.LookupState.FoundNone); } AnrManager.LookupState result; using (ContactsFolder contactsFolder = ContactsFolder.Bind(this.mailboxSession, DefaultFolderType.Contacts)) { if (!contactsFolder.IsValidAmbiguousName(name)) { result = AnrManager.LookupState.FoundNone; } else { object[][] array = contactsFolder.ResolveAmbiguousNameView(name, int.MaxValue, null, AnrManager.anrContactProperties); List <RecipientAddress> list = new List <RecipientAddress>(); int num = 0; while (array != null && num < array.GetLength(0)) { object[] array2 = array[num]; Participant participant = array2[1] as Participant; if (participant != null) { string displayName = array2[0] as string; VersionedId versionedId = (VersionedId)array2[2]; StoreObjectId storeId = (versionedId == null) ? null : versionedId.ObjectId; RecipientAddress recipientAddress = this.ConstructStoreRecipientAddress(participant, displayName, storeId); if (recipientAddress != null) { if (recipientAddress.RoutingType != null && string.Equals(recipientAddress.RoutingType, "MAPIPDL", StringComparison.OrdinalIgnoreCase)) { list.Add(recipientAddress); } else { recipients.Add(new ResolvedRecipient(recipientAddress)); } } } num++; } bool flag = recipients.Count + list.Count == 1; foreach (RecipientAddress address in list) { this.ExpandPDL(address, recipients); } if (recipients.Count == 0) { result = AnrManager.LookupState.FoundNone; } else if (flag) { result = AnrManager.LookupState.FoundExact; } else { result = AnrManager.LookupState.FoundMany; } } } return(result); }
// Token: 0x0600036E RID: 878 RVA: 0x00013D5C File Offset: 0x00011F5C private RecipientAddress ConstructStoreRecipientAddress(Participant participant, string displayName, StoreObjectId storeId) { RecipientAddress recipientAddress = new RecipientAddress(); recipientAddress.DisplayName = displayName; recipientAddress.AddressOrigin = AddressOrigin.Store; recipientAddress.RoutingType = participant.RoutingType; if (!string.IsNullOrEmpty(participant.EmailAddress)) { recipientAddress.RoutingAddress = participant.EmailAddress; if (string.Equals(recipientAddress.RoutingType, "EX", StringComparison.OrdinalIgnoreCase)) { string text = participant.TryGetProperty(ParticipantSchema.SmtpAddress) as string; if (string.IsNullOrEmpty(text)) { ABObject recipient = null; OperationRetryManagerResult operationRetryManagerResult = AnrManager.retryManager.TryRun(delegate { recipient = this.GetAddressBookSession().FindByLegacyExchangeDN(recipientAddress.RoutingAddress); }); if (!operationRetryManagerResult.Succeeded) { if (operationRetryManagerResult.Exception is ABProviderLoadException) { throw new AirSyncPermanentException(StatusCode.Sync_ClientServerConversion, EASServerStrings.UnableToLoadAddressBookProvider, operationRetryManagerResult.Exception, true) { ErrorStringForProtocolLogger = "ABProviderNotFound" }; } if (operationRetryManagerResult.Exception is ABSubscriptionDisabledException) { throw new AirSyncPermanentException(StatusCode.Sync_ClientServerConversion, operationRetryManagerResult.Exception, false) { ErrorStringForProtocolLogger = "ABSubscriptionDisabled" }; } if (operationRetryManagerResult.Exception is DataValidationException) { throw new AirSyncPermanentException(StatusCode.Sync_ClientServerConversion, operationRetryManagerResult.Exception, false) { ErrorStringForProtocolLogger = "AnrError:ADDataInvalid" }; } if (operationRetryManagerResult.Exception is ABOperationException) { ABOperationException ex = (ABOperationException)operationRetryManagerResult.Exception; throw new AirSyncPermanentException(StatusCode.Sync_ClientServerConversion, operationRetryManagerResult.Exception, false) { ErrorStringForProtocolLogger = "AnrError:ABOperationException" }; } if (operationRetryManagerResult.Exception is ABTransientException) { AirSyncDiagnostics.TraceError <string>(ExTraceGlobals.RequestTracer, null, "AnrManager.ConstructStoreRecipientAddress(): ABTransientException was thrown by FindByLegacyExchangeDN: {0}", operationRetryManagerResult.Exception.Message); } } if (recipient == null) { return(null); } recipientAddress.SmtpAddress = recipient.EmailAddress; } else { recipientAddress.SmtpAddress = text; } } else { if (!string.Equals(recipientAddress.RoutingType, "SMTP", StringComparison.OrdinalIgnoreCase)) { return(null); } recipientAddress.SmtpAddress = recipientAddress.RoutingAddress; } } recipientAddress.StoreObjectId = storeId; return(recipientAddress); }
internal ResolvedRecipient(RecipientAddress address) { this.ResolvedTo = address; this.CertificateRetrieval = ResolveRecipientsCommand.CertificateRetrievalType.None; this.Certificates = new X509Certificate2Collection(); }