Beispiel #1
0
 public void RemoveObjectFromList(SyncObjectId objectId, bool clearObjectCookie)
 {
     ExTraceGlobals.BackSyncTracer.TraceDebug <string>((long)SyncConfiguration.TraceId, "ObjectFullSyncPageToken RemoveObjectFromList objectId {0}", (objectId != null) ? objectId.ObjectId : "NULL");
     this.ObjectIds.Remove(objectId);
     if (clearObjectCookie)
     {
         ExTraceGlobals.BackSyncTracer.TraceDebug((long)SyncConfiguration.TraceId, "ObjectFullSyncPageToken clear object cookie");
         this.ObjectCookie = null;
     }
 }
Beispiel #2
0
        internal static ObjectFullSyncPageToken Parse(byte[] tokenBytes)
        {
            if (tokenBytes == null)
            {
                throw new ArgumentNullException("tokenBytes");
            }
            Exception innerException;

            try
            {
                using (BackSyncCookieReader backSyncCookieReader = BackSyncCookieReader.Create(tokenBytes, typeof(ObjectFullSyncPageToken)))
                {
                    int num = (int)backSyncCookieReader.GetNextAttributeValue();
                    ServiceInstanceId serviceInstanceId             = new ServiceInstanceId((string)backSyncCookieReader.GetNextAttributeValue());
                    long                     dateData               = (long)backSyncCookieReader.GetNextAttributeValue();
                    long                     dateData2              = (long)backSyncCookieReader.GetNextAttributeValue();
                    Guid                     invocationId           = (Guid)backSyncCookieReader.GetNextAttributeValue();
                    BackSyncOptions          syncOptions            = (BackSyncOptions)((int)backSyncCookieReader.GetNextAttributeValue());
                    string[]                 array                  = (string[])backSyncCookieReader.GetNextAttributeValue();
                    byte[]                   array2                 = (byte[])backSyncCookieReader.GetNextAttributeValue();
                    string[]                 errorObjects           = (string[])backSyncCookieReader.GetNextAttributeValue();
                    Dictionary <string, int> errorObjectsAndCount   = BackSyncCookie.ParseErrorObjectsAndFailureCounts(errorObjects);
                    DateTime                 sequenceStartTimestamp = DateTime.FromBinary((long)backSyncCookieReader.GetNextAttributeValue());
                    Guid                     sequenceId             = (Guid)backSyncCookieReader.GetNextAttributeValue();
                    HashSet <SyncObjectId>   hashSet                = new HashSet <SyncObjectId>();
                    if (array != null)
                    {
                        foreach (string identity in array)
                        {
                            hashSet.Add(SyncObjectId.Parse(identity));
                        }
                    }
                    FullSyncObjectCookie objectCookie = (array2 == null) ? null : FullSyncObjectCookie.Parse(array2);
                    return(new ObjectFullSyncPageToken(invocationId, hashSet, syncOptions, DateTime.FromBinary(dateData), DateTime.FromBinary(dateData2), objectCookie, errorObjectsAndCount, serviceInstanceId, sequenceId, sequenceStartTimestamp));
                }
            }
            catch (ArgumentException ex)
            {
                innerException = ex;
            }
            catch (IOException ex2)
            {
                innerException = ex2;
            }
            catch (FormatException ex3)
            {
                innerException = ex3;
            }
            catch (InvalidCookieException ex4)
            {
                innerException = ex4;
            }
            throw new InvalidCookieException(innerException);
        }
Beispiel #3
0
 public void SetNextPageData(SyncObjectId objectId, LinkMetadata overlapLink, int nextRangeStart, long usnChanged)
 {
     this.ObjectId = objectId;
     ExTraceGlobals.BackSyncTracer.TraceDebug <string>((long)SyncConfiguration.TraceId, "FullSyncObjectCookie.SetNextPageData this.ObjectId = {0}", (this.ObjectId != null) ? this.ObjectId.ObjectId : "NULL");
     this.EnumerateLinks = true;
     this.LinkName       = overlapLink.AttributeName;
     this.LinkRangeStart = nextRangeStart;
     this.LinkTarget     = overlapLink.TargetDistinguishedName;
     this.LinkVersion    = overlapLink.Version;
     this.UsnChanged     = usnChanged;
 }
Beispiel #4
0
 public FullSyncObjectRequest(SyncObjectId identity, string serviceInstanceId, FullSyncObjectRequestOptions options, ExDateTime creationTime, FullSyncObjectRequestState state) : this()
 {
     if (identity == null)
     {
         throw new ArgumentNullException("identity");
     }
     if (serviceInstanceId == null)
     {
         throw new ArgumentNullException("serviceInstanceId");
     }
     this.SetIdentity(identity);
     this.ServiceInstanceId = serviceInstanceId;
     this.Options           = options;
     this.CreationTime      = creationTime;
     this.State             = state;
 }
Beispiel #5
0
        public static FullSyncObjectCookie Parse(byte[] bytes)
        {
            ExTraceGlobals.BackSyncTracer.TraceDebug((long)SyncConfiguration.TraceId, "FullSyncObjectCookie.Parse entering");
            if (bytes == null)
            {
                ExTraceGlobals.BackSyncTracer.TraceError((long)SyncConfiguration.TraceId, "FullSyncObjectCookie.Parse bytes is NULL");
                throw new ArgumentNullException("bytes");
            }
            Exception ex2;

            try
            {
                using (BackSyncCookieReader backSyncCookieReader = BackSyncCookieReader.Create(bytes, typeof(FullSyncObjectCookie)))
                {
                    return(new FullSyncObjectCookie
                    {
                        Version = (int)backSyncCookieReader.GetNextAttributeValue(),
                        ServiceInstanceId = new ServiceInstanceId((string)backSyncCookieReader.GetNextAttributeValue()),
                        ObjectId = SyncObjectId.Parse((string)backSyncCookieReader.GetNextAttributeValue()),
                        ReadRestartsCount = (int)backSyncCookieReader.GetNextAttributeValue(),
                        UsnChanged = (long)backSyncCookieReader.GetNextAttributeValue(),
                        EnumerateLinks = (bool)backSyncCookieReader.GetNextAttributeValue(),
                        LinkRangeStart = (int)backSyncCookieReader.GetNextAttributeValue(),
                        LinkVersion = (int)backSyncCookieReader.GetNextAttributeValue(),
                        LinkTarget = (string)backSyncCookieReader.GetNextAttributeValue(),
                        LinkName = (string)backSyncCookieReader.GetNextAttributeValue()
                    });
                }
            }
            catch (ArgumentException ex)
            {
                ExTraceGlobals.BackSyncTracer.TraceError <string>((long)SyncConfiguration.TraceId, "FullSyncObjectCookie.Parse ArgumentException {0}", ex.ToString());
                ex2 = ex;
            }
            catch (IOException ex3)
            {
                ExTraceGlobals.BackSyncTracer.TraceError <string>((long)SyncConfiguration.TraceId, "FullSyncObjectCookie.Parse IOException {0}", ex3.ToString());
                ex2 = ex3;
            }
            catch (FormatException ex4)
            {
                ExTraceGlobals.BackSyncTracer.TraceError <string>((long)SyncConfiguration.TraceId, "FullSyncObjectCookie.Parse FormatException {0}", ex4.ToString());
                ex2 = ex4;
            }
            ExTraceGlobals.BackSyncTracer.TraceError <string>((long)SyncConfiguration.TraceId, "FullSyncObjectCookie.Parse throw InvalidCookieException {0}", ex2.ToString());
            throw new InvalidCookieException(ex2);
        }
Beispiel #6
0
        internal static FullSyncObjectRequest Parse(string requestBlob)
        {
            if (string.IsNullOrEmpty(requestBlob))
            {
                throw new ArgumentException("requestBlob");
            }
            FullSyncObjectRequest result;

            try
            {
                string[] array = requestBlob.Split(new string[]
                {
                    "#"
                }, StringSplitOptions.None);
                if (array.Length != 6)
                {
                    throw new FormatException("requestBlob");
                }
                string       serviceInstanceId       = array[1];
                SyncObjectId identity                = SyncObjectId.Parse(array[2]);
                FullSyncObjectRequestOptions options = (FullSyncObjectRequestOptions)int.Parse(array[3]);
                ExDateTime creationTime              = ExDateTime.FromFileTimeUtc(long.Parse(array[4]));
                FullSyncObjectRequestState state     = (FullSyncObjectRequestState)int.Parse(array[5]);
                result = new FullSyncObjectRequest(identity, serviceInstanceId, options, creationTime, state);
            }
            catch (ArgumentException innerException)
            {
                throw new FormatException("requestBlob", innerException);
            }
            catch (FormatException innerException2)
            {
                throw new FormatException("requestBlob", innerException2);
            }
            catch (OverflowException innerException3)
            {
                throw new FormatException("requestBlob", innerException3);
            }
            return(result);
        }
Beispiel #7
0
 // Token: 0x060063F2 RID: 25586 RVA: 0x0015B164 File Offset: 0x00159364
 public CompoundSyncObjectId(SyncObjectId syncObjectId, ServiceInstanceId serviceInstanceId)
 {
     this.SyncObjectId      = syncObjectId;
     this.ServiceInstanceId = serviceInstanceId;
 }
        private IEnumerable <ADRawEntry> ReadObjects()
        {
            ExTraceGlobals.BackSyncTracer.TraceDebug((long)SyncConfiguration.TraceId, "ObjectFullSyncConfiguration.ReadObjects entering");
            bool includeLinks = SyncConfiguration.InlcudeLinks(this.PageToken.SyncOptions);

            ExTraceGlobals.BackSyncTracer.TraceDebug <bool>((long)SyncConfiguration.TraceId, "ObjectFullSyncConfiguration.ReadObjects includeLinks = {0}", includeLinks);
            PropertyDefinition[] properties = FullSyncConfiguration.GetPropertyDefinitions(includeLinks);
            int objectCount = Math.Min(this.PageToken.ObjectIds.Count, FullSyncConfiguration.ObjectsPerPageLimit);

            ExTraceGlobals.BackSyncTracer.TraceDebug <int>((long)SyncConfiguration.TraceId, "ObjectFullSyncConfiguration.ReadObjects objectCount = {0}", objectCount);
            string[]             externalObjectIds = new string[objectCount];
            IList <SyncObjectId> objectIds         = this.PageToken.ObjectIds.ToList <SyncObjectId>();

            for (int k = 0; k < objectCount; k++)
            {
                externalObjectIds[k] = objectIds[k].ObjectId;
                ExTraceGlobals.BackSyncTracer.TraceDebug <int, string>((long)SyncConfiguration.TraceId, "ObjectFullSyncConfiguration.ReadObjects externalObjectIds[{0}] = \"{1}\"", k, externalObjectIds[k]);
            }
            ExTraceGlobals.BackSyncTracer.TraceDebug((long)SyncConfiguration.TraceId, "ObjectFullSyncConfiguration.ReadObjects FindByExternalDirectoryObjectIds ...");
            Result <ADRawEntry>[] results               = this.FindByExternalDirectoryObjectIds(externalObjectIds, true, properties);
            List <ADRawEntry>     completeEntries       = new List <ADRawEntry>();
            List <ADRawEntry>     deletedEntries        = new List <ADRawEntry>();
            List <ADRawEntry>     pagingRequiredEntries = new List <ADRawEntry>();

            for (int l = 0; l < externalObjectIds.Length; l++)
            {
                ExTraceGlobals.BackSyncTracer.TraceDebug <int, string>((long)SyncConfiguration.TraceId, "ObjectFullSyncConfiguration.ReadObjects externalObjectIds[{0}] = \"{1}\"", l, externalObjectIds[l]);
                if (results[l].Data != null)
                {
                    ADRawEntry data = results[l].Data;
                    ExTraceGlobals.BackSyncTracer.TraceDebug <int, ADObjectId>((long)SyncConfiguration.TraceId, "ObjectFullSyncConfiguration.ReadObjects found entry[{0}] = \"{1}\"", l, data.Id);
                    data.propertyBag.SetField(SyncObjectSchema.SyncObjectId, objectIds[l]);
                    if ((bool)data[SyncObjectSchema.Deleted])
                    {
                        ExTraceGlobals.BackSyncTracer.TraceDebug((long)SyncConfiguration.TraceId, "ObjectFullSyncConfiguration.ReadObjects add entry to deletedEntries");
                        deletedEntries.Add(data);
                    }
                    else
                    {
                        MultiValuedProperty <LinkMetadata> multiValuedProperty = (MultiValuedProperty <LinkMetadata>)data[FullSyncConfiguration.InitialLinkMetadataRangedProperty];
                        data.propertyBag.SetField(ADRecipientSchema.LinkMetadata, multiValuedProperty);
                        if (FullSyncConfiguration.NotAllLinksRetrieved(multiValuedProperty))
                        {
                            ExTraceGlobals.BackSyncTracer.TraceDebug((long)SyncConfiguration.TraceId, "ObjectFullSyncConfiguration.ReadObjects add entry to pagingRequiredEntries");
                            pagingRequiredEntries.Add(data);
                        }
                        else
                        {
                            ExTraceGlobals.BackSyncTracer.TraceDebug((long)SyncConfiguration.TraceId, "ObjectFullSyncConfiguration.ReadObjects add entry to completeEntries");
                            completeEntries.Add(data);
                        }
                    }
                }
                else if (results[l].Error == ProviderError.NotFound)
                {
                    ExTraceGlobals.BackSyncTracer.TraceDebug <int>((long)SyncConfiguration.TraceId, "ObjectFullSyncConfiguration.ReadObjects not found entry[{0}]", l);
                    SyncObjectId syncObjectId = objectIds[l];
                    base.ExcludedObjectReporter.ReportExcludedObject(syncObjectId, DirectoryObjectErrorCode.ObjectNotFound, ProcessingStage.ObjectFullSyncConfiguration);
                    this.PageToken.ObjectIds.Remove(syncObjectId);
                }
            }
            ExTraceGlobals.BackSyncTracer.TraceDebug((long)SyncConfiguration.TraceId, "ObjectFullSyncConfiguration.ReadObjects process deletedEntries ...");
            int i = 0;

            while (i < deletedEntries.Count && this.ShouldReadMoreData())
            {
                ExTraceGlobals.BackSyncTracer.TraceDebug <ADObjectId>((long)SyncConfiguration.TraceId, "ObjectFullSyncConfiguration.ReadObjects remove {0} from this.PageToken.ObjectIds", deletedEntries[i].Id);
                this.PageToken.ObjectIds.Remove((SyncObjectId)deletedEntries[i][SyncObjectSchema.SyncObjectId]);
                base.ReturnedObjectCount++;
                yield return(deletedEntries[i]);

                i++;
            }
            ExTraceGlobals.BackSyncTracer.TraceDebug((long)SyncConfiguration.TraceId, "ObjectFullSyncConfiguration.ReadObjects process completeEntries ...");
            int j = 0;

            while (j < completeEntries.Count && this.ShouldReadMoreData())
            {
                ExTraceGlobals.BackSyncTracer.TraceDebug <ADObjectId>((long)SyncConfiguration.TraceId, "ObjectFullSyncConfiguration.ReadObjects remove {0} from this.PageToken.ObjectIds", completeEntries[j].Id);
                this.PageToken.ObjectIds.Remove((SyncObjectId)completeEntries[j][SyncObjectSchema.SyncObjectId]);
                base.ReturnedObjectCount++;
                base.ReturnedLinkCount += ((MultiValuedProperty <LinkMetadata>)completeEntries[j][FullSyncConfiguration.InitialLinkMetadataRangedProperty]).Count;
                yield return(completeEntries[j]);

                j++;
            }
            if (this.ShouldReadMoreData() && pagingRequiredEntries.Count > 0)
            {
                ExTraceGlobals.BackSyncTracer.TraceDebug((long)SyncConfiguration.TraceId, "ObjectFullSyncConfiguration.ReadObjects read more data ...");
                ADRawEntry linkEntry = pagingRequiredEntries[0];
                ExTraceGlobals.BackSyncTracer.TraceDebug <ADObjectId>((long)SyncConfiguration.TraceId, "ObjectFullSyncConfiguration.ReadObjects linkEntry {0}", linkEntry.Id);
                base.ReturnedObjectCount++;
                MultiValuedProperty <LinkMetadata> metadata = (MultiValuedProperty <LinkMetadata>)linkEntry[FullSyncConfiguration.InitialLinkMetadataRangedProperty];
                LinkMetadata overlapLink = metadata[0];
                base.ReturnedLinkCount += metadata.Count;
                int nextPageLinkRangeStart = metadata.ValueRange.UpperBound - 10 + 1;
                this.PageToken.ObjectCookie = new FullSyncObjectCookie((SyncObjectId)linkEntry[SyncObjectSchema.SyncObjectId], overlapLink, nextPageLinkRangeStart, (long)linkEntry[ADRecipientSchema.UsnChanged], this.PageToken.ServiceInstanceId);
                yield return(linkEntry);
            }
            yield break;
        }
        private ADRawEntry ReadNextLinkPage()
        {
            ExTraceGlobals.BackSyncTracer.TraceDebug((long)SyncConfiguration.TraceId, "ObjectFullSyncConfiguration.ReadNextLinkPage entering");
            SyncObjectId objectId = this.PageToken.ObjectCookie.ObjectId;

            if (this.PageToken.ObjectCookie.ReadRestartsCount > 10)
            {
                if (base.EventLogger != null)
                {
                    base.EventLogger.LogTooManyObjectReadRestartsEvent(objectId.ToString(), 10);
                }
                ExTraceGlobals.BackSyncTracer.TraceDebug <string>((long)SyncConfiguration.TraceId, "ObjectFullSyncConfiguration.ReadNextLinkPage TooManyObjectReadRestarts {0}", objectId.ToString());
                base.ExcludedObjectReporter.ReportExcludedObject(objectId, DirectoryObjectErrorCode.Busy, ProcessingStage.ObjectFullSyncConfiguration);
                this.PageToken.RemoveObjectFromList(objectId, true);
                return(null);
            }
            int num = Math.Max(0, FullSyncConfiguration.LinksPerPageLimit - base.ReturnedLinkCount);

            if (num <= 10)
            {
                return(null);
            }
            List <PropertyDefinition> list = new List <PropertyDefinition>();
            int linkRangeStart             = this.PageToken.ObjectCookie.LinkRangeStart;

            ExTraceGlobals.BackSyncTracer.TraceDebug <int>((long)SyncConfiguration.TraceId, "ObjectFullSyncConfiguration.ReadNextLinkPage this.PageToken.ObjectCookie.LinkRangeStart = {0}", this.PageToken.ObjectCookie.LinkRangeStart);
            ADPropertyDefinition adpropertyDefinition = RangedPropertyHelper.CreateRangedProperty(ADRecipientSchema.LinkMetadata, new IntRange(linkRangeStart, linkRangeStart + num - 1));

            list.Add(adpropertyDefinition);
            list.Add(ADRecipientSchema.UsnChanged);
            bool flag = !this.PageToken.ObjectCookie.EnumerateLinks;

            if (flag)
            {
                list.AddRange(SyncSchema.Instance.AllBackSyncBaseProperties.Cast <PropertyDefinition>());
                list.AddRange(SyncObject.BackSyncProperties.Cast <PropertyDefinition>());
            }
            else
            {
                list.AddRange(SyncObject.FullSyncLinkPageBackSyncProperties.Cast <PropertyDefinition>());
            }
            ExTraceGlobals.BackSyncTracer.TraceDebug <string>((long)SyncConfiguration.TraceId, "ObjectFullSyncConfiguration.ReadNextLinkPage objectId.ObjectId = {0}", objectId.ObjectId);
            string[] externalObjectIds = new string[]
            {
                objectId.ObjectId
            };
            Result <ADRawEntry>[] array  = this.FindByExternalDirectoryObjectIds(externalObjectIds, true, list.ToArray());
            Result <ADRawEntry>   result = array[0];

            if (result.Data != null)
            {
                ADRawEntry data = result.Data;
                ExTraceGlobals.BackSyncTracer.TraceDebug <ADObjectId>((long)SyncConfiguration.TraceId, "ObjectFullSyncConfiguration.ReadNextLinkPage entry = {0}", data.Id);
                long num2 = (long)data[ADRecipientSchema.UsnChanged];
                ExTraceGlobals.BackSyncTracer.TraceDebug <long>((long)SyncConfiguration.TraceId, "ObjectFullSyncConfiguration.ReadNextLinkPage usnChanged = {0}", num2);
                MultiValuedProperty <LinkMetadata> multiValuedProperty = (MultiValuedProperty <LinkMetadata>)data[adpropertyDefinition];
                if (!flag)
                {
                    if (num2 != this.PageToken.ObjectCookie.UsnChanged)
                    {
                        ExTraceGlobals.BackSyncTracer.TraceDebug <long>((long)SyncConfiguration.TraceId, "ObjectFullSyncConfiguration.ReadNextLinkPage RestartObjectReadAfterObjectChange usnChanged = {0}", num2);
                        this.PageToken.ObjectCookie.RestartObjectReadAfterObjectChange(num2);
                        return(null);
                    }
                    if (this.PageToken.ObjectCookie.LinkRangeStart > 0 && !this.CheckLinkOverlap(multiValuedProperty))
                    {
                        ExTraceGlobals.BackSyncTracer.TraceDebug((long)SyncConfiguration.TraceId, "ObjectFullSyncConfiguration.ReadNextLinkPage RestartObjectReadAfterTargetLinksChange");
                        this.PageToken.ObjectCookie.RestartObjectReadAfterTargetLinksChange();
                        return(null);
                    }
                }
                result.Data.propertyBag.SetField(ADRecipientSchema.LinkMetadata, multiValuedProperty);
                LinkMetadata overlapLink = multiValuedProperty[0];
                base.ReturnedLinkCount += multiValuedProperty.Count;
                if (multiValuedProperty.ValueRange != null)
                {
                    if (multiValuedProperty.ValueRange.UpperBound == 2147483647)
                    {
                        this.PageToken.RemoveObjectFromList(objectId, true);
                        ExTraceGlobals.BackSyncTracer.TraceDebug((long)SyncConfiguration.TraceId, "ObjectFullSyncConfiguration.ReadNextLinkPage last link page read");
                    }
                    else
                    {
                        int num3 = multiValuedProperty.ValueRange.UpperBound - 10 + 1;
                        ExTraceGlobals.BackSyncTracer.TraceDebug <int>((long)SyncConfiguration.TraceId, "ObjectFullSyncConfiguration.ReadNextLinkPage set this.PageToken.nextLinkPageRangeStart to {0}", num3);
                        this.PageToken.ObjectCookie.SetNextPageData(objectId, overlapLink, num3, (long)result.Data[ADRecipientSchema.UsnChanged]);
                    }
                }
                else
                {
                    this.PageToken.RemoveObjectFromList(objectId, true);
                    ExTraceGlobals.BackSyncTracer.TraceDebug <string>((long)SyncConfiguration.TraceId, "ObjectFullSyncConfiguration.ReadNextLinkPage this.PageToken.RemoveObjectFromList objectId = {0}", objectId.ObjectId);
                }
                return(result.Data);
            }
            ExTraceGlobals.BackSyncTracer.TraceDebug((long)SyncConfiguration.TraceId, "ObjectFullSyncConfiguration.ReadNextLinkPage FindByExternalDirectoryObjectIds returned no data.");
            this.PageToken.ObjectCookie.RestartObjectRead(false);
            return(null);
        }
Beispiel #10
0
 internal void SetIdentity(SyncObjectId syncObjectId)
 {
     this[this.propertyBag.ObjectIdentityPropertyDefinition] = syncObjectId;
 }
 internal static string GetObjectName(SyncObjectId syncObjectId)
 {
     return(string.Format("{0}{1}", FailedMSOSyncObject.GetCompactGuidString(syncObjectId.ContextId), FailedMSOSyncObject.GetCompactGuidString(syncObjectId.ObjectId)));
 }
Beispiel #12
0
 internal FullSyncObjectCookie(SyncObjectId objectId, LinkMetadata overlapLink, int nextRangeStart, long usnChanged, ServiceInstanceId serviceInstanceid) : this()
 {
     this.ReadRestartsCount = 0;
     this.SetNextPageData(objectId, overlapLink, nextRangeStart, usnChanged);
     this.ServiceInstanceId = serviceInstanceid;
 }