protected void PostExchange(ADObjectId alContainer)
        {
            IConfigurationSession configurationSession = base.CreateGlobalWritableConfigSession();
            bool skipRangedAttributes = configurationSession.SkipRangedAttributes;

            configurationSession.SkipRangedAttributes = true;
            try
            {
                ExchangeConfigurationContainerWithAddressLists exchangeConfigurationContainerWithAddressLists = configurationSession.GetExchangeConfigurationContainerWithAddressLists();
                if (exchangeConfigurationContainerWithAddressLists.LinkedAddressBookRootAttributesPresent())
                {
                    exchangeConfigurationContainerWithAddressLists.AddressBookRoots2.Add(alContainer);
                }
                base.WriteVerbose(TaskVerboseStringHelper.GetSaveObjectVerboseString(exchangeConfigurationContainerWithAddressLists, configurationSession, typeof(ExchangeConfigurationContainer)));
                configurationSession.Save(exchangeConfigurationContainerWithAddressLists);
                exchangeConfigurationContainerWithAddressLists.ResetChangeTracking();
                if (!AddressBookUtilities.IsTenantAddressList(configurationSession, alContainer))
                {
                    exchangeConfigurationContainerWithAddressLists.AddressBookRoots.Add(alContainer);
                    base.WriteVerbose(TaskVerboseStringHelper.GetSaveObjectVerboseString(exchangeConfigurationContainerWithAddressLists, configurationSession, typeof(ExchangeConfigurationContainer)));
                    configurationSession.Save(exchangeConfigurationContainerWithAddressLists);
                }
            }
            finally
            {
                configurationSession.SkipRangedAttributes = skipRangedAttributes;
                base.WriteVerbose(TaskVerboseStringHelper.GetSourceVerboseString(configurationSession));
            }
        }
Exemple #2
0
        private void PostExchange(ADObjectId defaultGal)
        {
            IConfigurationSession configurationSession = base.CreateGlobalWritableConfigSession();
            bool skipRangedAttributes = configurationSession.SkipRangedAttributes;

            configurationSession.SkipRangedAttributes = true;
            try
            {
                ExchangeConfigurationContainerWithAddressLists exchangeConfigurationContainerWithAddressLists = configurationSession.GetExchangeConfigurationContainerWithAddressLists();
                if (exchangeConfigurationContainerWithAddressLists.LinkedAddressBookRootAttributesPresent())
                {
                    exchangeConfigurationContainerWithAddressLists.DefaultGlobalAddressList2.Add(defaultGal);
                }
                base.WriteVerbose(TaskVerboseStringHelper.GetSaveObjectVerboseString(exchangeConfigurationContainerWithAddressLists, configurationSession, typeof(ExchangeConfigurationContainer)));
                configurationSession.Save(exchangeConfigurationContainerWithAddressLists);
                exchangeConfigurationContainerWithAddressLists.ResetChangeTracking();
                if (!AddressBookUtilities.IsTenantAddressList(configurationSession, defaultGal))
                {
                    try
                    {
                        exchangeConfigurationContainerWithAddressLists.DefaultGlobalAddressList.Add(defaultGal);
                        base.WriteVerbose(TaskVerboseStringHelper.GetSaveObjectVerboseString(exchangeConfigurationContainerWithAddressLists, configurationSession, typeof(ExchangeConfigurationContainer)));
                        configurationSession.Save(exchangeConfigurationContainerWithAddressLists);
                    }
                    catch (AdminLimitExceededException innerException)
                    {
                        throw new ADOperationException(Strings.ErrorTooManyGALsCreated, innerException);
                    }
                }
            }
            finally
            {
                configurationSession.SkipRangedAttributes = skipRangedAttributes;
                base.WriteVerbose(TaskVerboseStringHelper.GetSourceVerboseString(configurationSession));
            }
        }
 private void PostNewAddressBookBase()
 {
     TaskLogger.LogEnter(new object[]
     {
         this.DataObject
     });
     if (VariantConfiguration.GetSnapshot(MachineSettingsContext.Local, null, null).CmdletInfra.GlobalAddressListAttrbutes.Enabled)
     {
         bool flag = true;
         IConfigurationSession tenantOrTopologyConfigurationSession = DirectorySessionFactory.Default.GetTenantOrTopologyConfigurationSession(base.DomainController, false, ConsistencyMode.PartiallyConsistent, ADSessionSettings.FromRootOrgScopeSet(), 625, "PostNewAddressBookBase", "f:\\15.00.1497\\sources\\dev\\Management\\src\\Management\\SystemConfigurationTasks\\AddressBook\\NewAddressBook.cs");
         bool skipRangedAttributes = tenantOrTopologyConfigurationSession.SkipRangedAttributes;
         tenantOrTopologyConfigurationSession.SkipRangedAttributes = false;
         try
         {
             ExchangeConfigurationContainerWithAddressLists exchangeConfigurationContainerWithAddressLists = tenantOrTopologyConfigurationSession.GetExchangeConfigurationContainerWithAddressLists();
             try
             {
                 if (exchangeConfigurationContainerWithAddressLists.LinkedAddressBookRootAttributesPresent())
                 {
                     AddressBookUtilities.SyncGlobalAddressLists(exchangeConfigurationContainerWithAddressLists, new Task.TaskWarningLoggingDelegate(this.WriteWarning));
                     exchangeConfigurationContainerWithAddressLists.DefaultGlobalAddressList2.Add(this.DataObject.Id);
                 }
                 tenantOrTopologyConfigurationSession.Save(exchangeConfigurationContainerWithAddressLists);
                 exchangeConfigurationContainerWithAddressLists.ResetChangeTracking();
                 flag = false;
                 if (!AddressBookUtilities.IsTenantAddressList(tenantOrTopologyConfigurationSession, this.DataObject.Id))
                 {
                     try
                     {
                         exchangeConfigurationContainerWithAddressLists.DefaultGlobalAddressList.Add(this.DataObject.Id);
                         tenantOrTopologyConfigurationSession.Save(exchangeConfigurationContainerWithAddressLists);
                     }
                     catch (AdminLimitExceededException innerException)
                     {
                         if (!exchangeConfigurationContainerWithAddressLists.LinkedAddressBookRootAttributesPresent())
                         {
                             throw new ADOperationException(Strings.ErrorTooManyGALsCreated, innerException);
                         }
                         this.WriteWarning(Strings.WarningTooManyLegacyGALsCreated);
                     }
                 }
             }
             catch (DataSourceTransientException exception)
             {
                 base.WriteError(exception, ErrorCategory.WriteError, this.DataObject.Id);
             }
         }
         finally
         {
             tenantOrTopologyConfigurationSession.SkipRangedAttributes = skipRangedAttributes;
             if (flag)
             {
                 try
                 {
                     base.DataSession.Delete(this.DataObject);
                 }
                 catch (DataSourceTransientException ex)
                 {
                     TaskLogger.Trace("Exception is raised in rollback action (deleting the new Global Address List object): {0}", new object[]
                     {
                         ex.ToString()
                     });
                 }
             }
         }
     }
     TaskLogger.LogExit();
 }