Ejemplo n.º 1
0
        private long ReadDcHighestUSN(PartitionId partitionId, string domainController, bool useConfigNC, out Guid invocationId, out WatermarkMap watermarks)
        {
            ITopologyConfigurationSession topologyConfigurationSession = DirectorySessionFactory.Default.CreateTopologyConfigurationSession(domainController, true, ConsistencyMode.PartiallyConsistent, null, ADSessionSettings.FromAccountPartitionRootOrgScopeSet(partitionId), 452, "ReadDcHighestUSN", "f:\\15.00.1497\\sources\\dev\\Management\\src\\Management\\Relocation\\RemoveTenantRelocationRequest.cs");

            invocationId = topologyConfigurationSession.GetInvocationIdByFqdn(domainController);
            topologyConfigurationSession.UseConfigNC = useConfigNC;
            watermarks = SyncConfiguration.GetReplicationCursors(topologyConfigurationSession, useConfigNC, false);
            return(watermarks[invocationId]);
        }
Ejemplo n.º 2
0
        public static SyncCookie ResolveSyncCookie(byte[] cookieData, IDirectorySession session, Task.TaskVerboseLoggingDelegate writeVerbose, Task.TaskErrorLoggingDelegate writeError)
        {
            if (session == null)
            {
                throw new ArgumentNullException("session");
            }
            string text = SyncTaskHelper.GetCurrentServerFromSession(session);
            ITopologyConfigurationSession topologyConfigurationSession = DirectorySessionFactory.Default.CreateTopologyConfigurationSession(text, true, ConsistencyMode.IgnoreInvalid, ADSessionSettings.FromRootOrgScopeSet(), 84, "ResolveSyncCookie", "f:\\15.00.1497\\sources\\dev\\Management\\src\\Management\\Common\\recipient\\SyncTaskHelper.cs");
            Guid guid = topologyConfigurationSession.GetInvocationIdByFqdn(text);

            writeVerbose(Strings.VerboseSyncTaskDomainControllerToUse(text, guid));
            if (cookieData == null)
            {
                writeVerbose(SyncTaskHelper.FormatCookieVerboseString(null));
                SyncCookie syncCookie = new SyncCookie(guid, WatermarkMap.Empty, SyncConfiguration.GetReplicationCursors(topologyConfigurationSession), null);
                writeVerbose(Strings.VerboseSyncTaskHighestCommittedUSN(text, syncCookie.HighWatermark));
                return(syncCookie);
            }
            SyncCookie syncCookie2 = null;
            Exception  exception   = null;

            if (!SyncCookie.TryFromBytes(cookieData, out syncCookie2, out exception))
            {
                writeError(exception, ErrorCategory.InvalidData, null);
            }
            writeVerbose(SyncTaskHelper.FormatCookieVerboseString(syncCookie2));
            if (syncCookie2.DomainController != guid)
            {
                writeVerbose(Strings.VerboseSyncTaskDomainControllerMismatch(syncCookie2.DomainController, guid));
                ADServer adserver = topologyConfigurationSession.FindDCByFqdn(text);
                if (syncCookie2.PageCookie != null)
                {
                    writeVerbose(Strings.VerboseSyncTaskCookieHasPageData(syncCookie2.DomainController, guid));
                    string text2 = SyncTaskHelper.FindAvailableServerByInvocationId(syncCookie2.DomainController, topologyConfigurationSession, adserver.Site);
                    if (text2 != null)
                    {
                        session.DomainController = text2;
                        writeVerbose(Strings.VerboseSyncTaskHighestCommittedUSN(text2, syncCookie2.HighWatermark));
                        return(syncCookie2);
                    }
                    writeError(new PageCookieInterruptedException(), ErrorCategory.InvalidData, null);
                }
                if (!syncCookie2.LowWatermarks.ContainsKey(guid))
                {
                    writeVerbose(Strings.VerboseSyncTaskCookieCurrentWatermarksMissingCurrentDC(syncCookie2.DomainController, guid));
                    string text3 = SyncTaskHelper.FindAvailableServerByInvocationId(syncCookie2.DomainController, topologyConfigurationSession, adserver.Site);
                    if (text3 != null)
                    {
                        session.DomainController = text3;
                        topologyConfigurationSession.DomainController = text3;
                        text = text3;
                        guid = syncCookie2.DomainController;
                    }
                    else
                    {
                        writeVerbose(Strings.VerboseSyncTaskCookieOriginatingDCNotAvailable(syncCookie2.DomainController));
                        Guid   guid2;
                        string text4 = SyncTaskHelper.FindAvailableServerFromWatermarks(syncCookie2.LowWatermarks, topologyConfigurationSession, adserver.Site, out guid2);
                        if (text4 != null)
                        {
                            session.DomainController = text4;
                            topologyConfigurationSession.DomainController = text4;
                            text = text4;
                            guid = guid2;
                        }
                        else
                        {
                            writeError(new CookieExpiredException(syncCookie2.DomainController, guid), ErrorCategory.InvalidData, null);
                        }
                    }
                }
            }
            WatermarkMap lowWatermarks  = SyncTaskHelper.FallbackWatermarks(syncCookie2.LowWatermarks, syncCookie2.DomainController, guid);
            WatermarkMap highWatermarks = SyncTaskHelper.FallbackWatermarks(syncCookie2.HighWatermarks, syncCookie2.DomainController, guid);

            if (syncCookie2.HighWatermark == 0L)
            {
                syncCookie2 = new SyncCookie(guid, lowWatermarks, SyncConfiguration.GetReplicationCursors(topologyConfigurationSession), null);
            }
            else
            {
                syncCookie2 = new SyncCookie(guid, lowWatermarks, highWatermarks, syncCookie2.PageCookie);
            }
            writeVerbose(Strings.VerboseSyncTaskHighestCommittedUSN(text, syncCookie2.HighWatermark));
            return(syncCookie2);
        }
Ejemplo n.º 3
0
        public override IEnumerable <ADRawEntry> GetDataPage()
        {
            ExTraceGlobals.TenantRelocationTracer.TraceDebug((long)SyncConfiguration.TraceId, "TenantRelocationSyncConfiguration GetDataPage ...");
            WatermarkMap watermarks         = SyncConfiguration.GetReplicationCursors(base.RootOrgConfigurationSession);
            WatermarkMap configNcWatermarks = SyncConfiguration.GetReplicationCursors(base.RootOrgConfigurationSession, true, false);
            string       dcName             = base.RootOrgConfigurationSession.DomainController;

            ExTraceGlobals.TenantRelocationTracer.TraceDebug <string>((long)SyncConfiguration.TraceId, "TenantRelocationSyncConfiguration dcName {0}", dcName);
            base.TenantConfigurationSession.DomainController = dcName;
            base.RecipientSession.DomainController           = dcName;
            Guid watermarksInvocationId = base.RootOrgConfigurationSession.GetInvocationIdByFqdn(dcName);

            ExTraceGlobals.TenantRelocationTracer.TraceDebug <Guid>((long)SyncConfiguration.TraceId, "TenantRelocationSyncConfiguration watermarksInvocationId {0}", watermarksInvocationId);
            long maxUsn = watermarks[watermarksInvocationId];

            ExTraceGlobals.TenantRelocationTracer.TraceDebug <long>((long)SyncConfiguration.TraceId, "TenantRelocationSyncConfiguration maxUsn {0}", maxUsn);
            this.PageToken.IsTenantConfigUnitInConfigNc = !ADSession.IsTenantConfigInDomainNC(base.RecipientSession.SessionSettings.GetAccountOrResourceForestFqdn());
            if (this.PageToken.InvocationId == Guid.Empty)
            {
                this.PageToken.SetInvocationId(watermarksInvocationId, dcName);
                ExTraceGlobals.TenantRelocationTracer.TraceDebug <Guid>((long)SyncConfiguration.TraceId, "TenantRelocationSyncConfiguration set this.PageToken.InvocationId to {0}", this.PageToken.InvocationId);
            }
            this.moreDataForThisPage = true;
            while (this.ShouldReadMoreData())
            {
                ExTraceGlobals.TenantRelocationTracer.TraceDebug <string>((long)SyncConfiguration.TraceId, "TenantRelocationSyncConfiguration this.PageToken.State = {0}", this.PageToken.State.ToString());
                switch (this.PageToken.State)
                {
                case TenantRelocationSyncState.PreSyncAllObjects:
                    if (this.PageToken.PreSyncLdapPagingCookie == null)
                    {
                        this.PageToken.PendingConfigNcWatermarks     = configNcWatermarks;
                        this.PageToken.PendingWatermarks             = watermarks;
                        this.PageToken.PendingWatermarksInvocationId = watermarksInvocationId;
                        ExTraceGlobals.TenantRelocationTracer.TraceDebug <Guid>((long)SyncConfiguration.TraceId, "TenantRelocationSyncConfiguration set this.PageToken.PendingWatermarksInvocationId to {0}", this.PageToken.PendingWatermarksInvocationId);
                    }
                    foreach (ADRawEntry entry in this.PreSyncAllObjects())
                    {
                        ExTraceGlobals.TenantRelocationTracer.TraceDebug <ADObjectId>((long)SyncConfiguration.TraceId, "TenantRelocationSyncConfiguration PreSyncAllObjects yield {0}", entry.Id);
                        yield return(entry);
                    }
                    break;

                case TenantRelocationSyncState.EnumerateConfigUnitLiveObjects:
                    foreach (ADRawEntry entry2 in this.ReadLiveObjects(maxUsn))
                    {
                        ExTraceGlobals.TenantRelocationTracer.TraceDebug <ADObjectId>((long)SyncConfiguration.TraceId, "TenantRelocationSyncConfiguration EnumerateConfigUnitLiveObjects yield {0}", entry2.Id);
                        yield return(entry2);
                    }
                    this.PageToken.PendingWatermarksInvocationId = watermarksInvocationId;
                    ExTraceGlobals.TenantRelocationTracer.TraceDebug <Guid>((long)SyncConfiguration.TraceId, "TenantRelocationSyncConfiguration set this.PageToken.PendingWatermarksInvocationId to {0}", this.PageToken.PendingWatermarksInvocationId);
                    if (this.PageToken.IsTenantConfigUnitInConfigNc)
                    {
                        this.PageToken.PendingConfigNcWatermarks = configNcWatermarks;
                    }
                    else
                    {
                        this.PageToken.PendingWatermarks = watermarks;
                    }
                    break;

                case TenantRelocationSyncState.EnumerateConfigUnitLinksInPage:
                    ExTraceGlobals.TenantRelocationTracer.TraceDebug((long)SyncConfiguration.TraceId, "TenantRelocationSyncConfiguration EnumerateConfigUnitLinksInPage skips");
                    this.PageToken.SwitchToEnumerateLiveObjectsState();
                    break;

                case TenantRelocationSyncState.EnumerateOrganizationalUnitLiveObjects:
                    foreach (ADRawEntry entry3 in this.ReadLiveObjects(maxUsn))
                    {
                        ExTraceGlobals.TenantRelocationTracer.TraceDebug <ADObjectId>((long)SyncConfiguration.TraceId, "TenantRelocationSyncConfiguration EnumerateOrganizationalUnitLiveObjects yield {0}", entry3.Id);
                        yield return(entry3);
                    }
                    if (this.PageToken.IsTenantConfigUnitInConfigNc)
                    {
                        this.PageToken.PendingWatermarksInvocationId = watermarksInvocationId;
                        ExTraceGlobals.TenantRelocationTracer.TraceDebug <Guid>((long)SyncConfiguration.TraceId, "TenantRelocationSyncConfiguration set this.PageToken.PendingWatermarksInvocationId to {0}", this.PageToken.PendingWatermarksInvocationId);
                        this.PageToken.PendingWatermarks = watermarks;
                    }
                    break;

                case TenantRelocationSyncState.EnumerateOrganizationalUnitLinksInPage:
                    ExTraceGlobals.TenantRelocationTracer.TraceDebug((long)SyncConfiguration.TraceId, "TenantRelocationSyncConfiguration EnumerateConfigUnitLinksInPage skips");
                    this.PageToken.SwitchToEnumerateLiveObjectsState();
                    break;

                case TenantRelocationSyncState.EnumerateConfigUnitDeletedObjects:
                    foreach (ADRawEntry entry4 in this.ReadDeletedObjects())
                    {
                        ExTraceGlobals.TenantRelocationTracer.TraceDebug <ADObjectId>((long)SyncConfiguration.TraceId, "TenantRelocationSyncConfiguration EnumerateConfigUnitDeletedObjects yield {0}", entry4.Id);
                        yield return(entry4);
                    }
                    break;

                case TenantRelocationSyncState.EnumerateOrganizationalUnitDeletedObjects:
                    if (!this.PageToken.IsTenantConfigUnitInConfigNc)
                    {
                        this.PageToken.SwitchToNextState();
                    }
                    else
                    {
                        foreach (ADRawEntry entry5 in this.ReadDeletedObjects())
                        {
                            ExTraceGlobals.TenantRelocationTracer.TraceDebug <ADObjectId>((long)SyncConfiguration.TraceId, "TenantRelocationSyncConfiguration EnumerateOrganizationalUnitDeletedObjects yield {0}", entry5.Id);
                            yield return(entry5);
                        }
                    }
                    break;

                case TenantRelocationSyncState.EnumerateSpecialObjects:
                    foreach (ADRawEntry entry6 in this.ReadSpecialObjects())
                    {
                        ExTraceGlobals.TenantRelocationTracer.TraceDebug <ADObjectId>((long)SyncConfiguration.TraceId, "TenantRelocationSyncConfiguration EnumerateSpecialObjects yield {0}", entry6.Id);
                        yield return(entry6);
                    }
                    if (!this.PageToken.IsTenantConfigUnitInConfigNc)
                    {
                        this.PageToken.PendingWatermarksInvocationId = watermarksInvocationId;
                        ExTraceGlobals.TenantRelocationTracer.TraceDebug <Guid>((long)SyncConfiguration.TraceId, "TenantRelocationSyncConfiguration set this.PageToken.PendingWatermarksInvocationId to {0}", this.PageToken.PendingWatermarksInvocationId);
                        this.PageToken.PendingConfigNcWatermarks = configNcWatermarks;
                    }
                    this.PageToken.SwitchToNextState();
                    break;

                default:
                    ExTraceGlobals.TenantRelocationTracer.TraceError <string>((long)SyncConfiguration.TraceId, "Invalid PageToken stat {0}", this.PageToken.State.ToString());
                    throw new ArgumentException(this.PageToken.State.ToString());
                }
            }
            ExTraceGlobals.TenantRelocationTracer.TraceDebug <long>((long)SyncConfiguration.TraceId, "TenantRelocationSyncConfiguration this.PageToken.OrganizationalUnitObjectUSN = {0}", this.PageToken.OrganizationalUnitObjectUSN);
            if (this.PageToken.OrganizationalUnitObjectUSN > maxUsn + 1L)
            {
                this.PageToken.OrganizationalUnitObjectUSN = maxUsn + 1L;
                ExTraceGlobals.TenantRelocationTracer.TraceDebug <long>((long)SyncConfiguration.TraceId, "TenantRelocationSyncConfiguration set this.PageToken.OrganizationalUnitObjectUSN to {0}", this.PageToken.OrganizationalUnitObjectUSN);
            }
            ExTraceGlobals.TenantRelocationTracer.TraceDebug <long>((long)SyncConfiguration.TraceId, "TenantRelocationSyncConfiguration this.PageToken.OrganizationalUnitTombstoneUSN = {0}", this.PageToken.OrganizationalUnitTombstoneUSN);
            if (this.PageToken.OrganizationalUnitTombstoneUSN > maxUsn + 1L)
            {
                this.PageToken.OrganizationalUnitTombstoneUSN = maxUsn + 1L;
                ExTraceGlobals.TenantRelocationTracer.TraceDebug <long>((long)SyncConfiguration.TraceId, "TenantRelocationSyncConfiguration set this.PageToken.OrganizationalUnitTombstoneUSN to {0}", this.PageToken.OrganizationalUnitTombstoneUSN);
            }
            ExTraceGlobals.TenantRelocationTracer.TraceDebug <long>((long)SyncConfiguration.TraceId, "TenantRelocationSyncConfiguration this.PageToken.ConfigUnitObjectUSN = {0}", this.PageToken.ConfigUnitObjectUSN);
            if (this.PageToken.ConfigUnitObjectUSN > maxUsn + 1L)
            {
                this.PageToken.ConfigUnitObjectUSN = maxUsn + 1L;
                ExTraceGlobals.TenantRelocationTracer.TraceDebug <long>((long)SyncConfiguration.TraceId, "TenantRelocationSyncConfiguration this.PageToken.ConfigUnitObjectUSN = {0}", this.PageToken.ConfigUnitObjectUSN);
            }
            ExTraceGlobals.TenantRelocationTracer.TraceDebug <long>((long)SyncConfiguration.TraceId, "TenantRelocationSyncConfiguration this.PageToken.ConfigUnitTombstoneUSN = {0}", this.PageToken.ConfigUnitTombstoneUSN);
            if (this.PageToken.ConfigUnitTombstoneUSN > maxUsn + 1L)
            {
                this.PageToken.ConfigUnitTombstoneUSN = maxUsn + 1L;
                ExTraceGlobals.TenantRelocationTracer.TraceDebug <long>((long)SyncConfiguration.TraceId, "TenantRelocationSyncConfiguration this.PageToken.ConfigUnitTombstoneUSN = {0}", this.PageToken.ConfigUnitTombstoneUSN);
            }
            ExTraceGlobals.TenantRelocationTracer.TraceDebug <long>((long)SyncConfiguration.TraceId, "TenantRelocationSyncConfiguration this.PageToken.SpecialObjectsUSN = {0}", this.PageToken.SpecialObjectsUSN);
            if (this.PageToken.SpecialObjectsUSN > maxUsn + 1L)
            {
                this.PageToken.SpecialObjectsUSN = maxUsn + 1L;
                ExTraceGlobals.TenantRelocationTracer.TraceDebug <long>((long)SyncConfiguration.TraceId, "TenantRelocationSyncConfiguration this.PageToken.SpecialObjectsUSN = {0}", this.PageToken.SpecialObjectsUSN);
            }
            this.PageToken.LastReadFailureStartTime = DateTime.MinValue;
            ExTraceGlobals.TenantRelocationTracer.TraceDebug <DateTime>((long)SyncConfiguration.TraceId, "TenantRelocationSyncConfiguration set this.PageToken.LastReadFailureStartTime to {0}", this.PageToken.LastReadFailureStartTime);
            this.PageToken.Timestamp = DateTime.UtcNow;
            ExTraceGlobals.TenantRelocationTracer.TraceDebug <DateTime>((long)SyncConfiguration.TraceId, "TenantRelocationSyncConfiguration set this.PageToken.Timestamp to {0}", this.PageToken.Timestamp);
            yield break;
        }
Ejemplo n.º 4
0
        private bool CheckReplicationStatus(ITopologyConfigurationSession session, WatermarkMap finishWaterMark, bool useConfigNC)
        {
            WatermarkMap replicationCursors = SyncConfiguration.GetReplicationCursors(session, useConfigNC, false);

            return(replicationCursors.ContainsAllChanges(finishWaterMark));
        }