internal static void SetProcessTopologyMode(TopologyMode mode) { if (TopologyMode.Adam == mode) { throw new ArgumentException("mode. Adam topology mode can't be specified"); } if (TopologyMode.Ldap == mode && TopologyProvider.IsTopologyServiceProcess()) { TopologyProvider.isRunningOnTopologyService = true; } ExTraceGlobals.TopologyProviderTracer.TraceDebug <TopologyMode, TopologyMode>(0L, "User set topology mode from {0} to {1}", (TopologyProvider.userSetTopologyMode != null) ? TopologyProvider.userSetTopologyMode.Value : TopologyProvider.CurrentTopologyMode, mode); TopologyProvider.userSetTopologyMode = new TopologyMode?(mode); int num; TopologyMode topologyMode = TopologyProvider.SelectTopologyMode(out num); if (TopologyProvider.staticInstance != null && (TopologyProvider.userSetTopologyMode.Value != TopologyProvider.staticInstance.TopologyMode || TopologyProvider.userSetTopologyMode.Value != topologyMode)) { IDisposable disposable = TopologyProvider.staticInstance as IDisposable; TopologyProvider topologyProvider = TopologyProvider.InitializeInstance(); topologyProvider.PopulateConfigNamingContextsForLocalForest(); topologyProvider.PopulateDomainNamingContextsForLocalForest(); ConnectionPoolManager.Reset(); if (disposable != null) { disposable.Dispose(); } } }
private static TopologyProvider InitializeInstance() { ExTraceGlobals.TopologyProviderTracer.TraceDebug(0L, "Starting InitializeInstance and waiting for the lock"); TopologyProvider result; lock (TopologyProvider.instanceLockRoot) { int adamPort; switch (TopologyProvider.SelectTopologyMode(out adamPort)) { case TopologyMode.ADTopologyService: { ServiceTopologyProvider serviceTopologyProvider = new ServiceTopologyProvider(); serviceTopologyProvider.SuppressDisposeTracker(); TopologyProvider.staticInstance = serviceTopologyProvider; break; } case TopologyMode.Adam: TopologyProvider.staticInstance = new AdamTopologyProvider(adamPort); break; case TopologyMode.Ldap: TopologyProvider.staticInstance = new LdapTopologyProvider(); break; } ExTraceGlobals.TopologyProviderTracer.TraceDebug <int>(0L, "TopologyProvider::InitializeInstance created {0}", (int)TopologyProvider.CurrentTopologyMode); result = TopologyProvider.staticInstance; } return(result); }