internal static bool TryLoadTenantRelocationStateSourceReplica(string tenantName, PartitionId partitionId, out RelocationStatusDetailsSource status)
        {
            ITenantConfigurationSession tenantConfigurationSession = DirectorySessionFactory.Default.CreateTenantConfigurationSession(ConsistencyMode.PartiallyConsistent, ADSessionSettings.FromAllTenantsPartitionId(partitionId), 164, "TryLoadTenantRelocationStateSourceReplica", "f:\\15.00.1497\\sources\\dev\\data\\src\\directory\\RelocationCache\\TenantRelocationStateCache.cs");

            tenantConfigurationSession.SessionSettings.TenantConsistencyMode = TenantConsistencyMode.IncludeRetiredTenants;
            ExchangeConfigurationUnit exchangeConfigurationUnitByName = tenantConfigurationSession.GetExchangeConfigurationUnitByName(tenantName);

            if (exchangeConfigurationUnitByName != null)
            {
                status = exchangeConfigurationUnitByName.RelocationStatusDetailsSource;
                return(true);
            }
            status = RelocationStatusDetailsSource.NotStarted;
            return(false);
        }
Beispiel #2
0
 internal static bool IsTenantConfigObjectInCorrectNC(ADObjectId tenantObjectId)
 {
     return(tenantObjectId == null || tenantObjectId.DomainId == null || ADSessionSettings.IsForefrontObject(tenantObjectId) || tenantObjectId.ToDNString().IndexOf("cn=configuration,dc=", StringComparison.OrdinalIgnoreCase) < 0 || !ADSession.IsTenantConfigInDomainNC(tenantObjectId.GetPartitionId().ForestFQDN));
 }
Beispiel #3
0
 public static bool ShouldFilterCNFObject(ADSessionSettings sessionSettings, ADObjectId id)
 {
     return(!sessionSettings.IncludeCNFObject && ADSession.IsCNFObject(id));
 }
        public static IPowerShellBudget Acquire(SecurityIdentifier callerSid, BudgetType budgetType, ADSessionSettings settings)
        {
            PowerShellBudget.VerifyCorrectBudgetType(budgetType);
            PowerShellBudget innerBudget = PowerShellBudgetCache.Singleton.Get(new SidBudgetKey(callerSid, budgetType, false, settings));

            return(new PowerShellBudgetWrapper(innerBudget));
        }
 private static void CreateWrappedContextForRegisterChangeNotification(ref ADObjectId baseDN, ADNotificationCallback callback, object context, out object wrappedContext)
 {
     if (callback == null)
     {
         throw new ArgumentNullException("callback");
     }
     if (baseDN == null)
     {
         ITopologyConfigurationSession topologyConfigurationSession = DirectorySessionFactory.Default.CreateTopologyConfigurationSession(ConsistencyMode.IgnoreInvalid, ADSessionSettings.FromRootOrgScopeSet(), 1089, "CreateWrappedContextForRegisterChangeNotification", "f:\\15.00.1497\\sources\\dev\\data\\src\\directory\\ADNotificationAdapter.cs");
         baseDN = topologyConfigurationSession.GetOrgContainerId();
     }
     ExTraceGlobals.ADNotificationsTracer.TraceDebug <ADObjectId, string, string>(0L, "new change notification registration for {0} from {1}.{2}", baseDN, callback.Method.DeclaringType.FullName, callback.Method.Name);
     wrappedContext = ADNotificationAdapter.CreateWrappingContext(callback, context);
 }
Beispiel #6
0
 // Token: 0x06000A83 RID: 2691 RVA: 0x0002F220 File Offset: 0x0002D420
 public override ITopologyConfigurationSession CreateTopologyConfigurationSession(string domainController, bool readOnly, ConsistencyMode consistencyMode, NetworkCredential networkCredential, ADSessionSettings sessionSettings, ConfigScopes configScope, int callerFileLine, string memberName, string callerFilePath)
 {
     return(DirectorySessionFactory.NonCacheSessionFactory.CreateTopologyConfigurationSession(domainController, readOnly, consistencyMode, networkCredential, sessionSettings, configScope, callerFileLine, memberName, callerFilePath));
 }
Beispiel #7
0
 private ADSchemaDataProvider()
 {
     this.schemaSession                   = DirectorySessionFactory.Default.CreateTopologyConfigurationSession(ConsistencyMode.PartiallyConsistent, ADSessionSettings.FromRootOrgScopeSet(), 82, ".ctor", "f:\\15.00.1497\\sources\\dev\\data\\src\\directory\\ADSchemaDataProvider.cs");
     this.constraintDictionary            = new Dictionary <ADSchemaDataProvider.PropertyKey, PropertyDefinitionConstraint[]>();
     this.schemaAttributeObjectDictionary = new ConcurrentDictionary <string, ADSchemaAttributeObject>(StringComparer.OrdinalIgnoreCase);
 }
Beispiel #8
0
 public IConfigurationSession GetTenantOrTopologyConfigurationSession(string domainController, bool readOnly, ConsistencyMode consistencyMode, NetworkCredential networkCredential, ADSessionSettings sessionSettings, [CallerLineNumber] int callerFileLine = 0, [CallerMemberName] string memberName = null, [CallerFilePath] string callerFilePath = null)
 {
     if (sessionSettings.CurrentOrganizationId == OrganizationId.ForestWideOrgId && sessionSettings.ConfigScopes != ConfigScopes.AllTenants)
     {
         return(this.CreateTopologyConfigurationSession(domainController, readOnly, consistencyMode, networkCredential, sessionSettings, callerFileLine, memberName, callerFilePath));
     }
     return(this.CreateTenantConfigurationSession(domainController, readOnly, consistencyMode, networkCredential, sessionSettings, callerFileLine, memberName, callerFilePath));
 }
Beispiel #9
0
 public IRecipientSession GetTenantOrRootOrgRecipientSession(ConsistencyMode consistencyMode, ADSessionSettings sessionSettings, [CallerLineNumber] int callerFileLine = 0, [CallerMemberName] string memberName = null, [CallerFilePath] string callerFilePath = null)
 {
     return(this.GetTenantOrRootOrgRecipientSession(true, consistencyMode, sessionSettings, callerFileLine, memberName, callerFilePath));
 }
Beispiel #10
0
 public abstract IRootOrganizationRecipientSession CreateRootOrgRecipientSession(string domainController, ADObjectId searchRoot, int lcid, bool readOnly, ConsistencyMode consistencyMode, NetworkCredential networkCredential, ADSessionSettings sessionSettings, [CallerLineNumber] int callerFileLine = 0, [CallerMemberName] string memberName = null, [CallerFilePath] string callerFilePath = null);
Beispiel #11
0
 public IConfigurationSession GetTenantOrTopologyConfigurationSession(bool readOnly, ConsistencyMode consistencyMode, ADSessionSettings sessionSettings, [CallerLineNumber] int callerFileLine = 0, [CallerMemberName] string memberName = null, [CallerFilePath] string callerFilePath = null)
 {
     return(this.GetTenantOrTopologyConfigurationSession(null, readOnly, consistencyMode, null, sessionSettings, callerFileLine, memberName, callerFilePath));
 }
Beispiel #12
0
 public SidBudgetKey(SecurityIdentifier sid, BudgetType budgetType, bool isServiceAccount, ADSessionSettings settings) : base(budgetType, isServiceAccount)
 {
     if (sid == null)
     {
         throw new ArgumentNullException("sid");
     }
     if (settings == null)
     {
         throw new ArgumentNullException("settings");
     }
     this.NtAccount       = SidToAccountMap.Singleton.Get(sid).ToString();
     this.SessionSettings = settings;
     if (sid.AccountDomainSid == null && (sid.IsWellKnown(WellKnownSidType.LocalSystemSid) || sid.IsWellKnown(WellKnownSidType.NetworkServiceSid)))
     {
         ExTraceGlobals.ClientThrottlingTracer.TraceDebug((long)this.GetHashCode(), "[SidBudgetKey.ctor] Using domain sid for local computer account.");
         this.Sid = SidBudgetKey.localMachineSid.Member;
     }
     else
     {
         this.Sid = sid;
     }
     this.cachedToString = this.GetCachedToString();
     this.cachedHashCode = (base.BudgetType.GetHashCode() ^ this.Sid.GetHashCode() ^ base.IsServiceAccountBudget.GetHashCode());
 }
Beispiel #13
0
        private static GlsLookupMode InitializeLookupMode()
        {
            string value = null;

            try
            {
                using (RegistryKey registryKey = Registry.LocalMachine.OpenSubKey(GlsMServDirectorySession.RegistryKey))
                {
                    value = ((registryKey != null) ? ((string)registryKey.GetValue(GlsMServDirectorySession.GlobalDirectoryLookupTypeValue, null)) : null);
                }
            }
            catch (SecurityException ex)
            {
                ExTraceGlobals.GLSTracer.TraceError <string>(0L, "SecurityException: {0}", ex.Message);
            }
            catch (UnauthorizedAccessException ex2)
            {
                ExTraceGlobals.GLSTracer.TraceError <string>(0L, "UnauthorizedAccessException: {0}", ex2.Message);
            }
            GlsLookupMode result;

            if (Enum.TryParse <GlsLookupMode>(value, true, out result))
            {
                return(result);
            }
            if (DatacenterRegistry.IsForefrontForOffice())
            {
                return(GlsLookupMode.GlsOnly);
            }
            ITopologyConfigurationSession topologyConfigurationSession = DirectorySessionFactory.Default.CreateTopologyConfigurationSession(ConsistencyMode.IgnoreInvalid, ADSessionSettings.FromRootOrgScopeSet(), 694, "InitializeLookupMode", "f:\\15.00.1497\\sources\\dev\\data\\src\\directory\\GlsMServDirectorySession.cs");
            ADSite localSite = topologyConfigurationSession.GetLocalSite();

            if (localSite.DistinguishedName.EndsWith("DC=extest,DC=microsoft,DC=com"))
            {
                return(GlsLookupMode.MServOnly);
            }
            return(GlsLookupMode.BothGLSAndMServ);
        }
        private static TenantRelocationState LoadTenantRelocationState(string tenantName, PartitionId partitionId)
        {
            ITenantConfigurationSession session = DirectorySessionFactory.NonCacheSessionFactory.CreateTenantConfigurationSession(ConsistencyMode.PartiallyConsistent, ADSessionSettings.FromAllTenantsPartitionId(partitionId), 185, "LoadTenantRelocationState", "f:\\15.00.1497\\sources\\dev\\data\\src\\directory\\RelocationCache\\TenantRelocationStateCache.cs");
            ExchangeConfigurationUnit   exchangeCUAndThrowIfNotFound = TenantRelocationStateCache.GetExchangeCUAndThrowIfNotFound(tenantName, session);

            if (exchangeCUAndThrowIfNotFound.IsCached)
            {
                ExTraceGlobals.TenantRelocationTracer.TraceDebug <string>(0L, "TenantRelocationStateCache::LoadTenantRelocationState(): Tenant {0} found in cache.", tenantName);
                if ((DateTime.UtcNow - exchangeCUAndThrowIfNotFound.WhenReadUTC).Value.TotalSeconds >= 30.0)
                {
                    ITenantConfigurationSession session2 = DirectorySessionFactory.NonCacheSessionFactory.CreateTenantConfigurationSession(ConsistencyMode.PartiallyConsistent, ADSessionSettings.FromAllTenantsPartitionId(partitionId), 203, "LoadTenantRelocationState", "f:\\15.00.1497\\sources\\dev\\data\\src\\directory\\RelocationCache\\TenantRelocationStateCache.cs");
                    exchangeCUAndThrowIfNotFound = TenantRelocationStateCache.GetExchangeCUAndThrowIfNotFound(tenantName, session2);
                    ITenantConfigurationSession tenantConfigurationSession = DirectorySessionFactory.CacheSessionFactory.CreateTenantConfigurationSession(ConsistencyMode.PartiallyConsistent, ADSessionSettings.FromAllTenantsPartitionId(partitionId), 206, "LoadTenantRelocationState", "f:\\15.00.1497\\sources\\dev\\data\\src\\directory\\RelocationCache\\TenantRelocationStateCache.cs");
                    tenantConfigurationSession.Delete(exchangeCUAndThrowIfNotFound);
                    tenantConfigurationSession.Save(exchangeCUAndThrowIfNotFound);
                }
            }
            if ((string.IsNullOrEmpty(exchangeCUAndThrowIfNotFound.TargetForest) && string.IsNullOrEmpty(exchangeCUAndThrowIfNotFound.RelocationSourceForestRaw)) || (!string.IsNullOrEmpty(exchangeCUAndThrowIfNotFound.RelocationSourceForestRaw) && exchangeCUAndThrowIfNotFound.RelocationStateRequested == RelocationStateRequested.Cleanup))
            {
                ExTraceGlobals.TenantRelocationTracer.TraceDebug <string, string, bool>(0L, "TenantRelocationStateCache::LoadTenantRelocationState(): Found tenant {0} on DC {1} Cached {2} - not being relocated.", tenantName, exchangeCUAndThrowIfNotFound.OriginatingServer, exchangeCUAndThrowIfNotFound.IsCached);
                return(new TenantRelocationState(partitionId.ForestFQDN, TenantRelocationStatus.NotStarted));
            }
            if (string.IsNullOrEmpty(exchangeCUAndThrowIfNotFound.ExternalDirectoryOrganizationId))
            {
                ExTraceGlobals.TenantRelocationTracer.TraceDebug <string, string, bool>(0L, "TenantRelocationStateCache::LoadTenantRelocationState(): Found tenant {0} on DC {1} Cached {2} - prepared for deletion.", tenantName, exchangeCUAndThrowIfNotFound.OriginatingServer, exchangeCUAndThrowIfNotFound.IsCached);
                TenantRelocationStatus sourceForestState;
                if (!string.IsNullOrEmpty(exchangeCUAndThrowIfNotFound.TargetForest))
                {
                    sourceForestState = exchangeCUAndThrowIfNotFound.RelocationStatus;
                }
                else
                {
                    sourceForestState = TenantRelocationStatus.NotStarted;
                }
                return(new TenantRelocationState(partitionId.ForestFQDN, sourceForestState));
            }
            if (!string.IsNullOrEmpty(exchangeCUAndThrowIfNotFound.TargetForest))
            {
                TenantRelocationRequest tenantRelocationRequest;
                Exception ex;
                TenantRelocationRequest.LoadOtherForestObjectInternal(null, exchangeCUAndThrowIfNotFound.TargetForest, exchangeCUAndThrowIfNotFound.DistinguishedName, exchangeCUAndThrowIfNotFound.ExternalDirectoryOrganizationId, true, out tenantRelocationRequest, out ex);
                if (ex != null && !(ex is CannotFindTargetTenantException))
                {
                    throw ex;
                }
                ExTraceGlobals.TenantRelocationTracer.TraceDebug <string, string>(0L, "TenantRelocationStateCache::LoadTenantRelocationState(): Found tenant {0} on DC {1} - this is relocation source.", tenantName, (tenantRelocationRequest != null) ? tenantRelocationRequest.OriginatingServer : "<unknown>");
                return(new TenantRelocationState(partitionId.ForestFQDN, exchangeCUAndThrowIfNotFound.RelocationStatus, exchangeCUAndThrowIfNotFound.TargetForest, (RelocationStatusDetailsDestination)((tenantRelocationRequest != null) ? tenantRelocationRequest.RelocationStatusDetailsRaw : RelocationStatusDetails.NotStarted), exchangeCUAndThrowIfNotFound.OrganizationId, (tenantRelocationRequest != null) ? tenantRelocationRequest.OrganizationId : null));
            }
            else
            {
                Exception ex;
                TenantRelocationRequest tenantRelocationRequest2;
                TenantRelocationRequest.LoadOtherForestObjectInternal(null, exchangeCUAndThrowIfNotFound.RelocationSourceForestRaw, exchangeCUAndThrowIfNotFound.DistinguishedName, exchangeCUAndThrowIfNotFound.ExternalDirectoryOrganizationId, false, out tenantRelocationRequest2, out ex);
                if (ex == null)
                {
                    ExTraceGlobals.TenantRelocationTracer.TraceDebug(0L, string.Format("TenantRelocationStateCache::LoadTenantRelocationState(): Found tenant {0} on DC {1} - this is relocation target.", tenantName, (tenantRelocationRequest2 != null) ? tenantRelocationRequest2.OriginatingServer : "<unknown>"));
                    return(new TenantRelocationState(exchangeCUAndThrowIfNotFound.RelocationSourceForestRaw, (tenantRelocationRequest2 != null) ? tenantRelocationRequest2.RelocationStatus : TenantRelocationStatus.NotStarted, partitionId.ForestFQDN, (RelocationStatusDetailsDestination)exchangeCUAndThrowIfNotFound.RelocationStatusDetailsSource, (tenantRelocationRequest2 != null) ? tenantRelocationRequest2.OrganizationId : null, exchangeCUAndThrowIfNotFound.OrganizationId));
                }
                if (ex is CannotFindTargetTenantException)
                {
                    return(new TenantRelocationState(partitionId.ForestFQDN, TenantRelocationStatus.NotStarted));
                }
                throw ex;
            }
        }
Beispiel #15
0
 // Token: 0x06000A87 RID: 2695 RVA: 0x0002F330 File Offset: 0x0002D530
 public override IRootOrganizationRecipientSession CreateRootOrgRecipientSession(string domainController, ADObjectId searchRoot, int lcid, bool readOnly, ConsistencyMode consistencyMode, NetworkCredential networkCredential, ADSessionSettings sessionSettings, int callerFileLine, string memberName, string callerFilePath)
 {
     return(DirectorySessionFactory.NonCacheSessionFactory.CreateRootOrgRecipientSession(domainController, searchRoot, lcid, readOnly, consistencyMode, networkCredential, sessionSettings, callerFileLine, memberName, callerFilePath));
 }
Beispiel #16
0
 public IRecipientSession GetTenantOrRootOrgRecipientSession(bool readOnly, ConsistencyMode consistencyMode, ADSessionSettings sessionSettings, [CallerLineNumber] int callerFileLine = 0, [CallerMemberName] string memberName = null, [CallerFilePath] string callerFilePath = null)
 {
     return(this.GetTenantOrRootOrgRecipientSession(null, null, CultureInfo.CurrentCulture.LCID, readOnly, consistencyMode, null, sessionSettings, callerFileLine, memberName, callerFilePath));
 }
Beispiel #17
0
 // Token: 0x06000A81 RID: 2689 RVA: 0x0002F1E6 File Offset: 0x0002D3E6
 public override ITopologyConfigurationSession CreateTopologyConfigurationSession(bool readOnly, ConsistencyMode consistencyMode, ADSessionSettings sessionSettings, int callerFileLine, string memberName, string callerFilePath)
 {
     return(DirectorySessionFactory.NonCacheSessionFactory.CreateTopologyConfigurationSession(readOnly, consistencyMode, sessionSettings, callerFileLine, memberName, callerFilePath));
 }
Beispiel #18
0
 public IRecipientSession GetTenantOrRootOrgRecipientSession(string domainController, bool readOnly, ConsistencyMode consistencyMode, NetworkCredential networkCredential, ADSessionSettings sessionSettings, ConfigScopes configScope, [CallerLineNumber] int callerFileLine = 0, [CallerMemberName] string memberName = null, [CallerFilePath] string callerFilePath = null)
 {
     return(this.GetTenantOrRootOrgRecipientSession(domainController, null, CultureInfo.CurrentCulture.LCID, readOnly, consistencyMode, networkCredential, sessionSettings, configScope, callerFileLine, memberName, callerFilePath));
 }
Beispiel #19
0
        // Token: 0x06000A85 RID: 2693 RVA: 0x0002F2A4 File Offset: 0x0002D4A4
        public override ITenantRecipientSession CreateTenantRecipientSession(string domainController, ADObjectId searchRoot, int lcid, bool readOnly, ConsistencyMode consistencyMode, NetworkCredential networkCredential, ADSessionSettings sessionSettings, ConfigScopes configScopes, int callerFileLine, string memberName, string callerFilePath)
        {
            bool cacheSessionForDeletingOnly = true;

            if (networkCredential == null && string.IsNullOrEmpty(domainController))
            {
                cacheSessionForDeletingOnly = false;
            }
            return(new CompositeTenantRecipientSession(DirectorySessionFactory.CacheSessionFactory.CreateTenantRecipientSession(domainController, searchRoot, lcid, readOnly, consistencyMode, networkCredential, sessionSettings, configScopes, callerFileLine, memberName, callerFilePath), DirectorySessionFactory.NonCacheSessionFactory.CreateTenantRecipientSession(domainController, searchRoot, lcid, readOnly, consistencyMode, networkCredential, sessionSettings, configScopes, callerFileLine, memberName, callerFilePath), cacheSessionForDeletingOnly));
        }
Beispiel #20
0
 public IRecipientSession GetTenantOrRootOrgRecipientSession(string domainController, ADObjectId searchRoot, int lcid, bool readOnly, ConsistencyMode consistencyMode, NetworkCredential networkCredential, ADSessionSettings sessionSettings, ConfigScopes configScope, [CallerLineNumber] int callerFileLine = 0, [CallerMemberName] string memberName = null, [CallerFilePath] string callerFilePath = null)
 {
     if (sessionSettings.CurrentOrganizationId == OrganizationId.ForestWideOrgId && sessionSettings.ConfigScopes != ConfigScopes.AllTenants)
     {
         return(this.CreateRootOrgRecipientSession(domainController, searchRoot, lcid, readOnly, consistencyMode, networkCredential, sessionSettings, configScope, callerFileLine, memberName, callerFilePath));
     }
     return(this.CreateTenantRecipientSession(domainController, searchRoot, lcid, readOnly, consistencyMode, networkCredential, sessionSettings, configScope, callerFileLine, memberName, callerFilePath));
 }
Beispiel #21
0
        private static TimeSpan CalculateCacheItemExpirationWindow(bool dataFromOfflineService, string tenantName, Guid externalOrgId, PartitionId accountPartitionId)
        {
            if (dataFromOfflineService)
            {
                return(TimeSpan.FromMinutes((double)ConfigBase <AdDriverConfigSchema> .GetConfig <int>("OfflineDataCacheExpirationTimeInMinutes")));
            }
            if (!ForestTenantRelocationsCache.IsTenantRelocationAllowed(accountPartitionId.ForestFQDN))
            {
                return(ExpiringTenantRelocationStateValue.TenantRelocationStateExpirationWindowProvider.DefaultExpirationWindow);
            }
            if (!string.IsNullOrEmpty(tenantName))
            {
                return(TenantRelocationStateCache.GetTenantCacheExpirationWindow(tenantName, accountPartitionId));
            }
            ITenantConfigurationSession tenantConfigurationSession            = DirectorySessionFactory.Default.CreateTenantConfigurationSession(ConsistencyMode.PartiallyConsistent, ADSessionSettings.FromAllTenantsPartitionId(accountPartitionId), 110, "CalculateCacheItemExpirationWindow", "f:\\15.00.1497\\sources\\dev\\data\\src\\directory\\TenantPartitionCacheItem.cs");
            ExchangeConfigurationUnit   exchangeConfigurationUnitByExternalId = tenantConfigurationSession.GetExchangeConfigurationUnitByExternalId(externalOrgId);

            if (exchangeConfigurationUnitByExternalId != null)
            {
                tenantName = ((ADObjectId)exchangeConfigurationUnitByExternalId.Identity).Parent.Name;
                return(TenantRelocationStateCache.GetTenantCacheExpirationWindow(tenantName, accountPartitionId));
            }
            return(ExpiringTenantRelocationStateValue.TenantRelocationStateExpirationWindowProvider.DefaultExpirationWindow);
        }
Beispiel #22
0
 public abstract ITenantConfigurationSession CreateTenantConfigurationSession(bool readOnly, ConsistencyMode consistencyMode, ADSessionSettings sessionSettings, [CallerLineNumber] int callerFileLine = 0, [CallerMemberName] string memberName = null, [CallerFilePath] string callerFilePath = null);
        public static ADNotificationRequestCookie RegisterExchangeTopologyChangeNotification(ADNotificationCallback callback, object context, ExchangeTopologyScope topologyType)
        {
            ITopologyConfigurationSession topologyConfigurationSession = DirectorySessionFactory.Default.CreateTopologyConfigurationSession(true, ConsistencyMode.PartiallyConsistent, ADSessionSettings.FromRootOrgScopeSet(), 387, "RegisterExchangeTopologyChangeNotification", "f:\\15.00.1497\\sources\\dev\\data\\src\\directory\\ADNotificationAdapter.cs");
            ADObjectId childId        = topologyConfigurationSession.ConfigurationNamingContext.GetChildId("CN", "Sites");
            ADObjectId childId2       = childId.GetChildId("CN", "Inter-Site Transports").GetChildId("CN", "IP");
            ADObjectId orgContainerId = topologyConfigurationSession.GetOrgContainerId();

            ADNotificationRequest[] requests;
            switch (topologyType)
            {
            case ExchangeTopologyScope.Complete:
                requests = new ADNotificationRequest[]
                {
                    ADNotificationAdapter.RegisterChangeNotification <ADServer>(childId, callback, context).Requests[0],
                    ADNotificationAdapter.RegisterChangeNotification <ADSite>(childId, callback, context).Requests[0],
                    ADNotificationAdapter.RegisterChangeNotification <ADSiteLink>(childId2, callback, context).Requests[0],
                    ADNotificationAdapter.RegisterChangeNotification <ADSubnet>(childId, callback, context).Requests[0],
                    ADNotificationAdapter.RegisterChangeNotification <ADVirtualDirectory>(orgContainerId, callback, context).Requests[0],
                    ADNotificationAdapter.RegisterChangeNotification <Server>(orgContainerId, callback, context).Requests[0],
                    ADNotificationAdapter.RegisterChangeNotification <ReceiveConnector>(orgContainerId, callback, context).Requests[0],
                    ADNotificationAdapter.RegisterChangeNotification <ADEmailTransport>(orgContainerId, callback, context).Requests[0]
                };
                break;

            case ExchangeTopologyScope.ServerAndSiteTopology:
                requests = new ADNotificationRequest[]
                {
                    ADNotificationAdapter.RegisterChangeNotification <ADSite>(childId, callback, context).Requests[0],
                    ADNotificationAdapter.RegisterChangeNotification <ADSiteLink>(childId2, callback, context).Requests[0],
                    ADNotificationAdapter.RegisterChangeNotification <Server>(orgContainerId, callback, context).Requests[0]
                };
                break;

            case ExchangeTopologyScope.ADAndExchangeServerAndSiteTopology:
                requests = new ADNotificationRequest[]
                {
                    ADNotificationAdapter.RegisterChangeNotification <ADServer>(childId, callback, context).Requests[0],
                    ADNotificationAdapter.RegisterChangeNotification <ADSite>(childId, callback, context).Requests[0],
                    ADNotificationAdapter.RegisterChangeNotification <ADSiteLink>(childId2, callback, context).Requests[0],
                    ADNotificationAdapter.RegisterChangeNotification <Server>(orgContainerId, callback, context).Requests[0]
                };
                break;

            case ExchangeTopologyScope.ADAndExchangeServerAndSiteAndVirtualDirectoryTopology:
                requests = new ADNotificationRequest[]
                {
                    ADNotificationAdapter.RegisterChangeNotification <ADServer>(childId, callback, context).Requests[0],
                    ADNotificationAdapter.RegisterChangeNotification <ADSite>(childId, callback, context).Requests[0],
                    ADNotificationAdapter.RegisterChangeNotification <ADSiteLink>(childId2, callback, context).Requests[0],
                    ADNotificationAdapter.RegisterChangeNotification <Server>(orgContainerId, callback, context).Requests[0],
                    ADNotificationAdapter.RegisterChangeNotification <ADVirtualDirectory>(orgContainerId, callback, context).Requests[0]
                };
                break;

            default:
                throw new ArgumentException("topologyType", "topologyType");
            }
            return(new ADNotificationRequestCookie(requests));
        }
Beispiel #24
0
 public ITenantConfigurationSession CreateTenantConfigurationSession(string domainController, bool readOnly, ConsistencyMode consistencyMode, ADSessionSettings sessionSettings, [CallerLineNumber] int callerFileLine = 0, [CallerMemberName] string memberName = null, [CallerFilePath] string callerFilePath = null)
 {
     return(this.CreateTenantConfigurationSession(domainController, readOnly, consistencyMode, null, sessionSettings, callerFileLine, memberName, callerFilePath));
 }
Beispiel #25
0
        internal static IDirectorySession CreateScopedSession(IDirectorySession session, ADSessionSettings underSessionSettings)
        {
            bool flag = object.Equals(session.SessionSettings.PartitionId, underSessionSettings.PartitionId);
            IConfigurationSession configurationSession = session as IConfigurationSession;
            IDirectorySession     directorySession;

            if (configurationSession != null)
            {
                directorySession = DirectorySessionFactory.Default.GetTenantOrTopologyConfigurationSession(flag ? configurationSession.DomainController : null, configurationSession.ReadOnly, configurationSession.ConsistencyMode, flag ? configurationSession.NetworkCredential : null, underSessionSettings, 395, "CreateScopedSession", "f:\\15.00.1497\\sources\\dev\\data\\src\\directory\\ADSession.cs");
            }
            else
            {
                IRecipientSession recipientSession = session as IRecipientSession;
                if (recipientSession.SessionSettings.IncludeSoftDeletedObjects)
                {
                    underSessionSettings.IncludeSoftDeletedObjects = true;
                    directorySession = DirectorySessionFactory.Default.GetTenantOrRootOrgRecipientSession(flag ? recipientSession.DomainController : null, flag ? recipientSession.SearchRoot : null, recipientSession.Lcid, recipientSession.ReadOnly, recipientSession.ConsistencyMode, flag ? recipientSession.NetworkCredential : null, underSessionSettings, recipientSession.ConfigScope, 410, "CreateScopedSession", "f:\\15.00.1497\\sources\\dev\\data\\src\\directory\\ADSession.cs");
                }
                else
                {
                    directorySession = DirectorySessionFactory.Default.GetTenantOrRootOrgRecipientSession(flag ? recipientSession.DomainController : null, flag ? recipientSession.SearchRoot : null, recipientSession.Lcid, recipientSession.ReadOnly, recipientSession.ConsistencyMode, flag ? recipientSession.NetworkCredential : null, underSessionSettings, 422, "CreateScopedSession", "f:\\15.00.1497\\sources\\dev\\data\\src\\directory\\ADSession.cs");
                }
                if (recipientSession.IsReducedRecipientSession())
                {
                    directorySession = DirectorySessionFactory.Default.GetReducedRecipientSession((IRecipientSession)directorySession, 434, "CreateScopedSession", "f:\\15.00.1497\\sources\\dev\\data\\src\\directory\\ADSession.cs");
                }
            }
            ADSession.CopySettableSessionProperties(session, directorySession);
            return(directorySession);
        }
Beispiel #26
0
 public abstract ITenantConfigurationSession CreateTenantConfigurationSession(string domainController, bool readOnly, ConsistencyMode consistencyMode, NetworkCredential networkCredential, ADSessionSettings sessionSettings, [CallerLineNumber] int callerFileLine = 0, [CallerMemberName] string memberName = null, [CallerFilePath] string callerFilePath = null);
Beispiel #27
0
 public static bool ShouldFilterSoftDeleteObject(ADSessionSettings sessionSettings, ADObjectId id)
 {
     return(!sessionSettings.IncludeSoftDeletedObjects && !sessionSettings.IncludeInactiveMailbox && -1 != id.DistinguishedName.IndexOf(",OU=Soft Deleted Objects,", StringComparison.OrdinalIgnoreCase));
 }
Beispiel #28
0
 // Token: 0x06000A7B RID: 2683 RVA: 0x0002F070 File Offset: 0x0002D270
 public override ITenantConfigurationSession CreateTenantConfigurationSession(ConsistencyMode consistencyMode, ADSessionSettings sessionSettings, int callerFileLine, string memberName, string callerFilePath)
 {
     return(new CompositeTenantConfigurationSession(DirectorySessionFactory.CacheSessionFactory.CreateTenantConfigurationSession(consistencyMode, sessionSettings, callerFileLine, memberName, callerFilePath), DirectorySessionFactory.NonCacheSessionFactory.CreateTenantConfigurationSession(consistencyMode, sessionSettings, callerFileLine, memberName, callerFilePath), false));
 }
        public static OwaMailboxPolicy GetDefaultOwaMailboxPolicy(OrganizationId orgId)
        {
            IConfigurationSession tenantOrTopologyConfigurationSession = DirectorySessionFactory.Default.GetTenantOrTopologyConfigurationSession(ConsistencyMode.PartiallyConsistent, ADSessionSettings.FromOrganizationIdWithoutRbacScopesServiceOnly(orgId), 161, "GetDefaultOwaMailboxPolicy", "f:\\15.00.1497\\sources\\dev\\data\\src\\directory\\OwaSegmentationSettings.cs");

            OwaMailboxPolicy[] array = tenantOrTopologyConfigurationSession.Find <OwaMailboxPolicy>(null, QueryScope.SubTree, new ComparisonFilter(ComparisonOperator.Equal, OwaMailboxPolicySchema.IsDefault, true), new SortBy(ADObjectSchema.WhenChanged, SortOrder.Descending), 1);
            if (array != null && array.Length > 0)
            {
                return(array[0]);
            }
            return(null);
        }
        public static bool TryGetTenantRelocationStateByObjectId(ADObjectId identity, out TenantRelocationState state, out bool isSourceTenant)
        {
            ArgumentValidator.ThrowIfNull("identity", identity);
            state          = null;
            isSourceTenant = true;
            PartitionId partitionId = identity.GetPartitionId();

            if (!ForestTenantRelocationsCache.IsTenantRelocationAllowed(partitionId.ForestFQDN))
            {
                return(false);
            }
            ITenantConfigurationSession tenantConfigurationSession = DirectorySessionFactory.Default.CreateTenantConfigurationSession(ConsistencyMode.PartiallyConsistent, ADSessionSettings.FromAllTenantsPartitionId(partitionId), 595, "TryGetTenantRelocationStateByObjectId", "f:\\15.00.1497\\sources\\dev\\data\\src\\directory\\RelocationCache\\TenantRelocationStateCache.cs");
            ADObjectId configurationUnitsRoot = tenantConfigurationSession.GetConfigurationUnitsRoot();

            if (configurationUnitsRoot.Equals(identity))
            {
                return(false);
            }
            ADObjectId adobjectId = null;

            if (identity.IsDescendantOf(configurationUnitsRoot))
            {
                adobjectId = identity.GetFirstGenerationDecendantOf(configurationUnitsRoot);
            }
            else
            {
                ADObjectId hostedOrganizationsRoot = tenantConfigurationSession.GetHostedOrganizationsRoot();
                if (hostedOrganizationsRoot.Equals(identity))
                {
                    return(false);
                }
                if (identity.IsDescendantOf(hostedOrganizationsRoot))
                {
                    adobjectId = identity.GetFirstGenerationDecendantOf(hostedOrganizationsRoot);
                }
            }
            if (adobjectId == null)
            {
                return(false);
            }
            try
            {
                state = TenantRelocationStateCache.GetTenantRelocationState(adobjectId.Name, partitionId, out isSourceTenant, false);
            }
            catch (CannotResolveTenantNameException)
            {
                return(false);
            }
            return(true);
        }