protected override IConfigDataProvider CreateSession() { IRecipientSession recipientSession = (IRecipientSession)base.CreateSession(); ADObjectId searchRoot = recipientSession.SearchRoot; if (this.SoftDeletedMailbox.IsPresent && base.CurrentOrganizationId != null && base.CurrentOrganizationId.OrganizationalUnit != null) { searchRoot = new ADObjectId("OU=Soft Deleted Objects," + base.CurrentOrganizationId.OrganizationalUnit.DistinguishedName); } if (base.ParameterSetName == "DatabaseSet" || base.ParameterSetName == "ServerSet" || base.ParameterSetName == "MailboxPlanSet" || this.SoftDeletedMailbox.IsPresent || this.IncludeSoftDeletedMailbox.IsPresent) { if (this.SoftDeletedMailbox.IsPresent || this.IncludeSoftDeletedMailbox.IsPresent) { recipientSession.SessionSettings.IncludeSoftDeletedObjects = true; } IRecipientSession tenantOrRootOrgRecipientSession = DirectorySessionFactory.Default.GetTenantOrRootOrgRecipientSession(recipientSession.DomainController, searchRoot, recipientSession.Lcid, recipientSession.ReadOnly, recipientSession.ConsistencyMode, recipientSession.NetworkCredential, recipientSession.SessionSettings, ConfigScopes.TenantSubTree, 417, "CreateSession", "f:\\15.00.1497\\sources\\dev\\Management\\src\\Management\\RecipientTasks\\mailbox\\GetMailbox.cs"); tenantOrRootOrgRecipientSession.EnforceDefaultScope = recipientSession.EnforceDefaultScope; tenantOrRootOrgRecipientSession.UseGlobalCatalog = recipientSession.UseGlobalCatalog; tenantOrRootOrgRecipientSession.LinkResolutionServer = recipientSession.LinkResolutionServer; recipientSession = tenantOrRootOrgRecipientSession; } if (this.IncludeInactiveMailbox.IsPresent) { recipientSession = SoftDeletedTaskHelper.CreateTenantOrRootOrgRecipientSessionIncludeInactiveMailbox(recipientSession, base.CurrentOrganizationId); } else if (this.InactiveMailboxOnly.IsPresent) { recipientSession = SoftDeletedTaskHelper.CreateTenantOrRootOrgRecipientSessionInactiveMailboxOnly(recipientSession, base.CurrentOrganizationId); } return(recipientSession); }