public virtual void CreateMessage(DeliverableItem item) { this.mailItemDeliver.Stage = this.mailItemDeliver.DeliveryBreadcrumb.SetStage(MailItemDeliver.DeliveryStage.CreateMessage); this.mailItemDeliver.CreateMessage(item); this.mailItemDeliver.Stage = this.mailItemDeliver.DeliveryBreadcrumb.SetStage(MailItemDeliver.DeliveryStage.PromoteProperties); this.mailItemDeliver.PromotePropertiesToItem(); this.mailItemDeliver.Stage = this.mailItemDeliver.DeliveryBreadcrumb.SetStage(MailItemDeliver.DeliveryStage.OnCreatedEvent); this.mailItemDeliver.RaiseEvent("OnCreatedMessage", LatencyComponent.StoreDriverOnCreatedMessage); }
public void CreatePublicFolderMessage(MailRecipient recipient, DeliverableItem item) { PublicFolderSession publicFolderSession = (PublicFolderSession)this.storeSession; bool flag = false; try { this.context.BeginTrackLatency(LatencyComponent.StoreDriverDeliveryRpc); using (Folder folder = Folder.Bind(publicFolderSession, this.deliverToFolder, new PropertyDefinition[] { FolderSchema.SecurityDescriptor })) { switch (MailPublicFolderPermissionHandler.CheckAccessForEmailDelivery(this.context, folder)) { case AccessCheckResult.NotAllowedAnonymous: DeliveryItem.Diag.TraceError(0L, "Anonymous users are not permitted to add contents to mail enabled public folder."); throw new SmtpResponseException(AckReason.NotAuthenticated, MessageAction.NDR); case AccessCheckResult.NotAllowedAuthenticated: DeliveryItem.Diag.TraceError <RoutingAddress>(0L, "User {0} is not permitted to add contents to mail enabled public folder.", this.context.MbxTransportMailItem.From); throw new SmtpResponseException(AckReason.RecipientPermissionRestricted, MessageAction.NDR); case AccessCheckResult.NotAllowedInternalSystemError: DeliveryItem.Diag.TraceError(0L, "Exception occured when determining permission for sender on public folder"); throw new SmtpResponseException(AckReason.PublicFolderSenderValidationFailed, MessageAction.NDR); default: if (folder.IsContentAvailable()) { this.messageItem = MessageItem.CreateForDelivery(publicFolderSession, folder.Id, this.context.ReplayItem.InternetMessageId, this.context.ReplayItem.GetValueAsNullable <ExDateTime>(ItemSchema.SentTime)); if (this.messageItem != null && this.messageItem.DisposeTracker != null) { this.messageItem.DisposeTracker.AddExtraDataWithStackTrace("DeliveryItem owns messageItem at:{0}{1}"); } flag = true; } else { this.ReroutePublicFolderRecipient(publicFolderSession, folder, recipient); } break; } } } finally { TimeSpan additionalLatency = this.context.EndTrackLatency(LatencyComponent.StoreDriverDeliveryRpc); this.context.AddRpcLatency(additionalLatency, "Open message"); } if (flag) { ItemConversion.ReplayInboundContent(this.context.ReplayItem, this.messageItem); } }
public override void CreateMessage(DeliverableItem item) { if (this.mailItemDeliver.IsPublicFolderRecipient) { this.useDeliveryProcessorBase = true; base.CreateMessage(item); return; } RetryAgentMessageSubmissionProcessor.Diag.TraceDebug <string>(0L, "RetryOnDuplicateDelivery set on incoming message {0}.", (this.mailItemDeliver.DeliveryItem != null && this.mailItemDeliver.DeliveryItem.Message != null) ? this.mailItemDeliver.DeliveryItem.Message.InternetMessageId : null); this.mailItemDeliver.Stage = this.mailItemDeliver.DeliveryBreadcrumb.SetStage(MailItemDeliver.DeliveryStage.CreateMessage); if (!this.mailItemDeliver.LoadMessageForAgentEventsRetry()) { RetryAgentMessageSubmissionProcessor.Diag.TraceDebug(0L, "The attempt to load the message failed. Using normal delivery processing for message."); this.mailItemDeliver.ClearRetryOnDuplicateDelivery(); ExTraceGlobals.FaultInjectionTracer.TraceTest(43648U); this.useDeliveryProcessorBase = true; base.CreateMessage(item); return; } this.mailItemDeliver.Stage = this.mailItemDeliver.DeliveryBreadcrumb.SetStage(MailItemDeliver.DeliveryStage.PromoteProperties); this.mailItemDeliver.Stage = this.mailItemDeliver.DeliveryBreadcrumb.SetStage(MailItemDeliver.DeliveryStage.OnCreatedEvent); this.mailItemDeliver.RaiseEvent("OnCreatedMessage", LatencyComponent.StoreDriverOnCreatedMessage); }
public virtual DeliverableItem CreateSession() { if (this.mailItemDeliver.Recipient.ExtendedProperties.Count == 0) { throw new SmtpResponseException(AckReason.ExtendedPropertiesNotAvailable, MessageAction.Reroute); } DeliverableItem deliverableItem = RecipientItem.Create(this.mailItemDeliver.Recipient) as DeliverableItem; if (deliverableItem == null) { throw new SmtpResponseException(AckReason.NotResolvedRecipient, MessageAction.Reroute); } this.mailItemDeliver.Stage = this.mailItemDeliver.DeliveryBreadcrumb.SetStage(MailItemDeliver.DeliveryStage.CreateReplay); this.mailItemDeliver.CreateReplay(); this.mailItemDeliver.IsPublicFolderRecipient = (deliverableItem.RecipientType == RecipientType.PublicFolder); int value; if (DeliveryThrottling.Instance.TryGetDatabaseHealth(this.mailItemDeliver.MbxTransportMailItem.DatabaseGuid, out value)) { this.mailItemDeliver.DatabaseHealthMeasureToLog = new int?(value); } if (!this.mailItemDeliver.IsPublicFolderRecipient) { this.mailItemDeliver.ExtractCulture(); } MailboxItem mailboxItem = deliverableItem as MailboxItem; if (mailboxItem != null) { this.mailItemDeliver.RecipientMailboxGuid = mailboxItem.MailboxGuid; } this.mailItemDeliver.Stage = this.mailItemDeliver.DeliveryBreadcrumb.SetStage(MailItemDeliver.DeliveryStage.CreateSession); this.mailItemDeliver.CreateSession(deliverableItem); this.mailItemDeliver.Stage = this.mailItemDeliver.DeliveryBreadcrumb.SetStage(MailItemDeliver.DeliveryStage.OnPromotedEvent); this.mailItemDeliver.RaiseEvent("OnPromotedMessage", LatencyComponent.StoreDriverOnPromotedMessage); return(deliverableItem); }
private bool isChecked(DeliverableItem dItem, IEnumerable<DataRow> filteredJC) { var deliverables = GetEnumDescription(dItem); return !string.IsNullOrEmpty((from item in filteredJC where ( item["Deliverables"].ToString() == deliverables && item["Value"].ToString() == "Y") select item["Value"].ToString()).FirstOrDefault()); }
private ExchangePrincipal GetExchangePrincipalForRecipient(MailRecipient recipient, DeliverableItem item, ICollection <CultureInfo> recipientLanguages, bool useCompletePrincipal) { ADSessionSettings adsessionSettings = ADSessionSettings.FromOrganizationIdWithoutRbacScopesServiceOnly(recipient.MailItemScopeOrganizationId); Guid databaseGuid = this.context.MbxTransportMailItem.DatabaseGuid; ExchangePrincipal exchangePrincipal; if (this.IsPublicFolderRecipient(item)) { ADObjectId value = recipient.ExtendedProperties.GetValue <ADObjectId>("Microsoft.Exchange.Transport.DirectoryData.ContentMailbox", null); StoreObjectId storeObjectId = null; if (value == null || !StoreObjectId.TryParseFromHexEntryId(recipient.ExtendedProperties.GetValue <string>("Microsoft.Exchange.Transport.DirectoryData.EntryId", null), out storeObjectId)) { throw new SmtpResponseException(AckReason.UnableToDetermineTargetPublicFolderMailbox, MessageAction.Reroute); } this.deliverToFolder = storeObjectId; try { exchangePrincipal = ExchangePrincipal.FromDirectoryObjectId(DirectorySessionFactory.Default.GetTenantOrRootOrgRecipientSession(true, ConsistencyMode.IgnoreInvalid, adsessionSettings, 830, "GetExchangePrincipalForRecipient", "f:\\15.00.1497\\sources\\dev\\MailboxTransport\\src\\MailboxTransportDelivery\\StoreDriver\\DeliveryItem.cs"), value, RemotingOptions.LocalConnectionsOnly); goto IL_14C; } catch (Microsoft.Exchange.Data.Storage.ObjectNotFoundException) { throw new SmtpResponseException(AckReason.PublicFolderMailboxNotFound, MessageAction.Reroute); } } MailboxItem mailboxItem = item as MailboxItem; if (mailboxItem == null) { throw new InvalidOperationException("Delivery to PFDBs is not supported in E15"); } if (!useCompletePrincipal) { string legacyExchangeDN; if (!recipient.ExtendedProperties.TryGetValue <string>("Microsoft.Exchange.Transport.MailRecipient.DisplayName", out legacyExchangeDN)) { legacyExchangeDN = mailboxItem.LegacyExchangeDN; } exchangePrincipal = ExchangePrincipal.FromMailboxData(legacyExchangeDN, adsessionSettings, databaseGuid, mailboxItem.MailboxGuid, mailboxItem.LegacyExchangeDN, recipient.Email.ToString(), recipientLanguages ?? new MultiValuedProperty <CultureInfo>(), true, mailboxItem.RecipientType, mailboxItem.RecipientTypeDetails.GetValueOrDefault()); } else { ProxyAddress proxyAddress = new SmtpProxyAddress((string)recipient.Email, true); exchangePrincipal = ExchangePrincipal.FromProxyAddress(adsessionSettings, proxyAddress.ToString()); } IL_14C: if (exchangePrincipal.MailboxInfo.IsRemote) { throw new SmtpResponseException(AckReason.RecipientMailboxIsRemote, MessageAction.Reroute); } if (exchangePrincipal.MailboxInfo.Location == MailboxDatabaseLocation.Unknown) { throw new SmtpResponseException(AckReason.RecipientMailboxLocationInfoNotAvailable, MessageAction.Reroute); } return(exchangePrincipal); }
private bool IsPublicFolderRecipient(DeliverableItem item) { return(item.RecipientType == Microsoft.Exchange.Data.Directory.Recipient.RecipientType.PublicFolder); }
private void CreateSessionInternal(MailRecipient recipient, OpenTransportSessionFlags deliveryFlags, DeliverableItem item, ICollection <CultureInfo> recipientLanguages, bool useCompletePrincipal) { bool isPublicFolderRecipient = this.IsPublicFolderRecipient(item); ExchangePrincipal principal = this.GetExchangePrincipalForRecipient(recipient, item, recipientLanguages, useCompletePrincipal); string databaseName = this.context.MbxTransportMailItem.DatabaseName; this.LogConnection(databaseName, "Mailbox"); this.RunUnderOpenStoreSessionFailedLogger(databaseName, delegate { if (isPublicFolderRecipient) { this.storeSession = PublicFolderSession.OpenAsTransport(principal, deliveryFlags); return; } this.storeSession = MailboxSession.OpenAsTransport(principal, deliveryFlags); }); if (!isPublicFolderRecipient) { this.storeSession.ExTimeZone = ExTimeZone.CurrentTimeZone; } }
public void CreateSession(MailRecipient recipient, OpenTransportSessionFlags deliveryFlags, DeliverableItem item, ICollection <CultureInfo> recipientLanguages) { bool flag = this.IsPublicFolderRecipient(item); if (flag) { DeliveryItem.Diag.TracePfd(0L, "PFD ESD {0} Deliver to PF recipient {1} on MDB {2} with public folder GUID {3}", new object[] { 29595, item.LegacyExchangeDN, item.HomeMdbDN, this.context.MbxTransportMailItem.DatabaseGuid }); } else { DeliveryItem.Diag.TracePfd <int, string, string>(0L, "PFD ESD {0} Deliver to Mailbox recipient {1} on MDB {2}", 19611, item.LegacyExchangeDN, item.HomeMdbDN); } this.ValidateLegacyDN(recipient, item.LegacyExchangeDN); bool flag2 = false; try { this.CreateSessionInternal(recipient, deliveryFlags, item, recipientLanguages, false); } catch (MailboxUnavailableException ex) { if (-2146233088 != ex.ErrorCode) { throw; } DeliveryItem.Diag.TraceDebug <string>(0L, "Failed to open mailbox {0} with stripped principal. Will retry with complete principal", recipient.Email.ToString()); flag2 = true; } if (flag2) { this.CreateSessionInternal(recipient, deliveryFlags, item, recipientLanguages, true); } }