Exemplo n.º 1
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);
        }
Exemplo n.º 2
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));
            }
        }