internal static bool CanProceedWithOrganizationTask(OrganizationIdParameter orgIdParam, IConfigurationSession session, OrganizationStatus[] ignorableFlagsOnStatusTimeout, Task.TaskErrorLoggingDelegate errorLogger)
        {
            bool result = false;
            ExchangeConfigurationUnit exchangeConfigUnitFromOrganizationId = OrganizationTaskHelper.GetExchangeConfigUnitFromOrganizationId(orgIdParam, session, errorLogger, true);

            if (ExchangeConfigurationUnit.IsOrganizationActive(exchangeConfigUnitFromOrganizationId.OrganizationStatus))
            {
                result = true;
            }
            else
            {
                DateTime?whenOrganizationStatusSet = exchangeConfigUnitFromOrganizationId.WhenOrganizationStatusSet;
                if (whenOrganizationStatusSet != null)
                {
                    DateTime value = whenOrganizationStatusSet.Value.ToUniversalTime();
                    if (DateTime.UtcNow.Subtract(value) > OrganizationTaskHelper.organizationStatusTimeout && ignorableFlagsOnStatusTimeout != null)
                    {
                        foreach (OrganizationStatus organizationStatus in ignorableFlagsOnStatusTimeout)
                        {
                            if (organizationStatus == exchangeConfigUnitFromOrganizationId.OrganizationStatus)
                            {
                                result = true;
                                break;
                            }
                        }
                    }
                }
            }
            return(result);
        }
Exemple #2
0
        protected override void InternalStateReset()
        {
            TaskLogger.LogEnter();
            base.InternalStateReset();
            OrganizationId organizationId = null;

            if (OrganizationId.ForestWideOrgId.Equals(base.ExecutingUserOrganizationId))
            {
                if (this.Identity == null)
                {
                    base.WriteError(new InvalidOperationException(Strings.ErrorNeedOrgIdentity), (ErrorCategory)1000, null);
                }
                else
                {
                    ADSessionSettings     sessionSettings = ADSessionSettings.FromOrganizationIdWithoutRbacScopes(base.RootOrgContainerId, base.CurrentOrganizationId, base.ExecutingUserOrganizationId, true);
                    IConfigurationSession tenantOrTopologyConfigurationSession = DirectorySessionFactory.Default.GetTenantOrTopologyConfigurationSession(base.DomainController, true, ConsistencyMode.PartiallyConsistent, null, sessionSettings, ConfigScopes.TenantSubTree, 109, "InternalStateReset", "f:\\15.00.1497\\sources\\dev\\Management\\src\\Management\\Deployment\\EnableConfigCustomizations.cs");
                    tenantOrTopologyConfigurationSession.UseConfigNC = false;
                    ADOrganizationalUnit oufromOrganizationId = OrganizationTaskHelper.GetOUFromOrganizationId(this.Identity, tenantOrTopologyConfigurationSession, new Task.TaskErrorLoggingDelegate(base.WriteError), true);
                    organizationId = oufromOrganizationId.OrganizationId;
                }
            }
            else
            {
                organizationId = base.ExecutingUserOrganizationId;
            }
            this.orgIdParam = new OrganizationIdParameter(organizationId.OrganizationalUnit);
            base.LoadTenantCU();
            TaskLogger.LogExit();
        }
 protected override void InternalProcessRecord()
 {
     TaskLogger.LogEnter();
     if (this.TenantCU.OrganizationStatus == OrganizationStatus.PendingAcceptedDomainAddition || this.TenantCU.OrganizationStatus == OrganizationStatus.PendingAcceptedDomainRemoval)
     {
         OrganizationTaskHelper.SetOrganizationStatus(base.Session, this.TenantCU, OrganizationStatus.Active);
     }
     try
     {
         base.InternalProcessRecord();
     }
     catch (Exception)
     {
         this.CleanupSecondaryDomain();
         throw;
     }
     if (!base.HasErrors)
     {
         AcceptedDomain acceptedDomain = OrganizationTaskHelper.GetAcceptedDomain(AcceptedDomainIdParameter.Parse(this.Name), base.Session, new Task.TaskErrorLoggingDelegate(base.WriteError), true);
         base.WriteObject(acceptedDomain);
     }
     else
     {
         this.CleanupSecondaryDomain();
     }
     TaskLogger.LogExit();
 }
 internal static OrganizationId ResolveOrganization(Task task, OrganizationIdParameter organization, ADObjectId rootOrgContainerId, LocalizedString cannotResolveOrganizationMessage)
 {
     if (organization != null)
     {
         ADSessionSettings     sessionSettings = ADSessionSettings.FromOrganizationIdWithoutRbacScopes(rootOrgContainerId, task.CurrentOrganizationId, task.ExecutingUserOrganizationId, true);
         IConfigurationSession tenantOrTopologyConfigurationSession = DirectorySessionFactory.Default.GetTenantOrTopologyConfigurationSession(ConsistencyMode.PartiallyConsistent, ADSessionSettings.RescopeToSubtree(sessionSettings), 371, "ResolveOrganization", "f:\\15.00.1497\\sources\\dev\\Management\\src\\Management\\Deployment\\OrganizationTaskHelper.cs");
         tenantOrTopologyConfigurationSession.UseConfigNC = false;
         ADOrganizationalUnit oufromOrganizationId = OrganizationTaskHelper.GetOUFromOrganizationId(organization, tenantOrTopologyConfigurationSession, new Task.TaskErrorLoggingDelegate(task.WriteError), true);
         if (oufromOrganizationId == null)
         {
             task.WriteError(new ArgumentException(cannotResolveOrganizationMessage), ErrorCategory.InvalidOperation, null);
             return(null);
         }
         return(oufromOrganizationId.OrganizationId);
     }
     else
     {
         if (task.CurrentOrganizationId == OrganizationId.ForestWideOrgId)
         {
             task.WriteError(new ArgumentException(cannotResolveOrganizationMessage), ErrorCategory.InvalidOperation, null);
             return(null);
         }
         return(task.CurrentOrganizationId);
     }
 }
 protected void LoadTenantCU()
 {
     this.tenantCU = OrganizationTaskHelper.GetExchangeConfigUnitFromOrganizationId(this.orgIdParam, base.Session, new Task.TaskErrorLoggingDelegate(base.WriteError), true);
     if (this.tenantCU != null)
     {
         base.CurrentOrganizationId = this.tenantCU.OrganizationId;
     }
 }
        private void CheckForDuplicateExistingDomain()
        {
            AcceptedDomain acceptedDomain = OrganizationTaskHelper.GetAcceptedDomain(AcceptedDomainIdParameter.Parse(this.Name), base.Session, new Task.TaskErrorLoggingDelegate(base.WriteError), false);

            if (acceptedDomain != null)
            {
                base.WriteError(new ManagementObjectAlreadyExistsException(Strings.ErrorAcceptedDomainExists(this.Name)), ErrorCategory.ResourceExists, null);
            }
        }
 protected override void InternalValidate()
 {
     TaskLogger.LogEnter();
     base.InternalValidate();
     this.acceptedDomain      = OrganizationTaskHelper.GetAcceptedDomain(this.Identity, base.Session, new Task.TaskErrorLoggingDelegate(base.WriteError), true);
     this.organizationIdParam = new OrganizationIdParameter(this.acceptedDomain.OrganizationId);
     if (!OrganizationTaskHelper.CanProceedWithOrganizationTask(this.organizationIdParam, base.Session, RemoveSecondaryDomainTask.IgnorableFlagsOnStatusTimeout, new Task.TaskErrorLoggingDelegate(base.WriteError)))
     {
         base.WriteError(new OrganizationPendingOperationException(Strings.ErrorCannotOperateOnOrgInCurrentState), ErrorCategory.InvalidOperation, null);
     }
     RemoveAcceptedDomain.CheckDomainForRemoval(this.acceptedDomain, new Task.TaskErrorLoggingDelegate(base.WriteError));
     TaskLogger.LogExit();
 }
        private OrganizationId ResolveCurrentOrganization()
        {
            base.Session = this.CreateSession();
            if (!OrganizationTaskHelper.CanProceedWithOrganizationTask(this.Organization, base.Session, AddSecondaryDomainTask.IgnorableFlagsOnStatusTimeout, new Task.TaskErrorLoggingDelegate(base.WriteError)))
            {
                base.WriteError(new OrganizationPendingOperationException(Strings.ErrorCannotOperateOnOrgInCurrentState), ErrorCategory.InvalidOperation, null);
            }
            base.Session.UseConfigNC = false;
            ADOrganizationalUnit oufromOrganizationId = OrganizationTaskHelper.GetOUFromOrganizationId(this.Organization, base.Session, new Task.TaskErrorLoggingDelegate(base.WriteError), true);

            base.Session.UseConfigNC = true;
            this.TenantCU            = OrganizationTaskHelper.GetExchangeConfigUnitFromOrganizationId(this.Organization, base.Session, new Task.TaskErrorLoggingDelegate(base.WriteError), true);
            base.Fields["TenantExternalDirectoryOrganizationId"] = this.TenantCU.ExternalDirectoryOrganizationId;
            return(oufromOrganizationId.OrganizationId);
        }
        private void CleanupSecondaryDomain()
        {
            AcceptedDomain acceptedDomain = OrganizationTaskHelper.GetAcceptedDomain(AcceptedDomainIdParameter.Parse(this.Name), base.Session, new Task.TaskErrorLoggingDelegate(base.WriteError), false);

            if (acceptedDomain != null)
            {
                try
                {
                    base.Session.Delete(acceptedDomain);
                }
                catch (Exception ex)
                {
                    this.WriteWarning(Strings.ErrorNonActiveOrganizationFound(ex.ToString()));
                }
            }
        }
        protected override void InternalBeginProcessing()
        {
            TaskLogger.LogEnter();
            LocalizedString empty = LocalizedString.Empty;

            this.Name = MailboxTaskHelper.GetNameOfAcceptableLengthForMultiTenantMode(this.Name, out empty);
            if (empty != LocalizedString.Empty)
            {
                this.WriteWarning(empty);
            }
            base.InternalBeginProcessing();
            if (this.Organization == null)
            {
                if (base.CurrentOrganizationId == OrganizationId.ForestWideOrgId)
                {
                    base.WriteError(new ArgumentException(Strings.ErrorOrganizationParameterRequired), ErrorCategory.InvalidOperation, null);
                }
                else
                {
                    this.Organization = new OrganizationIdParameter(base.CurrentOrganizationId.OrganizationalUnit.Name);
                }
            }
            base.CurrentOrganizationId = this.ResolveCurrentOrganization();
            OrganizationTaskHelper.ValidateParamString("Name", this.Name, new Task.TaskErrorLoggingDelegate(base.WriteError));
            if (base.Fields["AuthenticationType"] == null)
            {
                this.AuthenticationType = AuthenticationType.Managed;
            }
            if (base.Fields["LiveIdInstanceType"] == null)
            {
                this.LiveIdInstanceType = LiveIdInstanceType.Consumer;
            }
            base.Fields["OutBoundOnly"] = this.OutBoundOnly;
            base.Fields["MakeDefault"]  = this.MakeDefault;
            string value = string.Empty;

            if (this.Organization != null)
            {
                PartitionId partitionIdByAcceptedDomainName = ADAccountPartitionLocator.GetPartitionIdByAcceptedDomainName(this.Organization.RawIdentity);
                if (partitionIdByAcceptedDomainName != null)
                {
                    value = base.ServerSettings.PreferredGlobalCatalog(partitionIdByAcceptedDomainName.ForestFQDN);
                }
            }
            base.Fields["PreferredServer"] = value;
            TaskLogger.LogExit();
        }
        protected override void InternalProcessRecord()
        {
            TaskLogger.LogEnter();
            base.Fields["PrimaryOrganization"]     = this.acceptedDomain.OrganizationId.OrganizationalUnit.DistinguishedName;
            base.Fields["SecondarySmtpDomainName"] = this.acceptedDomain.DomainName.ToString();
            ExchangeConfigurationUnit exchangeConfigUnitFromOrganizationId = OrganizationTaskHelper.GetExchangeConfigUnitFromOrganizationId(this.organizationIdParam, base.Session, new Task.TaskErrorLoggingDelegate(base.WriteError), true);

            base.Fields["TenantExternalDirectoryOrganizationId"] = exchangeConfigUnitFromOrganizationId.ExternalDirectoryOrganizationId;
            IConfigurationSession session = (IConfigurationSession)TaskHelper.UnderscopeSessionToOrganization(base.Session, exchangeConfigUnitFromOrganizationId.OrganizationId, true);

            if (exchangeConfigUnitFromOrganizationId.OrganizationStatus == OrganizationStatus.PendingAcceptedDomainAddition || exchangeConfigUnitFromOrganizationId.OrganizationStatus == OrganizationStatus.PendingAcceptedDomainRemoval)
            {
                OrganizationTaskHelper.SetOrganizationStatus(this.organizationIdParam, session, OrganizationStatus.Active, new Task.TaskErrorLoggingDelegate(base.WriteError));
            }
            base.InternalProcessRecord();
            TaskLogger.LogExit();
        }
Exemple #12
0
 protected override void InternalValidate()
 {
     TaskLogger.LogEnter();
     base.InternalValidate();
     this.acceptedDomain = OrganizationTaskHelper.GetAcceptedDomain(this.Identity, base.Session, new Task.TaskErrorLoggingDelegate(base.WriteError), true);
     if (this.acceptedDomain.PendingRemoval)
     {
         base.WriteError(new CannotOperateOnAcceptedDomainPendingRemovalException(this.acceptedDomain.DomainName.ToString()), ErrorCategory.InvalidOperation, null);
     }
     this.orgOuDN             = this.acceptedDomain.OrganizationId.OrganizationalUnit.DistinguishedName;
     this.organizationIdParam = new OrganizationIdParameter(this.orgOuDN);
     if (!OrganizationTaskHelper.CanProceedWithOrganizationTask(this.organizationIdParam, base.Session, SetSecondaryDomainTask.IgnorableFlagsOnStatusTimeout, new Task.TaskErrorLoggingDelegate(base.WriteError)))
     {
         base.WriteError(new OrganizationPendingOperationException(Strings.ErrorCannotOperateOnOrgInCurrentState), ErrorCategory.InvalidOperation, null);
     }
     TaskLogger.LogExit();
 }
        private void CheckForDuplicateExistingOrganization()
        {
            ITenantConfigurationSession tenantConfigurationSession = this.WritableAllTenantsSessionForPartition(this.partition);
            ADObjectId           childId = tenantConfigurationSession.GetHostedOrganizationsRoot().GetChildId("OU", this.Name);
            ADOrganizationalUnit oufromOrganizationId = OrganizationTaskHelper.GetOUFromOrganizationId(new OrganizationIdParameter(childId), tenantConfigurationSession, null, false);

            if (oufromOrganizationId == null)
            {
                this.CleanupOrganization(this.partition);
                return;
            }
            if (OrganizationTaskHelper.CanProceedWithOrganizationTask(new OrganizationIdParameter(this.Name), tenantConfigurationSession, NewOrganizationTask.ignorableFlagsOnStatusTimeout, new Task.TaskErrorLoggingDelegate(base.WriteError)))
            {
                this.CleanupOrganization(this.partition);
                return;
            }
            base.WriteError(new OrganizationPendingOperationException(Strings.ErrorDuplicateNonActiveOrganizationExists(this.Name)), ErrorCategory.InvalidArgument, null);
        }
Exemple #14
0
 protected override void InternalValidate()
 {
     base.InternalValidate();
     if (this.DataObject.IsModified(ExchangeConfigurationUnitSchema.DirSyncServiceInstance) && !string.IsNullOrEmpty(this.DataObject.DirSyncServiceInstance) && !ServiceInstanceId.IsValidServiceInstanceId(this.DataObject.DirSyncServiceInstance))
     {
         base.WriteError(new InvalidServiceInstanceIdException(this.DataObject.DirSyncServiceInstance), ExchangeErrorCategory.Client, null);
     }
     if (this.DataObject.IsChanged(OrganizationSchema.SupportedSharedConfigurations) && !this.RemoveSharedConfigurations)
     {
         foreach (ExchangeConfigurationUnit exchangeConfigurationUnit in this.SharedConfigurationUnits)
         {
             if (exchangeConfigurationUnit.SharedConfigurationInfo == null)
             {
                 base.WriteError(new SharedConfigurationValidationException(Strings.SharedConfigurationInfoNotPresent(exchangeConfigurationUnit.Identity.ToString())), ExchangeErrorCategory.Client, null);
             }
             ServicePlanConfiguration instance = ServicePlanConfiguration.GetInstance();
             if (!exchangeConfigurationUnit.ProgramId.Equals(this.DataObject.ProgramId, StringComparison.OrdinalIgnoreCase) || (!this.IsHydratedOfferIdMatched(this.DataObject.ProgramId, this.DataObject.OfferId, exchangeConfigurationUnit, instance) && !this.IsPilotOfferIdMatched(this.DataObject.ProgramId, this.DataObject.OfferId, exchangeConfigurationUnit, instance) && !this.IsHydratedPilotOfferIdMatched(this.DataObject.ProgramId, this.DataObject.OfferId, exchangeConfigurationUnit, instance)))
             {
                 base.WriteError(new SharedConfigurationValidationException(Strings.OfferIdMatchError(this.Identity.ToString(), this.DataObject.ProgramId, this.DataObject.OfferId, exchangeConfigurationUnit.Identity.ToString(), exchangeConfigurationUnit.ProgramId, exchangeConfigurationUnit.OfferId)), ExchangeErrorCategory.Client, null);
             }
             if (!exchangeConfigurationUnit.EnableAsSharedConfiguration)
             {
                 base.WriteError(new SharedConfigurationValidationException(Strings.SharedConfigurationNotEnabled(this.Identity.ToString(), exchangeConfigurationUnit.Identity.ToString())), ExchangeErrorCategory.Client, null);
             }
         }
         if (this.DataObject.SharedConfigurationInfo != null)
         {
             base.WriteError(new SharedConfigurationValidationException(Strings.SharedConfigurationInfoExists(this.Identity.ToString(), this.DataObject.SharedConfigurationInfo.ToString())), ExchangeErrorCategory.Client, null);
         }
     }
     if (this.DataObject.IsChanged(OrganizationSchema.EnableAsSharedConfiguration) && !this.DataObject.EnableAsSharedConfiguration)
     {
         if (this.DataObject.SharedConfigurationInfo == null)
         {
             base.WriteError(new SharedConfigurationValidationException(Strings.SharedConfigurationInfoNotPresent(this.DataObject.Identity.ToString())), ExchangeErrorCategory.Client, null);
         }
         ExchangeConfigurationUnit[] array = OrganizationTaskHelper.FindSharedConfigurations(this.DataObject.SharedConfigurationInfo, this.DataObject.OrganizationId.PartitionId);
         if (array == null || array.Length < 2)
         {
             this.confirmLastSharedConfiguration = true;
         }
     }
 }
        internal static OrganizationStatus SetOrganizationStatus(OrganizationIdParameter orgIdParam, IConfigurationSession session, OrganizationStatus statusToSet, Task.TaskErrorLoggingDelegate errorLogger)
        {
            ExchangeConfigurationUnit exchangeConfigUnitFromOrganizationId = OrganizationTaskHelper.GetExchangeConfigUnitFromOrganizationId(orgIdParam, session, errorLogger, true);
            OrganizationStatus        organizationStatus = exchangeConfigUnitFromOrganizationId.OrganizationStatus;

            if (statusToSet != organizationStatus)
            {
                bool useConfigNC = session.UseConfigNC;
                try
                {
                    session.UseConfigNC = true;
                    exchangeConfigUnitFromOrganizationId.OrganizationStatus = statusToSet;
                    session.Save(exchangeConfigUnitFromOrganizationId);
                }
                finally
                {
                    session.UseConfigNC = useConfigNC;
                }
            }
            return(organizationStatus);
        }
Exemple #16
0
        protected override void InternalProcessRecord()
        {
            TaskLogger.LogEnter();
            int defaultValue = this.IsTestTopologyDomain() ? 100 : 0;
            int value        = RegistryReader.Instance.GetValue <int>(Registry.LocalMachine, "SOFTWARE\\Microsoft\\ExchangeServer\\v15\\ProvisioningThrottling", "MailboxCountAsyncRemovalSize", defaultValue);

            if (this.Async && this.GetRecipientCount(value + 1, false, true) > value)
            {
                OrganizationTaskHelper.SetOrganizationStatus(this.adSession, this.exchangeConfigUnit, OrganizationStatus.ReadyForRemoval);
            }
            else
            {
                base.Fields["TenantOrganizationFullPath"] = this.tenantOU.DistinguishedName;
                base.Fields["TenantCUFullPath"]           = this.tenantOU.ConfigurationUnit.Parent.DistinguishedName;
                base.Fields[RemoveOrganization.ExternalDirectoryOrganizationIdVarName] = this.exchangeConfigUnit.ExternalDirectoryOrganizationId;
                if (this.exchangeConfigUnit.OrganizationStatus != OrganizationStatus.PendingRemoval)
                {
                    OrganizationTaskHelper.SetOrganizationStatus(this.adSession, this.exchangeConfigUnit, OrganizationStatus.PendingRemoval);
                }
                base.InternalProcessRecord();
            }
            TaskLogger.LogExit();
        }
        internal static OrganizationStatus GetOrganizationStatus(OrganizationIdParameter orgIdParam, IConfigurationSession session, Task.TaskErrorLoggingDelegate errorLogger)
        {
            ExchangeConfigurationUnit exchangeConfigUnitFromOrganizationId = OrganizationTaskHelper.GetExchangeConfigUnitFromOrganizationId(orgIdParam, session, errorLogger, true);

            return(exchangeConfigUnitFromOrganizationId.OrganizationStatus);
        }
        protected override void InternalBeginProcessing()
        {
            TaskLogger.LogEnter();
            if (this.nameWarning != LocalizedString.Empty)
            {
                this.WriteWarning(this.nameWarning);
            }
            base.InternalBeginProcessing();
            if (this.Administrator != null)
            {
                OrganizationTaskHelper.ValidateParamString("Administrator", this.Administrator.ToString(), new Task.TaskErrorLoggingDelegate(base.WriteError));
            }
            if (this.AdministratorNetID != null)
            {
                OrganizationTaskHelper.ValidateParamString("AdministratorNetID", this.AdministratorNetID.ToString(), new Task.TaskErrorLoggingDelegate(base.WriteError));
            }
            if (this.AdministratorNetID != null && this.Administrator != null && this.Administrator.NetId != null && !this.AdministratorNetID.Equals(this.Administrator.NetId))
            {
                base.WriteError(new RecipientTaskException(Strings.ErrorNetIDValuesDoNotMatch(this.AdministratorNetID.ToString(), this.Administrator.NetId.ToString())), ErrorCategory.InvalidArgument, null);
            }
            if (this.AdministratorNetID != null && this.Administrator == null)
            {
                this.Administrator = new WindowsLiveId(this.AdministratorNetID.ToString());
            }
            if (base.Fields.IsModified("TenantDirSyncServiceInstance") && !string.IsNullOrEmpty(this.DirSyncServiceInstance) && !ServiceInstanceId.IsValidServiceInstanceId(this.DirSyncServiceInstance))
            {
                base.WriteError(new InvalidServiceInstanceIdException(this.DirSyncServiceInstance), ExchangeErrorCategory.Client, null);
            }
            if (this.ServicePlanConfig.IsPilotOffer(this.ProgramId, this.OfferId) && !this.CreateSharedConfiguration)
            {
                base.WriteError(new ArgumentException(Strings.ErrorPilotServicePlanCanBeUsedToCreateSharedOrgsOnly(this.ProgramId, this.OfferId)), (ErrorCategory)1000, null);
            }
            Exception ex   = null;
            string    text = null;

            if (base.Fields["TenantExternalDirectoryOrganizationId"] == null && !this.CreateSharedConfiguration)
            {
                base.Fields["TenantExternalDirectoryOrganizationId"] = Guid.NewGuid();
            }
            try
            {
                bool flag = this.ServicePlanConfig.TryGetHydratedOfferId(this.ProgramId, this.OfferId, out text);
                if (!this.CreateSharedConfiguration && this.Name == null)
                {
                    base.WriteError(new ArgumentException(Strings.ErrorNameNotSet), (ErrorCategory)1000, null);
                }
                this.partition = ((this.AccountPartition != null) ? NewOrganizationTask.ResolvePartitionId(this.AccountPartition, new Task.TaskErrorLoggingDelegate(base.WriteError)) : NewOrganizationTask.ChoosePartition(this.Name, this.CreateSharedConfiguration, new Task.TaskErrorLoggingDelegate(base.WriteError)));
                if (this.CreateSharedConfiguration && flag)
                {
                    this.OfferId         = text;
                    this.shouldCreateSCT = NewOrganizationTask.ShouldCreateSharedConfiguration(this.ProgramId, this.OfferId, this.partition, out this.sctConfigUnit);
                }
                string text2 = this.ServicePlanConfig.ResolveServicePlanName(this.ProgramId, this.OfferId);
                this.servicePlanSettings = this.ServicePlanConfig.GetServicePlanSettings(text2);
                bool flag2 = this.ServicePlanConfig.IsTemplateTenantServicePlan(this.servicePlanSettings);
                if (flag2)
                {
                    this.shouldCreateSCT = NewOrganizationTask.ShouldCreateTenantTemplate(this.ProgramId, this.OfferId, this.partition, out this.sctConfigUnit);
                }
                if (this.CreateSharedConfiguration)
                {
                    if (!this.shouldCreateSCT)
                    {
                        this.WriteWarning(Strings.WarningSharedConfigurationAlreadyExists(this.ProgramId, this.OfferId));
                        return;
                    }
                    if (string.IsNullOrEmpty(this.Name))
                    {
                        this.Name = (flag2 ? TemplateTenantConfiguration.CreateSharedConfigurationName(this.ProgramId, this.OfferId) : SharedConfiguration.CreateSharedConfigurationName(this.ProgramId, this.OfferId));
                    }
                    if (this.DomainName == null)
                    {
                        this.DomainName = (flag2 ? TemplateTenantConfiguration.CreateSharedConfigurationDomainName(this.Name) : SharedConfiguration.CreateSharedConfigurationDomainName(this.Name));
                    }
                }
                OrganizationTaskHelper.ValidateParamString("Name", this.Name, new Task.TaskErrorLoggingDelegate(base.WriteError), true);
                ADOrganizationalUnit adorganizationalUnit = new ADOrganizationalUnit();
                adorganizationalUnit[ADObjectSchema.Name] = this.Name;
                base.InternalIsSharedConfigServicePlan    = this.ServicePlanConfig.IsSharedConfigurationAllowedForServicePlan(this.servicePlanSettings);
                if (this.CreateSharedConfiguration && !base.InternalIsSharedConfigServicePlan && !this.ServicePlanConfig.IsHydratedOffer(text2))
                {
                    base.WriteError(new SharedConfigurationValidationException(Strings.ErrorServicePlanDoesntAllowSharedConfiguration(this.ProgramId, this.OfferId)), (ErrorCategory)1000, null);
                }
                else if (!flag && base.InternalIsSharedConfigServicePlan)
                {
                    text = this.OfferId;
                }
                if (this.CreateSharedConfiguration)
                {
                    base.InternalCreateSharedConfiguration = true;
                }
                else if (!this.CreateSharedConfiguration && base.InternalIsSharedConfigServicePlan)
                {
                    SharedConfigurationInfo sharedConfigurationInfo = SharedConfigurationInfo.FromInstalledVersion(this.ProgramId, text);
                    base.InternalSharedConfigurationId = SharedConfiguration.FindOneSharedConfigurationId(sharedConfigurationInfo, this.partition);
                    if (base.InternalSharedConfigurationId == null)
                    {
                        base.WriteError(new SharedConfigurationValidationException(Strings.ErrorSharedConfigurationNotFound(this.ProgramId, text, sharedConfigurationInfo.CurrentVersion.ToString())), (ErrorCategory)1000, null);
                    }
                    base.InternalCreateSharedConfiguration = false;
                }
                List <ValidationError> list = new List <ValidationError>();
                list.AddRange(ServicePlan.ValidateFileSchema(text2));
                list.AddRange(this.servicePlanSettings.Validate());
                if (list.Count != 0)
                {
                    ex = new ArgumentException(Strings.ErrorServicePlanInconsistent(text2, this.ProgramId, this.OfferId, ValidationError.CombineErrorDescriptions(list)));
                }
            }
            catch (ArgumentException ex2)
            {
                ex = ex2;
            }
            catch (IOException ex3)
            {
                ex = ex3;
            }
            if (ex != null)
            {
                base.WriteError(ex, ErrorCategory.InvalidArgument, null);
            }
            base.InternalLocalStaticConfigEnabled      = (!this.servicePlanSettings.Organization.AdvancedHydrateableObjectsSharedEnabled || this.CreateSharedConfiguration);
            base.InternalLocalHydrateableConfigEnabled = (!this.servicePlanSettings.Organization.CommonHydrateableObjectsSharedEnabled || this.CreateSharedConfiguration);
            TaskLogger.LogExit();
        }
 internal static void ValidateParamString(string paramName, string value, Task.TaskErrorLoggingDelegate errorLogger)
 {
     OrganizationTaskHelper.ValidateParamString(paramName, value, errorLogger, false);
 }
Exemple #20
0
        protected override void InternalValidate()
        {
            TaskLogger.LogEnter();
            base.InternalValidate();
            OrganizationId organizationId = OrganizationTaskHelper.ResolveOrganization(this, this.Identity, base.RootOrgContainerId, Strings.ErrorOrganizationIdentityRequired);

            if (this.Identity == null)
            {
                this.Identity = new OrganizationIdParameter(organizationId.OrganizationalUnit.Name);
            }
            ADSessionSettings sessionSettings = ADSessionSettings.FromAllTenantsPartitionId(organizationId.PartitionId);

            this.adSession = DirectorySessionFactory.Default.CreateTenantConfigurationSession((base.ServerSettings == null) ? null : base.ServerSettings.PreferredGlobalCatalog(organizationId.PartitionId.ForestFQDN), false, ConsistencyMode.PartiallyConsistent, sessionSettings, 262, "InternalValidate", "f:\\15.00.1497\\sources\\dev\\Management\\src\\Management\\Deployment\\RemoveOrganization.cs");
            this.tenantOU  = OrganizationTaskHelper.GetOUFromOrganizationId(this.Identity, this.adSession, new Task.TaskErrorLoggingDelegate(base.WriteError), false);
            if (this.tenantOU == null)
            {
                base.WriteError(new OrganizationDoesNotExistException(Strings.ErrorOrganizationNotFound(this.Identity.ToString())), ErrorCategory.InvalidArgument, null);
            }
            this.adSession.UseConfigNC = true;
            this.exchangeConfigUnit    = this.adSession.Read <ExchangeConfigurationUnit>(this.tenantOU.ConfigurationUnit);
            if (!OrganizationTaskHelper.CanProceedWithOrganizationTask(this.Identity, this.adSession, RemoveOrganization.ignorableFlagsOnStatusTimeout, new Task.TaskErrorLoggingDelegate(base.WriteError)))
            {
                base.WriteError(new OrganizationPendingOperationException(Strings.ErrorCannotRemoveNonActiveOrganization(this.Identity.ToString())), ErrorCategory.InvalidArgument, null);
            }
            ServicePlan servicePlanSettings = ServicePlanConfiguration.GetInstance().GetServicePlanSettings(this.exchangeConfigUnit.ProgramId, this.exchangeConfigUnit.OfferId);

            base.InternalLocalStaticConfigEnabled      = !servicePlanSettings.Organization.AdvancedHydrateableObjectsSharedEnabled;
            base.InternalLocalHydrateableConfigEnabled = !servicePlanSettings.Organization.CommonHydrateableObjectsSharedEnabled;
            base.InternalCreateSharedConfiguration     = (this.exchangeConfigUnit.SharedConfigurationInfo != null);
            ADSessionSettings sessionSettings2 = ADSessionSettings.FromOrganizationIdWithoutRbacScopes(base.RootOrgContainerId, this.tenantOU.OrganizationId, base.ExecutingUserOrganizationId, false);

            this.recipientSession = DirectorySessionFactory.Default.GetTenantOrRootOrgRecipientSession((base.ServerSettings == null) ? null : base.ServerSettings.PreferredGlobalCatalog(organizationId.PartitionId.ForestFQDN), true, ConsistencyMode.PartiallyConsistent, sessionSettings2, 314, "InternalValidate", "f:\\15.00.1497\\sources\\dev\\Management\\src\\Management\\Deployment\\RemoveOrganization.cs");
            IConfigurationSession    tenantOrTopologyConfigurationSession = DirectorySessionFactory.Default.GetTenantOrTopologyConfigurationSession((base.ServerSettings == null) ? null : base.ServerSettings.PreferredGlobalCatalog(organizationId.PartitionId.ForestFQDN), true, ConsistencyMode.PartiallyConsistent, sessionSettings2, 320, "InternalValidate", "f:\\15.00.1497\\sources\\dev\\Management\\src\\Management\\Deployment\\RemoveOrganization.cs");
            TransportConfigContainer transportConfigContainer             = tenantOrTopologyConfigurationSession.FindSingletonConfigurationObject <TransportConfigContainer>();

            if (transportConfigContainer != null)
            {
                this.organizationFederatedMailboxAlias = transportConfigContainer.OrganizationFederatedMailbox.Local;
            }
            if (!this.Force && this.GetUserMailboxCount(2) > 0)
            {
                base.WriteError(new OrganizationValidationException(Strings.RemoveOrganizationFailWithExistingMailboxes), ErrorCategory.InvalidOperation, this.Identity);
            }
            if (ExchangeConfigurationUnit.RelocationInProgress(this.exchangeConfigUnit))
            {
                base.WriteError(new OrganizationValidationException(Strings.RemoveOrganizationFailRelocationInProgress), (ErrorCategory)1000, this.Identity);
            }
            if (this.exchangeConfigUnit.EnableAsSharedConfiguration)
            {
                base.WriteError(new OrganizationValidationException(Strings.RemoveOrganizationFailWithoutSharedConfigurationParameter), (ErrorCategory)1000, this.Identity);
            }
            if (OrganizationTaskHelper.IsSharedConfigLinkedToOtherTenants(organizationId, this.adSession))
            {
                base.WriteError(new OrganizationValidationException(Strings.RemoveOrganizationFailWithSharedConfigurationBacklinks), (ErrorCategory)1000, this.Identity);
            }
            if (base.IsMSITTenant(organizationId))
            {
                this.authoritativeOnly = true;
            }
            TaskLogger.LogExit();
        }