示例#1
0
        protected override void InternalSave(ConfigurableObject instance)
        {
            if (instance == null)
            {
                throw new ArgumentNullException("instance");
            }
            App owaExtension = instance as App;

            if (owaExtension == null)
            {
                throw new NotSupportedException("Save: " + instance.GetType().FullName);
            }
            OWAExtensionDataProvider.RunAction(delegate
            {
                using (InstalledExtensionTable installedExtensionTable = InstalledExtensionTable.CreateInstalledExtensionTable(this.domain, this.isUserScope, null, this.MailboxSession))
                {
                    switch (owaExtension.ObjectState)
                    {
                    case ObjectState.New:
                        if (!owaExtension.IsDownloadOnly)
                        {
                            installedExtensionTable.InstallExtension(owaExtension.GetExtensionDataForInstall(this.adRecipientSession), false);
                        }
                        break;

                    case ObjectState.Changed:
                        if (this.isUserScope)
                        {
                            installedExtensionTable.ConfigureUserExtension(owaExtension.AppId, owaExtension.Enabled);
                        }
                        else
                        {
                            OrgApp orgApp = instance as OrgApp;
                            if (orgApp == null)
                            {
                                throw new NotSupportedException("Save: " + instance.GetType().FullName);
                            }
                            installedExtensionTable.ConfigureOrgExtension(orgApp.AppId, orgApp.Enabled, orgApp.DefaultStateForUser == DefaultStateForUser.AlwaysEnabled, orgApp.DefaultStateForUser == DefaultStateForUser.Enabled, orgApp.ProvidedTo, OrgApp.ConvertPresentationFormatToWireUserList(this.adRecipientSession, orgApp.UserList));
                        }
                        break;
                    }
                }
            });
        }
示例#2
0
        protected override void InternalSave(ConfigurableObject instance)
        {
            if (instance == null)
            {
                throw new ArgumentNullException("instance");
            }
            MailboxFolder mailboxFolder = instance as MailboxFolder;

            if (mailboxFolder == null)
            {
                throw new NotSupportedException("Save: " + instance.GetType().FullName);
            }
            FolderSaveResult folderSaveResult = null;

            switch (mailboxFolder.ObjectState)
            {
            case ObjectState.New:
                try
                {
                    using (Folder folder = Folder.Create(base.MailboxSession, mailboxFolder.InternalParentFolderIdentity, ObjectClass.GetObjectType(mailboxFolder.FolderClass), mailboxFolder.Name, CreateMode.CreateNew))
                    {
                        mailboxFolder.SaveDataToXso(folder, new ReadOnlyCollection <XsoDriverPropertyDefinition>(new List <XsoDriverPropertyDefinition>
                        {
                            MailboxFolderSchema.Name,
                            MailboxFolderSchema.InternalParentFolderIdentity
                        }));
                        MailboxFolderDataProvider.ValidateXsoObjectAndThrowForError(mailboxFolder.Name, folder, mailboxFolder.Schema);
                        folderSaveResult = folder.Save();
                    }
                    goto IL_FD;
                }
                catch (ObjectExistedException innerException)
                {
                    throw new ObjectExistedException(ServerStrings.ErrorFolderAlreadyExists(mailboxFolder.Name), innerException);
                }
                break;

            case ObjectState.Unchanged:
                goto IL_FD;

            case ObjectState.Changed:
                break;

            case ObjectState.Deleted:
                throw new InvalidOperationException(ServerStrings.ExceptionObjectHasBeenDeleted);

            default:
                goto IL_FD;
            }
            throw new NotImplementedException("Save.Changed");
IL_FD:
            if (folderSaveResult != null && folderSaveResult.OperationResult != OperationResult.Succeeded)
            {
                throw folderSaveResult.ToException(ServerStrings.ErrorFolderSave(instance.Identity.ToString(), folderSaveResult.ToString()));
            }
        }
示例#3
0
 // Token: 0x06000FC3 RID: 4035 RVA: 0x0003016C File Offset: 0x0002E36C
 protected override void FillProperty(Type type, PSObject psObject, ConfigurableObject configObject, string propertyName)
 {
     if (propertyName == "CallAnsweringRulesEnabled")
     {
         PropertyInfo property = configObject.GetType().GetProperty(propertyName);
         property.SetValue(configObject, MockObjectCreator.GetSingleProperty(psObject.Members[propertyName].Value, property.PropertyType), null);
         return;
     }
     base.FillProperty(type, psObject, configObject, propertyName);
 }
 protected override void FillProperty(Type type, PSObject psObject, ConfigurableObject configObject, string propertyName)
 {
     if (propertyName == "RetentionEnabled" || propertyName == "AgeLimitForRetention" || propertyName == "RetentionAction")
     {
         PropertyInfo property = configObject.GetType().GetProperty(propertyName);
         property.SetValue(configObject, MockObjectCreator.GetSingleProperty(psObject.Members[propertyName].Value, property.PropertyType), null);
         return;
     }
     base.FillProperty(type, psObject, configObject, propertyName);
 }
        protected void InternalSave(ConfigurableObject instance)
        {
            if (instance == null)
            {
                throw new ArgumentNullException("instance");
            }
            App owaExtension = instance as App;

            if (owaExtension == null)
            {
                throw new NotSupportedException("Save: " + instance.GetType().FullName);
            }
            OWAExtensionDataProvider.RunAction(delegate
            {
                switch (owaExtension.ObjectState)
                {
                case ObjectState.New:
                    if (!owaExtension.IsDownloadOnly)
                    {
                        OrgExtensionTable.SetOrgExtension(this.domain, 0, null, owaExtension.GetExtensionDataForInstall(this.adRecipientSession));
                        return;
                    }
                    break;

                case ObjectState.Unchanged:
                    break;

                case ObjectState.Changed:
                    {
                        OrgApp orgApp = instance as OrgApp;
                        if (orgApp == null)
                        {
                            throw new NotSupportedException("Save: " + instance.GetType().FullName);
                        }
                        OrgExtensionTable.ConfigureOrgExtension(this.domain, orgApp.AppId, orgApp.Enabled, orgApp.DefaultStateForUser == DefaultStateForUser.AlwaysEnabled, orgApp.DefaultStateForUser == DefaultStateForUser.Enabled, orgApp.ProvidedTo, OrgApp.ConvertPresentationFormatToWireUserList(this.adRecipientSession, orgApp.UserList));
                        break;
                    }

                default:
                    return;
                }
            });
        }
        protected override void InternalSave(ConfigurableObject instance)
        {
            if (instance == null)
            {
                throw new ArgumentNullException("instance");
            }
            UnifiedPolicyNotificationBase unifiedPolicyNotificationBase = instance as UnifiedPolicyNotificationBase;

            if (unifiedPolicyNotificationBase == null)
            {
                throw new NotSupportedException("Save: " + instance.GetType().FullName);
            }
            switch (unifiedPolicyNotificationBase.ObjectState)
            {
            case ObjectState.New:
                using (Folder folder = Folder.Bind(base.MailboxSession, base.MailboxSession.GetDefaultFolderId(DefaultFolderType.Inbox)))
                {
                    using (MessageItem messageItem = MessageItem.CreateAssociated(base.MailboxSession, folder.Id))
                    {
                        this.SetNotificationMessage(messageItem, unifiedPolicyNotificationBase);
                        messageItem.Save(SaveMode.NoConflictResolutionForceSave);
                        messageItem.Load();
                        unifiedPolicyNotificationBase.StoreObjectId = messageItem.Id;
                    }
                    return;
                }
                break;

            case ObjectState.Unchanged:
                return;

            case ObjectState.Changed:
                break;

            case ObjectState.Deleted:
                goto IL_FE;

            default:
                return;
            }
            if (unifiedPolicyNotificationBase.StoreObjectId == null)
            {
                throw new ArgumentException("notification.StoreObjectId is null when saving for an update.");
            }
            using (MessageItem messageItem2 = MessageItem.Bind(base.MailboxSession, unifiedPolicyNotificationBase.StoreObjectId))
            {
                this.SetNotificationMessage(messageItem2, unifiedPolicyNotificationBase);
                messageItem2.Save(SaveMode.NoConflictResolutionForceSave);
                messageItem2.Load();
                return;
            }
IL_FE:
            throw new InvalidOperationException(ServerStrings.ExceptionObjectHasBeenDeleted);
        }
        protected override void InternalSave(ConfigurableObject instance)
        {
            if (instance == null)
            {
                throw new ArgumentNullException("instance");
            }
            MailboxCalendarFolder mailboxCalendarFolder = instance as MailboxCalendarFolder;

            if (mailboxCalendarFolder == null)
            {
                throw new NotSupportedException("Save: " + instance.GetType().FullName);
            }
            if (mailboxCalendarFolder.PublishEnabled)
            {
                SharingPolicy sharingPolicy = DirectoryHelper.ReadSharingPolicy(base.MailboxSession.MailboxOwner.MailboxInfo.MailboxGuid, base.MailboxSession.MailboxOwner.MailboxInfo.IsArchive, base.MailboxSession.GetADRecipientSession(true, ConsistencyMode.IgnoreInvalid));
                if (sharingPolicy == null || !sharingPolicy.Enabled || !sharingPolicy.IsAllowedForAnonymousCalendarSharing())
                {
                    throw new NotAllowedPublishingByPolicyException();
                }
                SharingPolicyAction allowedForAnonymousCalendarSharing = sharingPolicy.GetAllowedForAnonymousCalendarSharing();
                int maxAllowed = PolicyAllowedDetailLevel.GetMaxAllowed(allowedForAnonymousCalendarSharing);
                if (mailboxCalendarFolder.DetailLevel > (DetailLevelEnumType)maxAllowed)
                {
                    throw new NotAllowedPublishingByPolicyException(mailboxCalendarFolder.DetailLevel, (DetailLevelEnumType)maxAllowed);
                }
            }
            MailboxFolderId mailboxFolderId = mailboxCalendarFolder.MailboxFolderId;
            StoreObjectId   folderId        = mailboxFolderId.StoreObjectIdValue ?? base.ResolveStoreObjectIdFromFolderPath(mailboxFolderId.MailboxFolderPath);

            if (folderId == null || folderId.ObjectType != StoreObjectType.CalendarFolder)
            {
                throw new CantFindCalendarFolderException(mailboxFolderId);
            }
            using (CalendarFolder calendarFolder = CalendarFolder.Bind(base.MailboxSession, folderId))
            {
                ExtendedFolderFlags?valueAsNullable = calendarFolder.GetValueAsNullable <ExtendedFolderFlags>(FolderSchema.ExtendedFolderFlags);
                if (valueAsNullable != null && (valueAsNullable.Value & ExtendedFolderFlags.PersonalShare) != (ExtendedFolderFlags)0)
                {
                    throw new CannotShareFolderException(ServerStrings.CannotShareOtherPersonalFolder);
                }
                this.SaveSharingAnonymous(mailboxCalendarFolder, folderId);
                if (!mailboxCalendarFolder.PublishEnabled)
                {
                    mailboxCalendarFolder.PublishedCalendarUrl = null;
                    mailboxCalendarFolder.PublishedICalUrl     = null;
                }
                UserConfigurationDictionaryHelper.Save(mailboxCalendarFolder, MailboxCalendarFolder.CalendarFolderConfigurationProperties, (bool createIfNonexisting) => UserConfigurationHelper.GetPublishingConfiguration(this.MailboxSession, folderId, createIfNonexisting));
                if (MailboxCalendarFolderDataProvider.UpdateExtendedFolderFlags(mailboxCalendarFolder, calendarFolder))
                {
                    calendarFolder.Save();
                }
            }
        }
        protected void InternalDelete(ConfigurableObject instance)
        {
            if (instance == null)
            {
                throw new ArgumentNullException("instance");
            }
            App app = instance as App;

            if (app == null)
            {
                throw new NotSupportedException("Save: " + instance.GetType().FullName);
            }
            OrgExtensionTable.SetOrgExtension(this.domain, 1, app.AppId, null);
        }
        protected void InternalSave(ConfigurableObject instance)
        {
            if (instance == null)
            {
                throw new ArgumentNullException("instance");
            }
            EncryptionConfiguration encryptionConfiguration = instance as EncryptionConfiguration;

            if (encryptionConfiguration == null)
            {
                throw new NotSupportedException("Save: " + instance.GetType().FullName);
            }
            EncryptionConfigurationTable.SetEncryptionConfiguration(this.organizationRawIdentity, encryptionConfiguration.ImageBase64, encryptionConfiguration.EmailText, encryptionConfiguration.PortalText, encryptionConfiguration.DisclaimerText, encryptionConfiguration.OTPEnabled);
        }
示例#10
0
        protected override void InternalDelete(ConfigurableObject instance)
        {
            if (instance == null)
            {
                throw new ArgumentNullException("instance");
            }
            App owaExtension = instance as App;

            if (owaExtension == null)
            {
                throw new NotSupportedException("Save: " + instance.GetType().FullName);
            }
            OWAExtensionDataProvider.RunAction(delegate
            {
                using (InstalledExtensionTable installedExtensionTable = InstalledExtensionTable.CreateInstalledExtensionTable(this.domain, this.isUserScope, null, this.MailboxSession))
                {
                    if (this.isUserScope)
                    {
                        if (ExtensionInstallScope.User != owaExtension.Scope)
                        {
                            throw new OwaExtensionOperationException(Strings.ErrorUninstallProvidedExtension(owaExtension.DisplayName));
                        }
                        if (this.TryRemovePerExtensionFai(owaExtension.AppId, owaExtension.AppVersion))
                        {
                            installedExtensionTable.UninstallExtension(owaExtension.AppId);
                        }
                        else
                        {
                            installedExtensionTable.ConfigureUserExtension(owaExtension.AppId, false);
                        }
                    }
                    else
                    {
                        if (ExtensionInstallScope.Default == owaExtension.Scope)
                        {
                            throw new OwaExtensionOperationException(Strings.ErrorUninstallDefaultExtension(owaExtension.DisplayName));
                        }
                        installedExtensionTable.UninstallExtension(owaExtension.AppId);
                    }
                }
            });
        }
        internal static ConfigurableObjectXML Create(ConfigurableObject obj)
        {
            if (obj == null)
            {
                return(null);
            }
            ConfigurableObjectXML configurableObjectXML = new ConfigurableObjectXML();

            configurableObjectXML.ClassName = obj.GetType().Name;
            foreach (PropertyDefinition propertyDefinition in obj.ObjectSchema.AllProperties)
            {
                ProviderPropertyDefinition providerPropertyDefinition = propertyDefinition as ProviderPropertyDefinition;
                if (providerPropertyDefinition != null && !ConfigurableObjectXML.PropertiesNotToSerialize.ContainsKey(propertyDefinition))
                {
                    object      value       = obj[providerPropertyDefinition];
                    PropertyXML propertyXML = PropertyXML.Create(providerPropertyDefinition, value);
                    if (propertyXML != null)
                    {
                        configurableObjectXML.properties[providerPropertyDefinition.Name] = propertyXML;
                    }
                }
            }
            return(configurableObjectXML);
        }
        protected override void InternalDelete(ConfigurableObject instance)
        {
            if (instance == null)
            {
                throw new ArgumentNullException("instance");
            }
            UnifiedPolicyNotificationBase unifiedPolicyNotificationBase = instance as UnifiedPolicyNotificationBase;

            if (unifiedPolicyNotificationBase == null)
            {
                throw new NotSupportedException("Delete: " + instance.GetType().FullName);
            }
            if (unifiedPolicyNotificationBase.StoreObjectId == null)
            {
                throw new ArgumentException("notification.StoreObjectId is null when deleting the instance.");
            }
            using (Folder folder = Folder.Bind(base.MailboxSession, base.MailboxSession.GetDefaultFolderId(DefaultFolderType.Inbox)))
            {
                folder.DeleteObjects(DeleteItemFlags.HardDelete, new StoreId[]
                {
                    unifiedPolicyNotificationBase.StoreObjectId
                });
            }
        }
        protected override void InternalSave(ConfigurableObject instance)
        {
            PublicFolder publicFolder = instance as PublicFolder;

            if (publicFolder == null)
            {
                throw new NotSupportedException("Save: " + instance.GetType().FullName);
            }
            FolderSaveResult folderSaveResult = null;

            switch (publicFolder.ObjectState)
            {
            case ObjectState.New:
                try
                {
                    using (Folder folder = Folder.Create(this.PublicFolderSession, publicFolder.InternalParentFolderIdentity, ObjectClass.GetObjectType(publicFolder.FolderClass), publicFolder.Name, CreateMode.CreateNew))
                    {
                        publicFolder.SaveDataToXso(folder, new ReadOnlyCollection <XsoDriverPropertyDefinition>(new List <XsoDriverPropertyDefinition>
                        {
                            PublicFolderSchema.Name,
                            MailboxFolderSchema.InternalParentFolderIdentity
                        }));
                        MailboxFolderDataProvider.ValidateXsoObjectAndThrowForError(publicFolder.Name, folder, publicFolder.Schema);
                        folderSaveResult            = folder.Save();
                        publicFolder.OrganizationId = this.PublicFolderSession.OrganizationId;
                    }
                    goto IL_157;
                }
                catch (ObjectExistedException innerException)
                {
                    throw new ObjectExistedException(ServerStrings.ErrorFolderAlreadyExists(publicFolder.Name), innerException);
                }
                break;

            case ObjectState.Unchanged:
                goto IL_157;

            case ObjectState.Changed:
                break;

            case ObjectState.Deleted:
                goto IL_147;

            default:
                goto IL_157;
            }
            using (Folder folder2 = Folder.Bind(this.PublicFolderSession, publicFolder.InternalFolderIdentity, null))
            {
                publicFolder.SaveDataToXso(folder2, new ReadOnlyCollection <XsoDriverPropertyDefinition>(new List <XsoDriverPropertyDefinition>
                {
                    MailboxFolderSchema.InternalParentFolderIdentity
                }));
                MailboxFolderDataProvider.ValidateXsoObjectAndThrowForError(publicFolder.Name, folder2, publicFolder.Schema);
                folderSaveResult = folder2.Save();
                goto IL_157;
            }
IL_147:
            throw new InvalidOperationException(ServerStrings.ExceptionObjectHasBeenDeleted);
IL_157:
            if (folderSaveResult != null && folderSaveResult.OperationResult != OperationResult.Succeeded && folderSaveResult.PropertyErrors.Length > 0)
            {
                foreach (PropertyError propertyError in folderSaveResult.PropertyErrors)
                {
                    if (propertyError.PropertyErrorCode == PropertyErrorCode.FolderNameConflict)
                    {
                        throw new ObjectExistedException(ServerStrings.ErrorFolderAlreadyExists(publicFolder.Name));
                    }
                }
                throw folderSaveResult.ToException(ServerStrings.ErrorFolderSave(instance.Identity.ToString(), folderSaveResult.ToString()));
            }
        }
        protected override void InternalDelete(ConfigurableObject instance)
        {
            PublicFolder publicFolder = instance as PublicFolder;

            if (publicFolder == null)
            {
                throw new NotSupportedException(ServerStrings.ExceptionIsNotPublicFolder(instance.GetType().FullName));
            }
            if (publicFolder.ObjectState == ObjectState.Deleted)
            {
                throw new InvalidOperationException(ServerStrings.ExceptionObjectHasBeenDeleted);
            }
            AggregateOperationResult aggregateOperationResult = this.PublicFolderSession.Delete(DeleteItemFlags.HardDelete, new StoreId[]
            {
                this.PublicFolderSession.IdConverter.GetSessionSpecificId(publicFolder.InternalFolderIdentity.ObjectId)
            });

            if (aggregateOperationResult != null && aggregateOperationResult.OperationResult != OperationResult.Succeeded)
            {
                StringBuilder stringBuilder = new StringBuilder();
                foreach (GroupOperationResult groupOperationResult in aggregateOperationResult.GroupOperationResults)
                {
                    if (groupOperationResult.OperationResult != OperationResult.Succeeded && groupOperationResult.Exception != null)
                    {
                        stringBuilder.AppendLine(groupOperationResult.Exception.ToString());
                    }
                }
                throw new StoragePermanentException(ServerStrings.ErrorFailedToDeletePublicFolder(publicFolder.Identity.ToString(), stringBuilder.ToString()));
            }
        }
示例#15
0
        public object Clone()
        {
            DataObjectProfile dataObjectProfile = new DataObjectProfile(this.Name, this.Type, this.Retriever, this.Validator);

            if (PSConnectionInfoSingleton.GetInstance().Type != OrganizationType.Cloud)
            {
                dataObjectProfile.DataObject = ((this.DataObject is ICloneable) ? ((ICloneable)this.DataObject).Clone() : this.DataObject);
            }
            else if (this.DataObject != null)
            {
                ConfigurableObject configurableObject = this.DataObject as ConfigurableObject;
                if (configurableObject != null)
                {
                    ConfigurableObject configurableObject2 = MockObjectInformation.CreateDummyObject(configurableObject.GetType()) as ConfigurableObject;
                    configurableObject2.propertyBag = (configurableObject.propertyBag.Clone() as PropertyBag);
                    dataObjectProfile.DataObject    = configurableObject2;
                }
                else
                {
                    dataObjectProfile.DataObject = this.DataObject;
                }
            }
            return(dataObjectProfile);
        }