protected override IConfigDataProvider CreateSession()
        {
            IRecipientSession tenantOrRootOrgRecipientSession = DirectorySessionFactory.Default.GetTenantOrRootOrgRecipientSession(base.DomainController, false, ConsistencyMode.PartiallyConsistent, base.SessionSettings, 149, "CreateSession", "f:\\15.00.1497\\sources\\dev\\Management\\src\\Management\\Mobility\\Aggregation\\SetSubscriptionBase.cs");

            if (this.Mailbox == null)
            {
                if (this.Identity != null && this.Identity.MailboxIdParameter != null)
                {
                    this.Mailbox = this.Identity.MailboxIdParameter;
                }
                else
                {
                    ADObjectId adObjectId;
                    if (!base.TryGetExecutingUserId(out adObjectId))
                    {
                        throw new ExecutingUserPropertyNotFoundException("executingUserid");
                    }
                    this.Mailbox = new MailboxIdParameter(adObjectId);
                }
            }
            ADUser            adUser  = (ADUser)base.GetDataObject <ADUser>(this.Mailbox, tenantOrRootOrgRecipientSession, null, new LocalizedString?(Strings.ErrorUserNotFound(this.Mailbox.ToString())), new LocalizedString?(Strings.ErrorUserNotUnique(this.Mailbox.ToString())));
            IRecipientSession session = AggregationTaskUtils.VerifyIsWithinWriteScopes(tenantOrRootOrgRecipientSession, adUser, new Task.TaskErrorLoggingDelegate(this.WriteDebugInfoAndError));
            AggregationSubscriptionDataProvider result = null;

            try
            {
                result = SubscriptionConfigDataProviderFactory.Instance.CreateSubscriptionDataProvider(this.AggregationType, AggregationTaskType.Set, session, adUser);
            }
            catch (MailboxFailureException exception)
            {
                this.WriteDebugInfoAndError(exception, ErrorCategory.InvalidArgument, this.Mailbox);
            }
            return(result);
        }
 protected override void InternalValidate()
 {
     TaskLogger.LogEnter();
     base.InternalValidate();
     AggregationTaskUtils.ValidateEmailAddress(base.DataSession, this.DataObject as PimSubscriptionProxy, new Task.TaskErrorLoggingDelegate(this.WriteDebugInfoAndError));
     TaskLogger.LogExit();
 }
Example #3
0
        protected override void ValidateWithDataObject(IConfigurable dataObject)
        {
            base.ValidateWithDataObject(dataObject);
            PopSubscriptionProxy    popSubscriptionProxy    = (PopSubscriptionProxy)dataObject;
            AuthenticationMechanism authenticationMechanism = base.Fields.IsModified("IncomingAuth") ? this.IncomingAuth : popSubscriptionProxy.IncomingAuthentication;
            SecureString            password = this.password ?? popSubscriptionProxy.Subscription.LogonPasswordSecured;
            string text = base.Fields.IsModified("IncomingUserName") ? base.IncomingUserName : popSubscriptionProxy.IncomingUserName;

            AggregationTaskUtils.ValidateUserName(text, new Task.TaskErrorLoggingDelegate(base.WriteDebugInfoAndError));
            if (authenticationMechanism == AuthenticationMechanism.Basic)
            {
                AggregationTaskUtils.ValidateUnicodeInfoOnUserNameAndPassword(text, password, new Task.TaskErrorLoggingDelegate(base.WriteDebugInfoAndError));
            }
            string text2 = base.Fields.IsModified("IncomingServer") ? base.IncomingServer : popSubscriptionProxy.IncomingServer;

            AggregationTaskUtils.ValidateIncomingServerLength(text2, new Task.TaskErrorLoggingDelegate(base.WriteDebugInfoAndError));
            if (!base.ShouldSkipAccountValidation())
            {
                bool leaveOnServer          = base.Fields.IsModified("LeaveOnServer") ? this.LeaveOnServer : popSubscriptionProxy.LeaveOnServer;
                int  port                   = base.Fields.IsModified("IncomingPort") ? base.IncomingPort : popSubscriptionProxy.IncomingPort;
                SecurityMechanism  security = base.Fields.IsModified("IncomingSecurity") ? this.IncomingSecurity : popSubscriptionProxy.IncomingSecurity;
                LocalizedException exception;
                if (!Pop3AutoProvision.ValidatePopSettings(leaveOnServer, popSubscriptionProxy.AggregationType == AggregationType.Mirrored, text2, port, text, password, authenticationMechanism, security, popSubscriptionProxy.Subscription.UserLegacyDN, CommonLoggingHelper.SyncLogSession, out exception))
                {
                    base.WriteDebugInfoAndError(exception, (ErrorCategory)1003, dataObject);
                }
            }
        }
 internal static void ValidateEmailAddress(IConfigDataProvider dataProvider, PimSubscriptionProxy subscriptionProxy, Task.TaskErrorLoggingDelegate taskErrorLoggingDelegate)
 {
     if (subscriptionProxy.AggregationType != AggregationType.Migration)
     {
         ADUser aduser = ((AggregationSubscriptionDataProvider)dataProvider).ADUser;
         string text   = subscriptionProxy.EmailAddress.ToString();
         if (AggregationTaskUtils.IsUserProxyAddress(aduser, text))
         {
             taskErrorLoggingDelegate(new LocalizedException(Strings.SubscriptionInvalidEmailAddress(text)), ErrorCategory.InvalidArgument, null);
         }
     }
 }
        protected override void ValidateWithDataObject(IConfigurable dataObject)
        {
            base.ValidateWithDataObject(dataObject);
            IMAPSubscriptionProxy imapsubscriptionProxy = dataObject as IMAPSubscriptionProxy;

            if (imapsubscriptionProxy == null)
            {
                throw new InvalidCastException("Expected dataObject of IMAPSubscriptionProxy type");
            }
            IMAPSubscriptionProxy imapsubscriptionProxy2 = IMAPSubscriptionProxy.ShallowCopy(imapsubscriptionProxy);

            if (base.Fields.IsModified("EmailAddress"))
            {
                imapsubscriptionProxy2.EmailAddress = base.EmailAddress;
            }
            if (base.Fields.IsModified("IncomingUserName"))
            {
                imapsubscriptionProxy2.IncomingUserName = base.IncomingUserName;
            }
            if (base.Fields.IsModified("IncomingServer"))
            {
                imapsubscriptionProxy2.IncomingServer = base.IncomingServer;
            }
            if (base.Fields.IsModified("IncomingPort"))
            {
                imapsubscriptionProxy2.IncomingPort = base.IncomingPort;
            }
            if (base.Fields.IsModified("IncomingAuth"))
            {
                imapsubscriptionProxy2.IncomingAuthentication = this.IncomingAuth;
            }
            if (base.Fields.IsModified("IncomingSecurity"))
            {
                imapsubscriptionProxy2.IncomingSecurity = this.IncomingSecurity;
            }
            AggregationTaskUtils.ValidateUserName(imapsubscriptionProxy2.IncomingUserName, new Task.TaskErrorLoggingDelegate(base.WriteDebugInfoAndError));
            SecureString password = this.password ?? imapsubscriptionProxy.Subscription.LogonPasswordSecured;

            if (imapsubscriptionProxy2.IncomingAuthentication == IMAPAuthenticationMechanism.Basic)
            {
                AggregationTaskUtils.ValidateUnicodeInfoOnUserNameAndPassword(imapsubscriptionProxy2.IncomingUserName, password, new Task.TaskErrorLoggingDelegate(base.WriteDebugInfoAndError));
            }
            AggregationTaskUtils.ValidateIncomingServerLength(imapsubscriptionProxy2.IncomingServer, new Task.TaskErrorLoggingDelegate(base.WriteDebugInfoAndError));
            bool      skipAccountVerification = base.ShouldSkipAccountValidation();
            Exception ex = NewImapSubscription.ValidateSubscription(imapsubscriptionProxy2, password, skipAccountVerification);

            if (ex != null)
            {
                base.WriteDebugInfoAndError(ex, (ErrorCategory)1003, imapsubscriptionProxy2);
            }
        }
Example #6
0
        protected override void InternalBeginProcessing()
        {
            TaskLogger.LogEnter();
            base.InternalBeginProcessing();
            PopSubscriptionProxy dataObject = this.DataObject;

            if (dataObject.IncomingAuthentication == AuthenticationMechanism.Basic)
            {
                AggregationTaskUtils.ValidateUnicodeInfoOnUserNameAndPassword(dataObject.IncomingUserName, this.password, new Task.TaskErrorLoggingDelegate(base.WriteDebugInfoAndError));
            }
            AggregationTaskUtils.ValidateIncomingServerLength(dataObject.IncomingServer, new Task.TaskErrorLoggingDelegate(base.WriteDebugInfoAndError));
            base.WriteDebugInfo();
            TaskLogger.LogExit();
        }
        protected override IConfigurable PrepareDataObject()
        {
            IConfigurable configurable = base.PrepareDataObject();

            if (this.ValidateSecret == null && this.ResendVerification == false)
            {
                return(configurable);
            }
            PimSubscriptionProxy pimSubscriptionProxy        = (PimSubscriptionProxy)configurable;
            AggregationSubscriptionDataProvider dataProvider = (AggregationSubscriptionDataProvider)base.DataSession;

            AggregationTaskUtils.ProcessSendAsSpecificParameters(pimSubscriptionProxy, this.ValidateSecret, this.ResendVerification, dataProvider, new Task.TaskErrorLoggingDelegate(base.WriteDebugInfoAndError));
            base.WriteDebugInfo();
            return(pimSubscriptionProxy);
        }
Example #8
0
        protected override IConfigDataProvider CreateSession()
        {
            ADSessionSettings sessionSettings = base.SessionSettings;
            IRecipientSession tenantOrRootOrgRecipientSession = DirectorySessionFactory.Default.GetTenantOrRootOrgRecipientSession(base.DomainController, false, ConsistencyMode.IgnoreInvalid, sessionSettings, 58, "CreateSession", "f:\\15.00.1497\\sources\\dev\\Management\\src\\Management\\Mobility\\Aggregation\\SetRemoteAccountSyncCache.cs");
            string            idStringValue    = this.Identity.ToString();
            ADUser            aduser           = (ADUser)base.GetDataObject <ADUser>(this.Identity.MailboxId, tenantOrRootOrgRecipientSession, null, new LocalizedString?(Strings.ErrorUserNotFound(idStringValue)), new LocalizedString?(Strings.ErrorUserNotUnique(idStringValue)));
            IRecipientSession recipientSession = AggregationTaskUtils.VerifyIsWithinWriteScopes(tenantOrRootOrgRecipientSession, aduser, new Task.TaskErrorLoggingDelegate(this.WriteDebugInfoAndError));

            try
            {
                this.userPrincipal = ExchangePrincipal.FromLegacyDN(recipientSession.SessionSettings, aduser.LegacyExchangeDN, RemotingOptions.AllowCrossSite);
            }
            catch (ObjectNotFoundException exception)
            {
                base.WriteError(exception, ErrorCategory.InvalidArgument, this.Identity.MailboxId);
            }
            return(new CacheDataProvider(SubscriptionCacheAction.Fix, this.userPrincipal));
        }
        protected override void InternalBeginProcessing()
        {
            TaskLogger.LogEnter();
            base.InternalBeginProcessing();
            IMAPSubscriptionProxy dataObject = this.DataObject;

            if (dataObject.IncomingAuthentication == IMAPAuthenticationMechanism.Basic)
            {
                AggregationTaskUtils.ValidateUnicodeInfoOnUserNameAndPassword(dataObject.IncomingUserName, this.password, new Task.TaskErrorLoggingDelegate(base.WriteDebugInfoAndError));
            }
            AggregationTaskUtils.ValidateIncomingServerLength(dataObject.IncomingServer, new Task.TaskErrorLoggingDelegate(base.WriteDebugInfoAndError));
            Exception ex = NewImapSubscription.ValidateSubscription(dataObject, this.password, this.Force);

            if (ex != null)
            {
                base.WriteDebugInfoAndError(ex, (ErrorCategory)1003, this.DataObject);
            }
            this.DataObject.SetPassword(this.password);
            base.WriteDebugInfo();
            TaskLogger.LogExit();
        }
Example #10
0
        protected override IConfigDataProvider CreateSession()
        {
            IRecipientSession  tenantOrRootOrgRecipientSession = DirectorySessionFactory.Default.GetTenantOrRootOrgRecipientSession(base.DomainController, false, ConsistencyMode.PartiallyConsistent, base.SessionSettings, 82, "CreateSession", "f:\\15.00.1497\\sources\\dev\\Management\\src\\Management\\Mobility\\Aggregation\\RemoveSubscriptionBase.cs");
            MailboxIdParameter mailboxIdParameter      = this.GetMailboxIdParameter();
            ADUser             adUser                  = (ADUser)base.GetDataObject <ADUser>(mailboxIdParameter, tenantOrRootOrgRecipientSession, null, new LocalizedString?(Strings.ErrorUserNotFound(mailboxIdParameter.ToString())), new LocalizedString?(Strings.ErrorUserNotUnique(mailboxIdParameter.ToString())));
            IRecipientSession  session                 = AggregationTaskUtils.VerifyIsWithinWriteScopes(tenantOrRootOrgRecipientSession, adUser, new Task.TaskErrorLoggingDelegate(this.WriteDebugInfoAndError));
            AggregationSubscriptionDataProvider result = null;

            try
            {
                AggregationType aggregationType = this.AggregationType;
                if (this.Identity != null && this.Identity.AggregationType != null)
                {
                    aggregationType = this.Identity.AggregationType.Value;
                }
                result = SubscriptionConfigDataProviderFactory.Instance.CreateSubscriptionDataProvider(aggregationType, AggregationTaskType.Remove, session, adUser);
            }
            catch (MailboxFailureException exception)
            {
                this.WriteDebugInfoAndError(exception, ErrorCategory.InvalidArgument, mailboxIdParameter);
            }
            return(result);
        }
        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);
            }
        }