protected sealed override IConfigDataProvider CreateSession()
        {
            IRecipientSession tenantOrRootOrgRecipientSession = DirectorySessionFactory.Default.GetTenantOrRootOrgRecipientSession(base.DomainController, true, ConsistencyMode.PartiallyConsistent, base.SessionSettings, 51, "CreateSession", "f:\\15.00.1497\\sources\\dev\\Management\\src\\Management\\StoreTasks\\UserOptions\\SetMailboxConfigurationTaskBase.cs");
            ADUser            aduser = (ADUser)base.GetDataObject <ADUser>(this.Identity, tenantOrRootOrgRecipientSession, null, new LocalizedString?(Strings.ErrorMailboxNotFound(this.Identity.ToString())), new LocalizedString?(Strings.ErrorMailboxNotUnique(this.Identity.ToString())));

            StoreTasksHelper.CheckUserVersion(aduser, new Task.TaskErrorLoggingDelegate(base.WriteError));
            IDirectorySession directorySession = tenantOrRootOrgRecipientSession;

            if (this.ReadUserFromDC)
            {
                IRecipientSession tenantOrRootOrgRecipientSession2 = DirectorySessionFactory.Default.GetTenantOrRootOrgRecipientSession(base.DomainController, true, ConsistencyMode.PartiallyConsistent, base.SessionSettings, 70, "CreateSession", "f:\\15.00.1497\\sources\\dev\\Management\\src\\Management\\StoreTasks\\UserOptions\\SetMailboxConfigurationTaskBase.cs");
                tenantOrRootOrgRecipientSession2.UseGlobalCatalog = false;
                if (aduser.OrganizationId.Equals(OrganizationId.ForestWideOrgId))
                {
                    tenantOrRootOrgRecipientSession2.EnforceDefaultScope = false;
                }
                ADUser aduser2 = (ADUser)tenantOrRootOrgRecipientSession2.Read <ADUser>(aduser.Identity);
                if (aduser2 != null)
                {
                    aduser           = aduser2;
                    directorySession = tenantOrRootOrgRecipientSession2;
                }
            }
            if (TaskHelper.ShouldUnderscopeDataSessionToOrganization(directorySession, aduser))
            {
                directorySession = TaskHelper.UnderscopeSessionToOrganization(directorySession, aduser.OrganizationId, true);
            }
            base.VerifyIsWithinScopes(directorySession, aduser, true, new DataAccessTask <TDataObject> .ADObjectOutOfScopeString(Strings.ErrorCannotChangeMailboxOutOfWriteScope));
            this.mailboxStoreIdParameter = new MailboxStoreIdParameter(new MailboxStoreIdentity(aduser.Id));
            return(this.CreateMailboxDataProvider(aduser));
        }
Пример #2
0
        protected sealed override IConfigDataProvider CreateSession()
        {
            this.rootId = null;
            IRecipientSession tenantOrRootOrgRecipientSession = DirectorySessionFactory.Default.GetTenantOrRootOrgRecipientSession(base.DomainController, true, ConsistencyMode.PartiallyConsistent, base.SessionSettings, 104, "CreateSession", "f:\\15.00.1497\\sources\\dev\\Management\\src\\Management\\StoreTasks\\UserOptions\\MailboxFolder\\GetMailboxFolder.cs");
            ADObjectId        adobjectId;
            bool flag = base.TryGetExecutingUserId(out adobjectId);
            MailboxIdParameter mailboxIdParameter;

            if (this.Identity == null)
            {
                if (!flag)
                {
                    throw new ExecutingUserPropertyNotFoundException("executingUserid");
                }
                mailboxIdParameter = new MailboxIdParameter(adobjectId);
                if (!this.Recurse.IsPresent && !this.GetChildren.IsPresent)
                {
                    this.Identity = new MailboxFolderIdParameter(adobjectId);
                }
            }
            else if (null == this.Identity.InternalMailboxFolderId)
            {
                if (this.Identity.RawOwner != null)
                {
                    mailboxIdParameter = this.Identity.RawOwner;
                }
                else
                {
                    if (!flag)
                    {
                        throw new ExecutingUserPropertyNotFoundException("executingUserid");
                    }
                    mailboxIdParameter = new MailboxIdParameter(adobjectId);
                }
            }
            else
            {
                mailboxIdParameter = new MailboxIdParameter(this.Identity.InternalMailboxFolderId.MailboxOwnerId);
            }
            ADUser aduser = (ADUser)base.GetDataObject <ADUser>(mailboxIdParameter, tenantOrRootOrgRecipientSession, null, new LocalizedString?(Strings.ErrorMailboxNotFound(mailboxIdParameter.ToString())), new LocalizedString?(Strings.ErrorMailboxNotUnique(mailboxIdParameter.ToString())));

            if (this.Identity != null && null == this.Identity.InternalMailboxFolderId)
            {
                this.Identity.InternalMailboxFolderId = new Microsoft.Exchange.Data.Storage.Management.MailboxFolderId(aduser.Id, this.Identity.RawFolderStoreId, this.Identity.RawFolderPath);
            }
            StoreTasksHelper.CheckUserVersion(aduser, new Task.TaskErrorLoggingDelegate(base.WriteError));
            if ((this.Recurse.IsPresent || this.GetChildren.IsPresent) && this.Identity != null)
            {
                this.rootId   = this.Identity.InternalMailboxFolderId;
                this.Identity = null;
            }
            base.InnerMailboxFolderDataProvider = new MailboxFolderDataProvider(base.SessionSettings, aduser, (base.ExchangeRunspaceConfig == null) ? null : base.ExchangeRunspaceConfig.SecurityAccessToken, "Get-MailboxFolder");
            return(base.InnerMailboxFolderDataProvider);
        }
Пример #3
0
        protected override IConfigDataProvider CreateSession()
        {
            IRecipientSession tenantOrRootOrgRecipientSession = DirectorySessionFactory.Default.GetTenantOrRootOrgRecipientSession(base.DomainController, true, ConsistencyMode.PartiallyConsistent, base.SessionSettings, 63, "CreateSession", "f:\\15.00.1497\\sources\\dev\\Management\\src\\Management\\StoreTasks\\UserOptions\\MailboxFolder\\NewMailboxFolder.cs");
            ADObjectId        adobjectId;
            bool flag = base.TryGetExecutingUserId(out adobjectId);
            MailboxIdParameter mailboxIdParameter;

            if (this.Parent == null)
            {
                if (!flag)
                {
                    throw new ExecutingUserPropertyNotFoundException("executingUserid");
                }
                mailboxIdParameter = new MailboxIdParameter(adobjectId);
                this.Parent        = new MailboxFolderIdParameter(adobjectId);
            }
            else if (null == this.Parent.InternalMailboxFolderId)
            {
                if (this.Parent.RawOwner != null)
                {
                    mailboxIdParameter = this.Parent.RawOwner;
                }
                else
                {
                    if (!flag)
                    {
                        throw new ExecutingUserPropertyNotFoundException("executingUserid");
                    }
                    mailboxIdParameter = new MailboxIdParameter(adobjectId);
                }
            }
            else
            {
                mailboxIdParameter = new MailboxIdParameter(this.Parent.InternalMailboxFolderId.MailboxOwnerId);
            }
            ADUser aduser = (ADUser)base.GetDataObject <ADUser>(mailboxIdParameter, tenantOrRootOrgRecipientSession, null, new LocalizedString?(Strings.ErrorMailboxNotFound(mailboxIdParameter.ToString())), new LocalizedString?(Strings.ErrorMailboxNotUnique(mailboxIdParameter.ToString())));

            base.VerifyIsWithinScopes(tenantOrRootOrgRecipientSession, aduser, true, new DataAccessTask <MailboxFolder> .ADObjectOutOfScopeString(Strings.ErrorCannotChangeMailboxOutOfWriteScope));
            StoreTasksHelper.CheckUserVersion(aduser, new Task.TaskErrorLoggingDelegate(base.WriteError));
            if (this.Parent != null && null == this.Parent.InternalMailboxFolderId)
            {
                this.Parent.InternalMailboxFolderId = new Microsoft.Exchange.Data.Storage.Management.MailboxFolderId(aduser.Id, this.Parent.RawFolderStoreId, this.Parent.RawFolderPath);
            }
            this.innerMailboxFolderDataProvider = new MailboxFolderDataProvider(base.SessionSettings, aduser, (base.ExchangeRunspaceConfig == null) ? null : base.ExchangeRunspaceConfig.SecurityAccessToken, "New-MailboxFolder");
            return(this.innerMailboxFolderDataProvider);
        }