Beispiel #1
0
        protected override IEnumerable <T> InternalFindPaged <T>(QueryFilter filter, ObjectId rootId, bool deepSearch, SortBy sortBy, int pageSize)
        {
            AppId owaExtensionId = rootId as AppId;

            if (sortBy != null)
            {
                throw new NotSupportedException("sortBy");
            }
            if (rootId != null && owaExtensionId == null)
            {
                throw new NotSupportedException("rootId");
            }
            InstalledExtensionTable installedList = null;

            OWAExtensionDataProvider.RunAction(delegate
            {
                installedList = InstalledExtensionTable.CreateInstalledExtensionTable(this.domain, this.isUserScope, null, this.MailboxSession);
            });
            if (owaExtensionId == null || (owaExtensionId.DisplayName == null && owaExtensionId.AppIdValue == null))
            {
                List <ExtensionData> extensions = null;
                OWAExtensionDataProvider.RunAction(delegate
                {
                    extensions             = installedList.GetExtensions(null, false, this.isDebug, out this.rawOrgMasterTableXml);
                    this.rawMasterTableXml = (this.isDebug ? installedList.MasterTableXml.InnerXml : string.Empty);
                });
                foreach (ExtensionData extensionData2 in extensions)
                {
                    yield return((T)((object)this.ConvertStoreObjectToPresentationObject(extensionData2)));
                }
            }
            else if (!string.IsNullOrEmpty(owaExtensionId.AppIdValue))
            {
                ExtensionData extensionData = null;
                OWAExtensionDataProvider.RunAction(delegate
                {
                    installedList.TryGetExtension(owaExtensionId.AppIdValue, out extensionData, this.isDebug, out this.rawOrgMasterTableXml);
                    this.rawMasterTableXml = (this.isDebug ? installedList.MasterTableXml.InnerXml : string.Empty);
                });
                if (extensionData != null)
                {
                    yield return((T)((object)this.ConvertStoreObjectToPresentationObject(extensionData)));
                }
            }
            yield break;
            yield break;
        }
        protected IEnumerable <T> InternalFindPaged <T>(QueryFilter filter, ObjectId rootId, bool deepSearch, SortBy sortBy, int pageSize)
        {
            AppId owaExtensionId = rootId as AppId;

            if (sortBy != null)
            {
                throw new NotSupportedException("sortBy");
            }
            if (rootId != null && owaExtensionId == null)
            {
                throw new NotSupportedException("rootId");
            }
            if (owaExtensionId == null || (owaExtensionId.DisplayName == null && owaExtensionId.AppIdValue == null))
            {
                List <ExtensionData> extensions = new List <ExtensionData>();
                OWAExtensionDataProvider.RunAction(delegate
                {
                    Dictionary <string, ExtensionData> providedExtensions = this.GetProvidedExtensions(null, this.domain, false);
                    foreach (ExtensionData item in providedExtensions.Values)
                    {
                        extensions.Add(item);
                    }
                });
                foreach (ExtensionData extensionData2 in extensions)
                {
                    yield return((T)((object)this.ConvertStoreObjectToPresentationObject(extensionData2)));
                }
            }
            else if (!string.IsNullOrEmpty(owaExtensionId.AppIdValue))
            {
                ExtensionData extensionData = null;
                OWAExtensionDataProvider.RunAction(delegate
                {
                    Dictionary <string, ExtensionData> providedExtensions = this.GetProvidedExtensions(new HashSet <string>(StringComparer.OrdinalIgnoreCase)
                    {
                        owaExtensionId.AppIdValue
                    }, null, false);
                    providedExtensions.TryGetValue(owaExtensionId.AppIdValue, out extensionData);
                });
                if (extensionData != null)
                {
                    yield return((T)((object)this.ConvertStoreObjectToPresentationObject(extensionData)));
                }
            }
            yield break;
        }
Beispiel #3
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;
                    }
                }
            });
        }
Beispiel #4
0
        protected override IConfigDataProvider CreateSession()
        {
            MailboxIdParameter mailboxIdParameter = null;

            if (this.Identity != null)
            {
                if (this.Identity.InternalOWAExtensionId != null)
                {
                    mailboxIdParameter = new MailboxIdParameter(this.Identity.InternalOWAExtensionId.MailboxOwnerId);
                }
                else
                {
                    mailboxIdParameter = this.Identity.RawMailbox;
                }
            }
            if (mailboxIdParameter != null && this.Mailbox != null)
            {
                base.WriteError(new InvalidOperationException(Strings.ErrorConflictingMailboxes), ErrorCategory.InvalidOperation, this.Identity);
            }
            if (mailboxIdParameter == null)
            {
                ADObjectId executingUserId;
                if (!base.TryGetExecutingUserId(out executingUserId) && this.Mailbox == null)
                {
                    base.WriteError(new LocalizedException(Strings.ErrorParameterRequired("Mailbox")), ErrorCategory.InvalidArgument, null);
                }
                mailboxIdParameter = (this.Mailbox ?? MailboxTaskHelper.ResolveMailboxIdentity(executingUserId, new Task.ErrorLoggerDelegate(base.WriteError)));
            }
            this.adUser = (ADUser)base.GetDataObject <ADUser>(mailboxIdParameter, base.TenantGlobalCatalogSession, null, new LocalizedString?(Strings.ErrorMailboxNotFound(mailboxIdParameter.ToString())), new LocalizedString?(Strings.ErrorMailboxNotUnique(mailboxIdParameter.ToString())));
            if (this.Identity != null && this.Identity.InternalOWAExtensionId == null)
            {
                this.Identity.InternalOWAExtensionId = OWAExtensionHelper.CreateOWAExtensionId(this, this.adUser.Id, null, this.Identity.RawExtensionName);
            }
            ADScopeException ex;

            if (!base.TenantGlobalCatalogSession.TryVerifyIsWithinScopes(this.adUser, true, out ex))
            {
                base.WriteError(new InvalidOperationException(Strings.ErrorCannotChangeMailboxOutOfWriteScope(this.adUser.Identity.ToString(), (ex == null) ? string.Empty : ex.Message), ex), ErrorCategory.InvalidOperation, this.adUser.Identity);
            }
            OWAExtensionDataProvider owaextensionDataProvider = GetApp.CreateOwaExtensionDataProvider(null, base.TenantGlobalCatalogSession, base.SessionSettings, true, this.adUser, "EnableDisable-App", false, new Task.ErrorLoggerDelegate(base.WriteError));

            this.mailboxOwner = owaextensionDataProvider.MailboxSession.MailboxOwner.ObjectId.ToString();
            return(owaextensionDataProvider);
        }
        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;
                }
            });
        }
Beispiel #6
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);
                    }
                }
            });
        }
Beispiel #7
0
        internal static OWAExtensionDataProvider CreateOwaExtensionDataProvider(OrganizationIdParameter organizationIdParameter, IRecipientSession tenantGlobalCatalogSession, ADSessionSettings sessionSettings, bool isUserScope, ADUser adUser, string taskName, bool isDebugOn, Task.ErrorLoggerDelegate writeErrorDelegate)
        {
            OWAExtensionDataProvider result = null;
            LocalizedException       ex     = null;

            try
            {
                result = new OWAExtensionDataProvider((organizationIdParameter == null) ? null : organizationIdParameter.RawIdentity, tenantGlobalCatalogSession, sessionSettings, isUserScope, adUser, taskName, isDebugOn);
            }
            catch (StorageTransientException ex2)
            {
                ex = ex2;
            }
            catch (StoragePermanentException ex3)
            {
                ex = ex3;
            }
            if (ex != null)
            {
                writeErrorDelegate(ex, ExchangeErrorCategory.Client, adUser.Identity);
            }
            return(result);
        }