Esempio n. 1
0
        protected override IConfigDataProvider CreateSession()
        {
            ADObjectId executingUserId;

            if (!base.TryGetExecutingUserId(out executingUserId) && this.Mailbox == null)
            {
                return(this.CreateDataProviderForNonMailboxUser());
            }
            MailboxIdParameter mailboxIdParameter = this.Mailbox ?? MailboxTaskHelper.ResolveMailboxIdentity(executingUserId, new Task.ErrorLoggerDelegate(base.WriteError));

            try
            {
                this.adUser = (ADUser)base.GetDataObject <ADUser>(mailboxIdParameter, base.TenantGlobalCatalogSession, null, new LocalizedString?(Strings.ErrorMailboxNotFound(mailboxIdParameter.ToString())), new LocalizedString?(Strings.ErrorMailboxNotUnique(mailboxIdParameter.ToString())));
            }
            catch (ManagementObjectNotFoundException)
            {
                return(this.CreateDataProviderForNonMailboxUser());
            }
            this.isBposUser = CapabilityHelper.HasBposSKUCapability(this.adUser.PersistedCapabilities);
            ADScopeException ex;

            if (!TaskHelper.UnderscopeSessionToOrganization(base.TenantGlobalCatalogSession, this.adUser.OrganizationId, true).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);
            }
            IConfigDataProvider configDataProvider = GetApp.CreateOwaExtensionDataProvider(null, base.TenantGlobalCatalogSession, base.SessionSettings, !this.OrganizationApp, this.adUser, "New-App", false, new Task.ErrorLoggerDelegate(base.WriteError));

            this.mailboxOwner = ((OWAExtensionDataProvider)configDataProvider).MailboxSession.MailboxOwner.ObjectId.ToString();
            return(configDataProvider);
        }
Esempio n. 2
0
        protected override IConfigDataProvider CreateSession()
        {
            ADUser     adUser = null;
            ADObjectId executingUserId;

            if (!base.TryGetExecutingUserId(out executingUserId))
            {
                return(this.CreateDataProviderForNonMailboxUser());
            }
            MailboxIdParameter mailboxIdParameter = MailboxTaskHelper.ResolveMailboxIdentity(executingUserId, new Task.ErrorLoggerDelegate(base.WriteError));

            try
            {
                adUser = (ADUser)base.GetDataObject <ADUser>(mailboxIdParameter, base.TenantGlobalCatalogSession, null, new LocalizedString?(Strings.ErrorMailboxNotFound(mailboxIdParameter.ToString())), new LocalizedString?(Strings.ErrorMailboxNotUnique(mailboxIdParameter.ToString())));
            }
            catch (ManagementObjectNotFoundException)
            {
                return(this.CreateDataProviderForNonMailboxUser());
            }
            if (this.Identity != null && this.Identity.InternalOWAExtensionId == null)
            {
                this.Identity.InternalOWAExtensionId = OWAExtensionHelper.CreateOWAExtensionId(this, new ADObjectId(), null, this.Identity.RawExtensionName);
            }
            if (this.Organization != null)
            {
                this.SetCurrentOrganizationId();
            }
            return(GetApp.CreateOwaExtensionDataProvider(this.Organization, base.TenantGlobalCatalogSession, base.SessionSettings, false, adUser, "Set-App", false, new Task.ErrorLoggerDelegate(base.WriteError)));
        }
Esempio n. 3
0
        protected override IConfigDataProvider CreateSession()
        {
            MailboxIdParameter mailboxIdParameter = null;
            ADUser             aduser             = 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 adobjectId;
                base.TryGetExecutingUserId(out adobjectId);
                if (adobjectId == null && this.Mailbox == null)
                {
                    return(this.CreateDataProviderForNonMailboxUser());
                }
                mailboxIdParameter = (this.Mailbox ?? MailboxTaskHelper.ResolveMailboxIdentity(adobjectId, new Task.ErrorLoggerDelegate(base.WriteError)));
            }
            try
            {
                aduser = (ADUser)base.GetDataObject <ADUser>(mailboxIdParameter, base.TenantGlobalCatalogSession, null, new LocalizedString?(Strings.ErrorMailboxNotFound(mailboxIdParameter.ToString())), new LocalizedString?(Strings.ErrorMailboxNotUnique(mailboxIdParameter.ToString())));
            }
            catch (ManagementObjectNotFoundException)
            {
                return(this.CreateDataProviderForNonMailboxUser());
            }
            if (this.Identity != null && this.Identity.InternalOWAExtensionId == null)
            {
                this.Identity.InternalOWAExtensionId = OWAExtensionHelper.CreateOWAExtensionId(this, aduser.Id, null, this.Identity.RawExtensionName);
            }
            ADScopeException ex;

            if (!base.TenantGlobalCatalogSession.TryVerifyIsWithinScopes(aduser, true, out ex))
            {
                base.WriteError(new InvalidOperationException(Strings.ErrorCannotChangeMailboxOutOfWriteScope(aduser.Identity.ToString(), (ex == null) ? string.Empty : ex.Message), ex), ErrorCategory.InvalidOperation, aduser.Identity);
            }
            if (this.Organization != null)
            {
                this.SetCurrentOrganizationId();
            }
            return(GetApp.CreateOwaExtensionDataProvider(this.Organization, base.TenantGlobalCatalogSession, base.SessionSettings, !this.OrganizationApp, aduser, "Get-App", base.IsDebugOn, new Task.ErrorLoggerDelegate(base.WriteError)));
        }
Esempio n. 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);
        }