Example #1
0
        protected override void InternalProcessRecord()
        {
            OfflineAddressBook offlineAddressBook = null;

            if (this.DataObject.IsDefault)
            {
                offlineAddressBook = OfflineAddressBookTaskUtility.ResetOldDefaultOab(base.DataSession, new Task.TaskErrorLoggingDelegate(base.WriteError));
            }
            bool flag = false;

            try
            {
                base.InternalProcessRecord();
                flag = true;
            }
            finally
            {
                if (!flag && offlineAddressBook != null)
                {
                    offlineAddressBook.IsDefault = true;
                    try
                    {
                        base.DataSession.Save(offlineAddressBook);
                    }
                    catch (DataSourceTransientException exception)
                    {
                        this.WriteError(exception, ErrorCategory.WriteError, null, false);
                    }
                }
            }
        }
Example #2
0
        protected override IConfigurable PrepareDataObject()
        {
            this.DataObject = (OfflineAddressBook)base.PrepareDataObject();
            MultiValuedProperty <OfflineAddressBookVersion> multiValuedProperty = new MultiValuedProperty <OfflineAddressBookVersion>();

            multiValuedProperty.Add(OfflineAddressBookVersion.Version4);
            this.DataObject.Versions             = multiValuedProperty;
            this.DataObject.ConfiguredAttributes = OfflineAddressBookMapiProperty.DefaultOABPropertyList;
            this.DataObject.UpdateRawMapiAttributes(false);
            if (base.Fields.IsModified("GeneratingMailbox"))
            {
                this.DataObject.GeneratingMailbox = OfflineAddressBookTaskUtility.ValidateGeneratingMailbox(base.TenantGlobalCatalogSession, this.GeneratingMailbox, new OfflineAddressBookTaskUtility.GetUniqueObject(base.GetDataObject <ADUser>), this.DataObject, new Task.TaskWarningLoggingDelegate(this.WriteWarning), new Task.TaskErrorLoggingDelegate(base.WriteError));
            }
            this.DataObject.AddressLists = OfflineAddressBookTaskUtility.ValidateAddressBook(base.DataSession, this.AddressLists, new OfflineAddressBookTaskUtility.GetUniqueObject(base.GetDataObject <AddressBookBase>), this.DataObject, new Task.TaskErrorLoggingDelegate(base.WriteError));
            this.DataObject.PublicFolderDistributionEnabled = false;
            this.DataObject.PublicFolderDatabase            = null;
            if (this.VirtualDirectories != null && this.VirtualDirectories.Length != 0)
            {
                this.DataObject.VirtualDirectories = OfflineAddressBookTaskUtility.ValidateVirtualDirectory(base.GlobalConfigSession, this.VirtualDirectories, new OfflineAddressBookTaskUtility.GetUniqueObject(base.GetDataObject <ADOabVirtualDirectory>), this.DataObject, new Task.TaskErrorLoggingDelegate(base.WriteError));
            }
            if (base.Fields.IsModified("GlobalWebDistributionEnabled"))
            {
                this.DataObject.GlobalWebDistributionEnabled = this.GlobalWebDistributionEnabled;
            }
            if (base.Fields.IsModified("ShadowMailboxDistributionEnabled"))
            {
                this.DataObject.ShadowMailboxDistributionEnabled = this.ShadowMailboxDistributionEnabled;
            }
            this.DataObject.Server = ((IConfigurationSession)base.DataSession).GetOrgContainerId().GetDescendantId(this.DataObject.ParentPath);
            if (!this.DataObject.IsModified(OfflineAddressBookSchema.IsDefault) && ((IConfigurationSession)base.DataSession).Find <OfflineAddressBook>(null, QueryScope.SubTree, null, null, 1).Length == 0)
            {
                this.DataObject.IsDefault = true;
            }
            this.DataObject.SetId((IConfigurationSession)base.DataSession, base.Name);
            string parentLegacyDN = string.Format(CultureInfo.InvariantCulture, "{0}/cn=addrlists/cn=oabs", new object[]
            {
                ((IConfigurationSession)base.DataSession).GetOrgContainer().LegacyExchangeDN
            });

            this.DataObject[OfflineAddressBookSchema.ExchangeLegacyDN] = LegacyDN.GenerateLegacyDN(parentLegacyDN, this.DataObject, true, new LegacyDN.LegacyDNIsUnique(this.LegacyDNIsUnique));
            OfflineAddressBookTaskUtility.WarnForNoDistribution(this.DataObject, new Task.TaskWarningLoggingDelegate(this.WriteWarning));
            return(this.DataObject);
        }
Example #3
0
        protected override void InternalProcessRecord()
        {
            OfflineAddressBook offlineAddressBook = null;

            if (this.DataObject.IsChanged(OfflineAddressBookSchema.IsDefault) && this.DataObject.IsDefault)
            {
                offlineAddressBook = OfflineAddressBookTaskUtility.ResetOldDefaultOab(base.DataSession, new Task.TaskErrorLoggingDelegate(base.WriteError));
            }
            bool flag = false;

            try
            {
                base.InternalProcessRecord();
                flag = true;
                if (!this.isOriginalPfDistributionEnabled && this.isPresentPfDistributionEnabled)
                {
                    this.WriteWarning(Strings.DoNotMoveImmediately(this.DataObject.Name));
                    OfflineAddressBookTaskUtility.DoMaintenanceTask(this.publicFolderDatabase, base.DomainController, new Task.TaskWarningLoggingDelegate(this.WriteWarning));
                }
            }
            finally
            {
                if (!flag && offlineAddressBook != null)
                {
                    offlineAddressBook.IsDefault = true;
                    try
                    {
                        base.DataSession.Save(offlineAddressBook);
                    }
                    catch (DataSourceTransientException exception)
                    {
                        this.WriteError(exception, ErrorCategory.WriteError, null, false);
                    }
                }
            }
        }
        protected override IConfigurable PrepareDataObject()
        {
            TaskLogger.LogEnter();
            OfflineAddressBook offlineAddressBook = (OfflineAddressBook)base.PrepareDataObject();

            if (this.provisionedCurrentServer)
            {
                this.confirmationMessage = LocalizedString.Empty;
                TaskLogger.LogExit();
                return(offlineAddressBook);
            }
            if (this.targetServer == null)
            {
                this.targetServer = (Server)base.GetDataObject <Server>(this.Server, base.GlobalConfigSession, null, new LocalizedString?(Strings.ErrorServerNotFound(this.Server.ToString())), new LocalizedString?(Strings.ErrorServerNotUnique(this.Server.ToString())));
            }
            if (offlineAddressBook.IsE15OrLater())
            {
                this.WriteError(new InvalidOperationException(Strings.CannotMoveE15OrLaterOab), ErrorCategory.InvalidOperation, offlineAddressBook.Identity, true);
            }
            if (this.targetServer.IsE15OrLater)
            {
                this.WriteError(new InvalidOperationException(Strings.CannotMoveOabToE15OrLaterServer), ErrorCategory.InvalidOperation, offlineAddressBook.Identity, true);
            }
            bool flag = false;

            try
            {
                this.sourceServer = (Server)base.GetDataObject <Server>(new ServerIdParameter(offlineAddressBook.Server), base.GlobalConfigSession, null, new LocalizedString?(Strings.ErrorServerNotFound(offlineAddressBook.Server.Name.ToString())), new LocalizedString?(Strings.ErrorServerNotUnique(offlineAddressBook.Server.Name.ToString())));
            }
            catch (ArgumentNullException)
            {
                flag = true;
            }
            catch (ManagementObjectNotFoundException)
            {
                flag = true;
            }
            if (flag)
            {
                this.WriteWarning(Strings.WarningOABSourceServerDoesNotExist(offlineAddressBook.Server.Name));
            }
            if (this.sourceServer != null && this.targetServer.Guid == this.sourceServer.Guid)
            {
                base.WriteError(new InvalidOperationException(Strings.ErrorMovingOabAlreadyThere(this.Identity.ToString(), this.targetServer.Name.ToString())), ErrorCategory.InvalidOperation, offlineAddressBook.Identity);
            }
            if (this.targetServer.IsExchange2007OrLater)
            {
                if (!this.targetServer.IsMailboxServer)
                {
                    base.WriteError(new InvalidOperationException(Strings.ErrorMoveOabToNoMailboxServer(this.Server.ToString())), ErrorCategory.InvalidOperation, offlineAddressBook.Identity);
                }
                if (offlineAddressBook.Versions.Contains(OfflineAddressBookVersion.Version1))
                {
                    MultiValuedProperty <OfflineAddressBookVersion> multiValuedProperty = new MultiValuedProperty <OfflineAddressBookVersion>();
                    foreach (OfflineAddressBookVersion offlineAddressBookVersion in offlineAddressBook.Versions)
                    {
                        if (offlineAddressBookVersion != OfflineAddressBookVersion.Version1)
                        {
                            multiValuedProperty.Add(offlineAddressBookVersion);
                        }
                    }
                    offlineAddressBook.Versions = multiValuedProperty;
                }
                if (this.sourceServer == null)
                {
                    if (this.targetServer.IsE14OrLater)
                    {
                        offlineAddressBook.ExchangeVersion = ExchangeObjectVersion.Exchange2010;
                        if (offlineAddressBook.Versions.Contains(OfflineAddressBookVersion.Version4))
                        {
                            offlineAddressBook.ConfiguredAttributes = OfflineAddressBookMapiProperty.DefaultOABPropertyList;
                        }
                    }
                    else
                    {
                        this.ClearNewAttributesForOldExchange(offlineAddressBook, ExchangeObjectVersion.Exchange2007);
                        offlineAddressBook.ExchangeVersion = ExchangeObjectVersion.Exchange2007;
                    }
                    offlineAddressBook.MinAdminVersion     = new int?(offlineAddressBook.ExchangeVersion.ExchangeBuild.ToExchange2003FormatInt32());
                    offlineAddressBook.DiffRetentionPeriod = new Unlimited <int>?(OfflineAddressBook.DefaultDiffRetentionPeriod);
                }
                else if (this.targetServer.IsE14OrLater)
                {
                    if (!this.sourceServer.IsE14OrLater)
                    {
                        if (this.sourceServer.IsExchange2007OrLater)
                        {
                            offlineAddressBook.ExchangeVersion = ExchangeObjectVersion.Exchange2010;
                            offlineAddressBook.MinAdminVersion = new int?(offlineAddressBook.ExchangeVersion.ExchangeBuild.ToExchange2003FormatInt32());
                            if (offlineAddressBook.Versions.Contains(OfflineAddressBookVersion.Version4))
                            {
                                offlineAddressBook.ConfiguredAttributes = OfflineAddressBookMapiProperty.DefaultOABPropertyList;
                            }
                        }
                        else
                        {
                            offlineAddressBook.ExchangeVersion     = ExchangeObjectVersion.Exchange2010;
                            offlineAddressBook.MinAdminVersion     = new int?(offlineAddressBook.ExchangeVersion.ExchangeBuild.ToExchange2003FormatInt32());
                            offlineAddressBook.DiffRetentionPeriod = new Unlimited <int>?(OfflineAddressBook.DefaultDiffRetentionPeriod);
                            if (offlineAddressBook.Versions.Contains(OfflineAddressBookVersion.Version4))
                            {
                                offlineAddressBook.ConfiguredAttributes = OfflineAddressBookMapiProperty.DefaultOABPropertyList;
                            }
                        }
                    }
                }
                else if (this.sourceServer.IsE14OrLater)
                {
                    this.ClearNewAttributesForOldExchange(offlineAddressBook, ExchangeObjectVersion.Exchange2007);
                    offlineAddressBook.ExchangeVersion = ExchangeObjectVersion.Exchange2007;
                    offlineAddressBook.MinAdminVersion = new int?(offlineAddressBook.ExchangeVersion.ExchangeBuild.ToExchange2003FormatInt32());
                }
                else if (!this.sourceServer.IsExchange2007OrLater)
                {
                    offlineAddressBook.ExchangeVersion     = ExchangeObjectVersion.Exchange2007;
                    offlineAddressBook.MinAdminVersion     = new int?(offlineAddressBook.ExchangeVersion.ExchangeBuild.ToExchange2003FormatInt32());
                    offlineAddressBook.DiffRetentionPeriod = new Unlimited <int>?(OfflineAddressBook.DefaultDiffRetentionPeriod);
                }
            }
            else
            {
                if (this.targetServer.IsPreE12FrontEnd)
                {
                    base.WriteError(new InvalidOperationException(Strings.ErrorMoveOabToTiFrondEndServer), ErrorCategory.InvalidOperation, offlineAddressBook.Identity);
                }
                if (this.sourceServer != null && !this.sourceServer.IsExchange2007OrLater)
                {
                    base.WriteError(new InvalidOperationException(Strings.ErrorMoveOabBetweenTwoTiServers), ErrorCategory.InvalidOperation, offlineAddressBook.Identity);
                }
                if (offlineAddressBook.Versions.Contains(OfflineAddressBookVersion.Version4) && !this.targetServer.IsExchange2003Sp3OrLater && !OfflineAddressBookTaskUtility.IsKB922817InstalledOnServer(this.targetServer.Fqdn, new Task.TaskErrorLoggingDelegate(base.WriteError)))
                {
                    base.WriteError(new InvalidOperationException(Strings.ErrorMoveVersion4OabToTiServerWithoutSP3(offlineAddressBook.Identity.ToString())), ErrorCategory.InvalidOperation, offlineAddressBook.Identity);
                }
                if (offlineAddressBook.WebDistributionEnabled)
                {
                    base.WriteError(new InvalidOperationException(Strings.ErrorMoveWebDistributionEnabledOabToTiServer), ErrorCategory.InvalidOperation, offlineAddressBook.Identity);
                }
                if (!offlineAddressBook.PublicFolderDistributionEnabled)
                {
                    base.WriteError(new InvalidOperationException(Strings.ErrorMovePublicFolderDistributionDisabledOabToTiServer(this.Identity.ToString())), ErrorCategory.InvalidOperation, offlineAddressBook.Identity);
                }
                this.ClearNewAttributesForOldExchange(offlineAddressBook, ExchangeObjectVersion.Exchange2003);
                offlineAddressBook.DiffRetentionPeriod = new Unlimited <int>?(Unlimited <int> .UnlimitedValue);
                offlineAddressBook.MinAdminVersion     = null;
                offlineAddressBook.ExchangeVersion     = ExchangeObjectVersion.Exchange2003;
            }
            offlineAddressBook.Server = (ADObjectId)this.targetServer.Identity;
            if (this.targetServer.IsE14OrLater)
            {
                offlineAddressBook.LastTouchedTime = new DateTime?((DateTime)ExDateTime.Now);
            }
            if (!this.targetServer.IsE14OrLater && this.sourceServer != null && this.sourceServer.IsE14OrLater)
            {
                this.confirmationMessage = Strings.ConfirmationMessageMoveOfflineAddressBookE14ToLowerVersion(this.Identity.ToString(), this.Server.ToString());
            }
            else
            {
                this.confirmationMessage = Strings.ConfirmationMessageMoveOfflineAddressBook(this.Identity.ToString(), this.Server.ToString());
            }
            if (this.DataObject.IsModified(OfflineAddressBookSchema.ConfiguredAttributes))
            {
                this.DataObject.UpdateRawMapiAttributes(!this.targetServer.IsE14OrLater);
            }
            TaskLogger.LogExit();
            return(offlineAddressBook);
        }
Example #5
0
        protected override void StampChangesOn(IConfigurable dataObject)
        {
            bool flag = ((OfflineAddressBook)dataObject).Versions.Contains(OfflineAddressBookVersion.Version1);

            this.isOriginalPfDistributionEnabled = ((OfflineAddressBook)dataObject).PublicFolderDistributionEnabled;
            base.StampChangesOn(dataObject);
            bool flag2 = ((OfflineAddressBook)dataObject).Versions.Contains(OfflineAddressBookVersion.Version1);

            this.isPresentPfDistributionEnabled = ((OfflineAddressBook)dataObject).PublicFolderDistributionEnabled;
            OfflineAddressBook offlineAddressBook = (OfflineAddressBook)dataObject;

            for (int i = 0; i < SetOfflineAddressBookInternal.propertiesCannotBeSet.GetLength(0); i++)
            {
                if (offlineAddressBook.IsModified(SetOfflineAddressBookInternal.propertiesCannotBeSet[i, 0]))
                {
                    base.WriteError(new InvalidOperationException(Strings.ErrorSpecifiedPropertyCannotBeSet((SetOfflineAddressBookInternal.propertiesCannotBeSet[i, 1] ?? SetOfflineAddressBookInternal.propertiesCannotBeSet[i, 0]).ToString())), ErrorCategory.InvalidOperation, this.Identity);
                }
            }
            if (!flag && flag2)
            {
                base.WriteError(new InvalidOperationException(Strings.ErrorSetVersion1OfExchange12OAB), ErrorCategory.InvalidOperation, offlineAddressBook.Identity);
            }
            if (this.GeneratingMailbox != null)
            {
                if (offlineAddressBook.ExchangeVersion.IsOlderThan(ExchangeObjectVersion.Exchange2012))
                {
                    base.WriteError(new InvalidOperationException(Strings.ErrorLegacyOABDoesNotSupportLinkedMailbox), ErrorCategory.InvalidOperation, this.Identity);
                }
                offlineAddressBook.GeneratingMailbox = OfflineAddressBookTaskUtility.ValidateGeneratingMailbox(base.TenantGlobalCatalogSession, this.GeneratingMailbox, new OfflineAddressBookTaskUtility.GetUniqueObject(base.GetDataObject <ADUser>), offlineAddressBook, new Task.TaskWarningLoggingDelegate(this.WriteWarning), new Task.TaskErrorLoggingDelegate(base.WriteError));
            }
            if (this.AddressLists != null && this.AddressLists.Length > 0)
            {
                offlineAddressBook.AddressLists = OfflineAddressBookTaskUtility.ValidateAddressBook(base.DataSession, this.AddressLists, new OfflineAddressBookTaskUtility.GetUniqueObject(base.GetDataObject <AddressBookBase>), offlineAddressBook, new Task.TaskErrorLoggingDelegate(base.WriteError));
            }
            else if (offlineAddressBook.IsModified(OfflineAddressBookSchema.AddressLists))
            {
                List <AddressBookBaseIdParameter> list = new List <AddressBookBaseIdParameter>();
                if (offlineAddressBook.AddressLists != null && offlineAddressBook.AddressLists.Added.Length != 0)
                {
                    foreach (ADObjectId adObjectId in offlineAddressBook.AddressLists.Added)
                    {
                        list.Add(new AddressBookBaseIdParameter(adObjectId));
                    }
                    OfflineAddressBookTaskUtility.ValidateAddressBook(base.DataSession, list.ToArray(), new OfflineAddressBookTaskUtility.GetUniqueObject(base.GetDataObject <AddressBookBase>), offlineAddressBook, new Task.TaskErrorLoggingDelegate(base.WriteError));
                }
            }
            if (base.Fields.IsModified("VirtualDirectories"))
            {
                if (this.VirtualDirectories != null && this.VirtualDirectories.Length > 0)
                {
                    offlineAddressBook.VirtualDirectories = OfflineAddressBookTaskUtility.ValidateVirtualDirectory(base.GlobalConfigSession, this.VirtualDirectories, new OfflineAddressBookTaskUtility.GetUniqueObject(base.GetDataObject <ADOabVirtualDirectory>), offlineAddressBook, new Task.TaskErrorLoggingDelegate(base.WriteError));
                }
                else
                {
                    offlineAddressBook.VirtualDirectories = null;
                }
            }
            else if (offlineAddressBook.IsModified(OfflineAddressBookSchema.VirtualDirectories))
            {
                if (offlineAddressBook.VirtualDirectories != null && offlineAddressBook.VirtualDirectories.Added.Length > 0)
                {
                    List <VirtualDirectoryIdParameter> list2 = new List <VirtualDirectoryIdParameter>();
                    foreach (ADObjectId adObjectId2 in offlineAddressBook.VirtualDirectories.Added)
                    {
                        list2.Add(new VirtualDirectoryIdParameter(adObjectId2));
                    }
                    OfflineAddressBookTaskUtility.ValidateVirtualDirectory(base.GlobalConfigSession, list2.ToArray(), new OfflineAddressBookTaskUtility.GetUniqueObject(base.GetDataObject <ADOabVirtualDirectory>), offlineAddressBook, new Task.TaskErrorLoggingDelegate(base.WriteError));
                }
                else
                {
                    offlineAddressBook.VirtualDirectories = null;
                }
            }
            bool flag3 = false;

            if (this.isOriginalPfDistributionEnabled ^ this.isPresentPfDistributionEnabled)
            {
                if (offlineAddressBook.PublicFolderDatabase != null)
                {
                    IEnumerable <PublicFolderDatabase> objects = new DatabaseIdParameter(offlineAddressBook.PublicFolderDatabase)
                    {
                        AllowLegacy = true
                    }.GetObjects <PublicFolderDatabase>(null, base.GlobalConfigSession);
                    using (IEnumerator <PublicFolderDatabase> enumerator = objects.GetEnumerator())
                    {
                        if (enumerator.MoveNext())
                        {
                            this.publicFolderDatabase = enumerator.Current;
                            if (enumerator.MoveNext())
                            {
                                this.publicFolderDatabase = null;
                            }
                            else
                            {
                                flag3 = true;
                            }
                        }
                    }
                }
                if (!flag3)
                {
                    OfflineAddressBookTaskUtility.ValidatePublicFolderInfrastructure(base.GlobalConfigSession, new Task.TaskErrorLoggingDelegate(base.WriteError), new Task.TaskWarningLoggingDelegate(this.WriteWarning), this.isPresentPfDistributionEnabled);
                }
            }
            if (this.UseDefaultAttributes.IsPresent)
            {
                if (offlineAddressBook.ExchangeVersion.IsOlderThan(ExchangeObjectVersion.Exchange2010))
                {
                    base.WriteError(new InvalidOperationException(Strings.CannotUseDefaultAttributesForExchange2007OAB), ErrorCategory.InvalidOperation, this.Identity);
                }
                offlineAddressBook.ConfiguredAttributes = OfflineAddressBookMapiProperty.DefaultOABPropertyList;
            }
            if (!this.isOriginalPfDistributionEnabled && this.isPresentPfDistributionEnabled && !flag3)
            {
                this.publicFolderDatabase = OfflineAddressBookTaskUtility.FindPublicFolderDatabase(base.GlobalConfigSession, offlineAddressBook.Server, new Task.TaskErrorLoggingDelegate(base.WriteError));
                offlineAddressBook.PublicFolderDatabase = (ADObjectId)this.publicFolderDatabase.Identity;
            }
            if (offlineAddressBook.IsChanged(OfflineAddressBookSchema.VirtualDirectories) || this.isOriginalPfDistributionEnabled != this.isPresentPfDistributionEnabled)
            {
                OfflineAddressBookTaskUtility.WarnForNoDistribution(offlineAddressBook, new Task.TaskWarningLoggingDelegate(this.WriteWarning));
            }
        }