public static ExchangePrincipal GetTenantMailbox(OrganizationId organizationId)
        {
            string            organizationKey   = TenantStoreDataProvider.GetOrganizationKey(organizationId);
            ExchangePrincipal exchangePrincipal = null;

            if (!TenantStoreDataProvider.exchangePrincipalCache.TryGetValue(organizationKey, out exchangePrincipal))
            {
                ADSessionSettings sessionSettings = ADSessionSettings.FromOrganizationIdWithoutRbacScopes(ADSystemConfigurationSession.GetRootOrgContainerIdForLocalForest(), organizationId, null, false);
                IRecipientSession tenantOrRootOrgRecipientSession = DirectorySessionFactory.Default.GetTenantOrRootOrgRecipientSession(true, ConsistencyMode.IgnoreInvalid, sessionSettings, 67, "GetTenantMailbox", "f:\\15.00.1497\\sources\\dev\\data\\src\\storage\\Management\\EwsDriver\\TenantStoreDataProvider.cs");
                try
                {
                    exchangePrincipal = ExchangePrincipal.FromADUser(MailboxDataProvider.GetDiscoveryMailbox(tenantOrRootOrgRecipientSession), null);
                }
                catch (ObjectNotFoundException ex)
                {
                    throw new DataSourceOperationException(ex.LocalizedString, ex);
                }
                TenantStoreDataProvider.exchangePrincipalCache.Add(organizationKey, exchangePrincipal);
            }
            return(exchangePrincipal);
        }
 private static string GetPrintableId(OrganizationId organizationId, string id)
 {
     return(TenantStoreDataProvider.GetOrganizationKey(organizationId) + "\\" + id);
 }
 protected override void ExpireCache()
 {
     base.ExpireCache();
     TenantStoreDataProvider.exchangePrincipalCache.Remove(TenantStoreDataProvider.GetOrganizationKey(base.Mailbox.MailboxInfo.OrganizationId));
 }
 protected TenantStoreDataProvider(OrganizationId organizationId) : base(new LazilyInitialized <IExchangePrincipal>(() => TenantStoreDataProvider.GetTenantMailbox(organizationId ?? OrganizationId.ForestWideOrgId)), SpecialLogonType.SystemService, OpenAsAdminOrSystemServiceBudgetTypeType.RunAsBackgroundLoad)
 {
     if (organizationId == null && Datacenter.IsMultiTenancyEnabled())
     {
         throw new ArgumentNullException("organizationId", "organizationId can't be null in hosting environment.");
     }
 }