public static ActiveManagerOperationResult TryGetCachedServerForDatabaseBasic(Guid mdbGuid, GetServerForDatabaseFlags gsfdFlags, out DatabaseLocationInfo databaseLocationInfo) { Exception ex = null; databaseLocationInfo = null; ActiveManager cachingActiveManagerInstance = ActiveManager.GetCachingActiveManagerInstance(); try { databaseLocationInfo = cachingActiveManagerInstance.GetServerForDatabase(mdbGuid, gsfdFlags, NullPerformanceDataLogger.Instance); return(new ActiveManagerOperationResult(true, ex)); } catch (DatabaseNotFoundException ex2) { ex = ex2; } catch (ObjectNotFoundException ex3) { ex = ex3; } catch (StoragePermanentException ex4) { ex = ex4; } catch (StorageTransientException ex5) { ex = ex5; } catch (ServerForDatabaseNotFoundException ex6) { ex = ex6; } return(new ActiveManagerOperationResult(false, ex)); }
internal static void CalculatePreferredHomeServerInternal(ActiveManager activeManager, IADDatabase database, ITopologyConfigurationSession adSession, IFindAdObject <IADDatabaseAvailabilityGroup> dagLookup, IFindAdObject <IADClientAccessArray> findClientAccessArray, IFindMiniClientAccessServerOrArray findMiniClientAccessServer, out LegacyDN preferredRpcClientAccessServerLegacyDN, out ADObjectId preferredServerSite) { Util.ThrowOnNullArgument(activeManager, "activeManager"); preferredRpcClientAccessServerLegacyDN = LegacyDN.Parse(database.RpcClientAccessServerLegacyDN); ADObjectId masterServerOrAvailabilityGroup = database.MasterServerOrAvailabilityGroup; IADDatabaseAvailabilityGroup iaddatabaseAvailabilityGroup = (masterServerOrAvailabilityGroup != null) ? dagLookup.ReadAdObjectByObjectId(masterServerOrAvailabilityGroup) : null; if (iaddatabaseAvailabilityGroup == null || !iaddatabaseAvailabilityGroup.AllowCrossSiteRpcClientAccess) { ExTraceGlobals.ActiveManagerClientTracer.TraceDebug <ADObjectId, ADObjectId>((long)activeManager.GetHashCode(), "CalculatePreferredHomeServerInternal: Cross-site is not allowed. Database = '{0}', DAG = '{1}'", database.Id, masterServerOrAvailabilityGroup); DatabaseLocationInfo databaseLocationInfo = null; preferredServerSite = null; try { databaseLocationInfo = activeManager.GetServerForDatabase(database.Guid, GetServerForDatabaseFlags.IgnoreAdSiteBoundary, NullPerformanceDataLogger.Instance); if (databaseLocationInfo != null) { preferredServerSite = databaseLocationInfo.ServerSite; } } catch (DatabaseNotFoundException arg) { ExTraceGlobals.ActiveManagerClientTracer.TraceDebug <ADObjectId, DatabaseNotFoundException>((long)activeManager.GetHashCode(), "CalculatePreferredHomeServerInternal: The database '{0}' does not exist. Exception = {1}", database.Id, arg); preferredServerSite = null; } catch (ObjectNotFoundException arg2) { ExTraceGlobals.ActiveManagerClientTracer.TraceDebug <ADObjectId, ObjectNotFoundException>((long)activeManager.GetHashCode(), "CalculatePreferredHomeServerInternal: Server hosting the database {0} cannot be found. Exception = {1}", database.Id, arg2); preferredServerSite = null; } if (preferredServerSite == null) { preferredRpcClientAccessServerLegacyDN = null; return; } IADMiniClientAccessServerOrArray iadminiClientAccessServerOrArray = findMiniClientAccessServer.FindMiniClientAccessServerOrArrayByLegdn(databaseLocationInfo.RpcClientAccessServerLegacyDN); if (iadminiClientAccessServerOrArray != null && iadminiClientAccessServerOrArray.ServerSite != null && iadminiClientAccessServerOrArray.ServerSite.Equals(preferredServerSite)) { preferredRpcClientAccessServerLegacyDN = LegacyDN.Parse(databaseLocationInfo.RpcClientAccessServerLegacyDN); return; } preferredRpcClientAccessServerLegacyDN = ActiveManagerImplementation.FindClientAccessArrayOrServerFromSite(preferredServerSite, database.HostServerForPreference1, findClientAccessArray, findMiniClientAccessServer, AdObjectLookupFlags.None); return; } else { IADMiniClientAccessServerOrArray iadminiClientAccessServerOrArray2 = findMiniClientAccessServer.FindMiniClientAccessServerOrArrayByLegdn(preferredRpcClientAccessServerLegacyDN.ToString()); ExTraceGlobals.ActiveManagerClientTracer.TraceDebug <LegacyDN, string>((long)activeManager.GetHashCode(), "CalculatePreferredHomeServerInternal. preferredRpcClientAccessServerLegacyDN = {0}, preferredMiniServer = {1}.", preferredRpcClientAccessServerLegacyDN, (iadminiClientAccessServerOrArray2 == null) ? "<null>" : iadminiClientAccessServerOrArray2.Fqdn); if (iadminiClientAccessServerOrArray2 == null) { preferredServerSite = null; preferredRpcClientAccessServerLegacyDN = null; return; } preferredRpcClientAccessServerLegacyDN = LegacyDN.Parse(iadminiClientAccessServerOrArray2.ExchangeLegacyDN); preferredServerSite = iadminiClientAccessServerOrArray2.ServerSite; return; } }
public static ActiveManager CreateRemoteActiveManager(string domainControllerName, NetworkCredential networkCredential, bool createCachingActiveManager) { ITopologyConfigurationSession topologyConfigurationSession = DirectorySessionFactory.Default.CreateTopologyConfigurationSession(domainControllerName, true, ConsistencyMode.FullyConsistent, networkCredential, ADSessionSettings.FromRootOrgScopeSet(), 1071, "CreateRemoteActiveManager", "f:\\15.00.1497\\sources\\dev\\data\\src\\storage\\ActiveManager\\ActiveManager.cs"); IADToplogyConfigurationSession adSession = ADSessionFactory.CreateWrapper(topologyConfigurationSession); IFindAdObject <IADDatabaseAvailabilityGroup> dagLookup; IFindAdObject <IADServer> serverLookup; IFindMiniServer miniServerLookup; IFindAdObject <IADClientAccessArray> casLookup; IFindMiniClientAccessServerOrArray miniCasArrayLookup; IFindAdObject <IADDatabase> databaseLookup; if (createCachingActiveManager) { TimeSpan timeSpan = new TimeSpan(0, 0, 75); dagLookup = new AdObjectLookupCache <IADDatabaseAvailabilityGroup>(adSession, timeSpan, timeSpan, ActiveManager.s_cacheLockTimeout, AdObjectLookupCache <IADDatabaseAvailabilityGroup> .AdOperationTimeout); serverLookup = new AdObjectLookupCache <IADServer>(adSession, AdObjectLookupCache <IADServer> .TimeToLive, AdObjectLookupCache <IADServer> .TimeToNegativeLive, ActiveManager.s_cacheLockTimeout, AdObjectLookupCache <IADServer> .AdOperationTimeout); miniServerLookup = new MiniServerLookupCache(adSession, MiniServerLookupCache.TimeToLive, MiniServerLookupCache.TimeToNegativeLive, ActiveManager.s_cacheLockTimeout, MiniServerLookupCache.AdOperationTimeout); casLookup = new AdObjectLookupCache <IADClientAccessArray>(adSession, AdObjectLookupCache <IADClientAccessArray> .TimeToLive, AdObjectLookupCache <IADClientAccessArray> .TimeToNegativeLive, ActiveManager.s_cacheLockTimeout, AdObjectLookupCache <IADClientAccessArray> .AdOperationTimeout); miniCasArrayLookup = new MiniClientAccessServerOrArrayLookupCache(topologyConfigurationSession, MiniClientAccessServerOrArrayLookupCache.TimeToLive, MiniClientAccessServerOrArrayLookupCache.TimeToNegativeLive, ActiveManager.s_cacheLockTimeout, MiniClientAccessServerOrArrayLookupCache.AdOperationTimeout); databaseLookup = new AdObjectLookupCache <IADDatabase>(adSession, AdObjectLookupCache <IADDatabase> .TimeToLive, AdObjectLookupCache <IADDatabase> .TimeToNegativeLive, ActiveManager.s_cacheLockTimeout, AdObjectLookupCache <IADDatabase> .AdOperationTimeout); } else { dagLookup = new SimpleAdObjectLookup <IADDatabaseAvailabilityGroup>(adSession); serverLookup = new SimpleAdObjectLookup <IADServer>(adSession); miniServerLookup = new SimpleMiniServerLookup(adSession); casLookup = new SimpleAdObjectLookup <IADClientAccessArray>(adSession); miniCasArrayLookup = new SimpleMiniClientAccessServerOrArrayLookup(topologyConfigurationSession); databaseLookup = new SimpleAdObjectLookup <IADDatabase>(adSession); } ActiveManager activeManager = new ActiveManager(createCachingActiveManager, dagLookup, serverLookup, miniServerLookup, casLookup, miniCasArrayLookup, databaseLookup, topologyConfigurationSession, false); activeManager.m_networkCredential = networkCredential; ExTraceGlobals.ActiveManagerClientTracer.TraceDebug <string>(0L, "Created an ActiveManager suitable for cross-forest queries, dcName={0}.", domainControllerName); return(activeManager); }
private IADDatabase GetDatabaseByGuidEx(Guid databaseId, AdObjectLookupFlags flags, IPerformanceDataLogger perfLogger) { return(ActiveManager.GetDatabaseByGuidEx(this.m_databaseLookup, databaseId, flags, perfLogger)); }
private static IADDatabase GetDatabaseByGuid(IFindAdObject <IADDatabase> databaseLookup, Guid databaseId) { return(ActiveManager.GetDatabaseByGuidEx(databaseLookup, databaseId, AdObjectLookupFlags.None, NullPerformanceDataLogger.Instance)); }
public static ActiveManagerOperationResult TryGetCachedServerForDatabaseBasic(Guid mdbGuid, out DatabaseLocationInfo databaseLocationInfo) { return(ActiveManager.TryGetCachedServerForDatabaseBasic(mdbGuid, GetServerForDatabaseFlags.IgnoreAdSiteBoundary | GetServerForDatabaseFlags.BasicQuery, out databaseLocationInfo)); }
public static ActiveManager GetActiveManagerInstance() { return(ActiveManager.GetNoncachingActiveManagerInstance()); }