internal static void UpdateServerLegdnForDatabaseSite(Task.TaskErrorLoggingDelegate writeErrorDelegate, Task.TaskVerboseLoggingDelegate writeVerboseDelegate, ITopologyConfigurationSession adSession, DatabaseCopy dbCopy)
        {
            ADObjectId hostServer = dbCopy.HostServer;

            PropertyDefinition[] properties = new PropertyDefinition[]
            {
                ServerSchema.ServerSite
            };
            MiniServer miniServer = adSession.ReadMiniServer(hostServer, properties);

            if (miniServer == null)
            {
                writeErrorDelegate(new ADServerNotFoundException(hostServer.ToString()), ErrorCategory.InvalidArgument, null);
            }
            IADToplogyConfigurationSession adSession2 = ADSessionFactory.CreateWrapper(adSession);
            SimpleAdObjectLookup <IADClientAccessArray> findClientAccessArray      = new SimpleAdObjectLookup <IADClientAccessArray>(adSession2);
            SimpleMiniClientAccessServerOrArrayLookup   findMiniClientAccessServer = new SimpleMiniClientAccessServerOrArrayLookup(adSession);
            ADObjectId serverSite = miniServer.ServerSite;
            LegacyDN   legacyDN   = ActiveManagerImplementation.FindClientAccessArrayOrServerFromSite(serverSite, miniServer.Id, findClientAccessArray, findMiniClientAccessServer, AdObjectLookupFlags.ReadThrough);
            ADObjectId parent     = dbCopy.Id.Parent;
            Database   database   = adSession.Read <Database>(parent);

            if (legacyDN != null)
            {
                LegacyDN databaseLegacyDNFromRcaLegacyDN = Database.GetDatabaseLegacyDNFromRcaLegacyDN(legacyDN, database.IsPublicFolderDatabase);
                database.ExchangeLegacyDN = databaseLegacyDNFromRcaLegacyDN.ToString();
                writeVerboseDelegate(Strings.UpdatingLegDnForDatabaseToServer(database.Name, legacyDN.ToString(), legacyDN.ToString()));
                adSession.Save(database);
                return;
            }
            ExTraceGlobals.CmdletsTracer.TraceDebug <ADObjectId>(0L, "Could not find a new CAS machines for site '{0}'. Leaving the database's legdn unchanged.", serverSite);
        }
Esempio n. 2
0
        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);
        }