Exemplo n.º 1
0
        protected override IConfigurable PrepareDataObject()
        {
            TaskLogger.LogEnter();
            IConfigurable configurable = this.ResolveDataObject();

            if (base.HasErrors)
            {
                return(null);
            }
            this.ValidateWithDataObject(configurable);
            this.StampChangesOn(configurable);
            if (base.HasErrors)
            {
                return(null);
            }
            PimSubscriptionProxy pimSubscriptionProxy = (PimSubscriptionProxy)configurable;

            pimSubscriptionProxy.ObjectState = ObjectState.Changed;
            SendAsManager sendAsManager = new SendAsManager();

            sendAsManager.ResetVerificationEmailData(pimSubscriptionProxy.Subscription);
            pimSubscriptionProxy.SendAsCheckNeeded = this.SendAsCheckNeeded();
            TaskLogger.LogExit();
            return(pimSubscriptionProxy);
        }
Exemplo n.º 2
0
        private void PostSaveSendAsStateProcessing(PimAggregationSubscription subscription, DelayedEmailSender delayedEmailSender, MailboxSession mailboxSession)
        {
            SyncUtilities.ThrowIfArgumentNull("delayedEmailSender", delayedEmailSender);
            if (subscription.SendAsState == SendAsState.Enabled)
            {
                AggregationTaskUtils.EnableAlwaysShowFrom(this.primaryExchangePrincipal);
            }
            if (!delayedEmailSender.SendAttempted)
            {
                return;
            }
            IEmailSender  emailSender   = delayedEmailSender.TriggerDelayedSend();
            SendAsManager sendAsManager = new SendAsManager();

            sendAsManager.UpdateSubscriptionWithDiagnostics(subscription, emailSender);
            SubscriptionManager.SetSubscription(mailboxSession, subscription);
        }
        internal static void ProcessSendAsSpecificParameters(PimSubscriptionProxy subscriptionProxy, string validateSecret, bool resendVerification, AggregationSubscriptionDataProvider dataProvider, Task.TaskErrorLoggingDelegate taskErrorLoggingDelegate)
        {
            SyncUtilities.ThrowIfArgumentNull("subscriptionProxy", subscriptionProxy);
            SyncUtilities.ThrowIfArgumentNull("dataProvider", dataProvider);
            SyncUtilities.ThrowIfArgumentNull("taskErrorLoggingDelegate", taskErrorLoggingDelegate);
            SendAsManager sendAsManager = new SendAsManager();

            if (validateSecret != null)
            {
                if (sendAsManager.ValidateSharedSecret(subscriptionProxy.Subscription, validateSecret))
                {
                    AggregationTaskUtils.EnableAlwaysShowFrom(dataProvider.SubscriptionExchangePrincipal);
                }
                else
                {
                    taskErrorLoggingDelegate(new ValidateSecretFailureException(), (ErrorCategory)1003, subscriptionProxy);
                }
            }
            if (resendVerification)
            {
                IEmailSender emailSender = subscriptionProxy.Subscription.CreateEmailSenderFor(dataProvider.ADUser, dataProvider.SubscriptionExchangePrincipal);
                sendAsManager.ResendVerificationEmail(subscriptionProxy.Subscription, emailSender);
            }
        }
Exemplo n.º 4
0
 public static bool TryGetSendAsSubscription(MessageItem item, SendAsManager sendAsManager, out ISendAsSource subscription)
 {
     return(StoreProvider.StoreProviderInstance.TryGetSendAsSubscription(item, sendAsManager, out subscription));
 }
Exemplo n.º 5
0
        public bool TryGetSendAsSubscription(MessageItem item, SendAsManager sendAsManager, out ISendAsSource subscription)
        {
            subscription = null;
            MailboxSession mailboxSession = item.Session as MailboxSession;
            object         obj            = item.TryGetProperty(MessageItemSchema.SharingInstanceGuid);

            if (PropertyError.IsPropertyNotFound(obj))
            {
                if (mailboxSession != null && mailboxSession.MailboxOwner != null && mailboxSession.MailboxOwner.MailboxInfo.IsAggregated)
                {
                    TraceHelper.MapiStoreDriverSubmissionTracer.TracePass(TraceHelper.MessageProbeActivityId, 0L, "The message was submitted from an aggregated mailbox. There must be one associated send as subscription.");
                    bool flag;
                    if (!sendAsManager.TryGetSendAsSubscription(mailboxSession, out subscription, out flag))
                    {
                        TraceHelper.MapiStoreDriverSubmissionTracer.TraceFail(TraceHelper.MessageProbeActivityId, 0L, "Could not find a unique send as subscription.  Rejecting the message.");
                        if (flag)
                        {
                            throw new SmtpResponseException(AckReason.AmbiguousSubscription);
                        }
                        throw new SmtpResponseException(AckReason.SubscriptionNotFound);
                    }
                }
            }
            else
            {
                TraceHelper.MapiStoreDriverSubmissionTracer.TracePass(TraceHelper.MessageProbeActivityId, 0L, "The message has a subscription id on it. Subscription id: {0}", new object[]
                {
                    obj
                });
                if (mailboxSession == null)
                {
                    TraceHelper.MapiStoreDriverSubmissionTracer.TraceFail <Type>(TraceHelper.MessageProbeActivityId, 0L, "The session is not the right type. Actual type: {0}", item.Session.GetType());
                    throw new SmtpResponseException(AckReason.UnrecognizedSendAsMessage);
                }
                if (!sendAsManager.TryGetSendAsSubscription(item, mailboxSession, out subscription))
                {
                    TraceHelper.MapiStoreDriverSubmissionTracer.TraceFail(TraceHelper.MessageProbeActivityId, 0L, "The subscription could not be found. Rejecting the message. Subscription id: {0}", new object[]
                    {
                        obj
                    });
                    throw new SmtpResponseException(AckReason.SubscriptionNotFound);
                }
                if (!sendAsManager.IsSubscriptionEnabled(subscription))
                {
                    TraceHelper.MapiStoreDriverSubmissionTracer.TraceFail(TraceHelper.MessageProbeActivityId, 0L, "The subscription is not enabled. Rejecting the message. Subscription id: {0}", new object[]
                    {
                        obj
                    });
                    throw new SmtpResponseException(AckReason.SubscriptionDisabled);
                }
                if (!sendAsManager.IsSendAsEnabled(subscription))
                {
                    TraceHelper.MapiStoreDriverSubmissionTracer.TraceFail(TraceHelper.MessageProbeActivityId, 0L, "The subscription is not enabled for send as. Rejecting the message. Subscription id: {0}", new object[]
                    {
                        obj
                    });
                    throw new SmtpResponseException(AckReason.SubscriptionNotEnabledForSendAs);
                }
                if (!sendAsManager.IsValidSendAsMessage(subscription, item))
                {
                    TraceHelper.MapiStoreDriverSubmissionTracer.TraceFail(TraceHelper.MessageProbeActivityId, 0L, "The message does not have valid sent representing properties. Rejecting the message. Subscription id: {0}", new object[]
                    {
                        obj
                    });
                    throw new SmtpResponseException(AckReason.InvalidSendAsProperties);
                }
            }
            return(subscription != null);
        }