Ejemplo n.º 1
0
        public IConfigurable Read <T>(ObjectId identity) where T : IConfigurable, new()
        {
            if (identity == null)
            {
                throw new ArgumentNullException("identity");
            }
            if (this.serviceInstanceName == null)
            {
                throw new InvalidOperationException("Read can be performed only for specific service instance.");
            }
            SyncObjectId syncObjectId = identity as SyncObjectId;

            if (syncObjectId == null)
            {
                throw new NotSupportedException(identity.GetType().FullName);
            }
            this.RefreshRidMasterInformation();
            MsoMainStreamCookieContainer msoMainStreamCookieContainer = this.configurationSession.GetMsoMainStreamCookieContainer(this.serviceInstanceName);
            MultiValuedProperty <FullSyncObjectRequest> msoForwardSyncObjectFullSyncRequests = msoMainStreamCookieContainer.MsoForwardSyncObjectFullSyncRequests;

            foreach (FullSyncObjectRequest fullSyncObjectRequest in msoForwardSyncObjectFullSyncRequests)
            {
                if (syncObjectId.Equals(fullSyncObjectRequest.Identity))
                {
                    fullSyncObjectRequest.ResetChangeTracking(true);
                    return(fullSyncObjectRequest);
                }
            }
            return(null);
        }
Ejemplo n.º 2
0
        public MsoMainStreamCookie ReadMostRecentCookie()
        {
            MsoMainStreamCookieContainer msoMainStreamCookieContainer = this.cookieSession.GetMsoMainStreamCookieContainer(base.ServiceInstanceName);
            MultiValuedProperty <byte[]> multiValuedProperty          = this.RetrievePersistedCookies(msoMainStreamCookieContainer);

            if (multiValuedProperty.Count == 0)
            {
                return(null);
            }
            MsoMainStreamCookie msoMainStreamCookie = null;

            foreach (byte[] storageCookie in multiValuedProperty)
            {
                MsoMainStreamCookie msoMainStreamCookie2 = null;
                Exception           ex = null;
                if (MsoMainStreamCookie.TryFromStorageCookie(storageCookie, out msoMainStreamCookie2, out ex) && string.Equals(base.ServiceInstanceName, msoMainStreamCookie2.ServiceInstanceName, StringComparison.OrdinalIgnoreCase) && (msoMainStreamCookie == null || msoMainStreamCookie.TimeStamp < msoMainStreamCookie2.TimeStamp))
                {
                    msoMainStreamCookie = msoMainStreamCookie2;
                }
            }
            if (msoMainStreamCookie != null)
            {
                base.SyncPropertySetVersion     = msoMainStreamCookie.SyncPropertySetVersion;
                base.IsSyncPropertySetUpgrading = msoMainStreamCookie.IsSyncPropertySetUpgrading;
                return(msoMainStreamCookie);
            }
            return(null);
        }
Ejemplo n.º 3
0
        public void Delete(IConfigurable instance)
        {
            if (instance == null)
            {
                throw new ArgumentNullException("instance");
            }
            if (this.configurationSession.ReadOnly)
            {
                throw new InvalidOperationException("read only");
            }
            if (this.serviceInstanceName == null)
            {
                throw new InvalidOperationException("Delete can be performed only for specific service instance.");
            }
            FullSyncObjectRequest fullSyncObjectRequest = instance as FullSyncObjectRequest;

            if (fullSyncObjectRequest == null)
            {
                throw new NotSupportedException(instance.GetType().FullName);
            }
            this.RefreshRidMasterInformation();
            MsoMainStreamCookieContainer msoMainStreamCookieContainer = this.configurationSession.GetMsoMainStreamCookieContainer(this.serviceInstanceName);
            MultiValuedProperty <FullSyncObjectRequest> msoForwardSyncObjectFullSyncRequests = msoMainStreamCookieContainer.MsoForwardSyncObjectFullSyncRequests;

            if (msoForwardSyncObjectFullSyncRequests.Contains(fullSyncObjectRequest))
            {
                msoForwardSyncObjectFullSyncRequests.Remove(fullSyncObjectRequest);
                this.configurationSession.Save(msoMainStreamCookieContainer);
                return;
            }
            throw new ADNoSuchObjectException(DirectoryStrings.ExceptionADOperationFailedNoSuchObject(this.configurationSession.DomainController, fullSyncObjectRequest.ToString()));
        }
 protected override MultiValuedProperty <byte[]> RetrievePersistedCookies(MsoMainStreamCookieContainer container)
 {
     if (container == null)
     {
         throw new ArgumentNullException("container");
     }
     return(container.MsoForwardSyncNonRecipientCookie);
 }
Ejemplo n.º 5
0
        private IEnumerable <T> FindInServiceInstance <T>(ComparisonFilter comparisonFilter, string serviceInstanceName)
        {
            MsoMainStreamCookieContainer msoMainStreamCookieContainer = this.configurationSession.GetMsoMainStreamCookieContainer(serviceInstanceName);
            MultiValuedProperty <FullSyncObjectRequest> msoForwardSyncObjectFullSyncRequests = msoMainStreamCookieContainer.MsoForwardSyncObjectFullSyncRequests;

            if (comparisonFilter == null)
            {
                return((IEnumerable <T>)msoForwardSyncObjectFullSyncRequests);
            }
            return((IEnumerable <T>)(from request in msoForwardSyncObjectFullSyncRequests
                                     where StringComparer.OrdinalIgnoreCase.Equals(request[comparisonFilter.Property], comparisonFilter.PropertyValue)
                                     select request));
        }
Ejemplo n.º 6
0
        public void Save(IConfigurable instance)
        {
            if (instance == null)
            {
                throw new ArgumentNullException("instance");
            }
            if (this.configurationSession.ReadOnly)
            {
                throw new InvalidOperationException("read only");
            }
            if (this.serviceInstanceName == null)
            {
                throw new InvalidOperationException("Save can be performed only for specific service instance.");
            }
            FullSyncObjectRequest request = instance as FullSyncObjectRequest;

            if (request == null)
            {
                throw new NotSupportedException(instance.GetType().FullName);
            }
            this.RefreshRidMasterInformation();
            MsoMainStreamCookieContainer msoMainStreamCookieContainer = this.configurationSession.GetMsoMainStreamCookieContainer(this.serviceInstanceName);
            MultiValuedProperty <FullSyncObjectRequest> msoForwardSyncObjectFullSyncRequests = msoMainStreamCookieContainer.MsoForwardSyncObjectFullSyncRequests;
            FullSyncObjectRequest fullSyncObjectRequest = msoForwardSyncObjectFullSyncRequests.Find((FullSyncObjectRequest r) => request.Identity.Equals(r.Identity) && request.ServiceInstanceId == r.ServiceInstanceId);

            if (fullSyncObjectRequest != null)
            {
                if (request.ObjectState == ObjectState.New)
                {
                    throw new ADObjectAlreadyExistsException(DirectoryStrings.ExceptionADOperationFailedAlreadyExist(this.configurationSession.DomainController, request.ToString()));
                }
                if (request.ObjectState == ObjectState.Changed)
                {
                    msoForwardSyncObjectFullSyncRequests.Remove(fullSyncObjectRequest);
                }
            }
            else
            {
                IEnumerable <FullSyncObjectRequest> source = from r in msoForwardSyncObjectFullSyncRequests
                                                             where request.ServiceInstanceId == r.ServiceInstanceId
                                                             select r;
                int maxObjectFullSyncRequestsPerServiceInstance = ProvisioningTasksConfigImpl.MaxObjectFullSyncRequestsPerServiceInstance;
                if (source.Count <FullSyncObjectRequest>() >= maxObjectFullSyncRequestsPerServiceInstance)
                {
                    throw new DataSourceOperationException(Strings.OperationExceedsPerServiceInstanceFullSyncObjectRequestLimit(maxObjectFullSyncRequestsPerServiceInstance, request.ServiceInstanceId));
                }
            }
            msoForwardSyncObjectFullSyncRequests.Add(request);
            this.configurationSession.Save(msoMainStreamCookieContainer);
        }
Ejemplo n.º 7
0
        public static void PerformConversion(string serviceInstanceName, int maxCookieHistoryCount, TimeSpan cookieHistoryInterval)
        {
            SyncServiceInstance syncServiceInstance = ServiceInstanceId.GetSyncServiceInstance(serviceInstanceName);

            if (syncServiceInstance != null && syncServiceInstance.IsMultiObjectCookieEnabled)
            {
                MsoMultiObjectCookieManager   msoMultiObjectCookieManager  = new MsoMultiObjectCookieManager(serviceInstanceName, maxCookieHistoryCount, cookieHistoryInterval, ForwardSyncCookieType.RecipientIncremental);
                MsoMultiObjectCookieManager   msoMultiObjectCookieManager2 = new MsoMultiObjectCookieManager(serviceInstanceName, maxCookieHistoryCount, cookieHistoryInterval, ForwardSyncCookieType.CompanyIncremental);
                ITopologyConfigurationSession ridmasterSession             = MsoCookieConverter.GetRIDMasterSession();
                MsoMainStreamCookieContainer  msoMainStreamCookieContainer = ridmasterSession.GetMsoMainStreamCookieContainer(serviceInstanceName);
                MsoCookieConverter.FromMultiValuedCookieToMultiObjectCookie(serviceInstanceName, msoMainStreamCookieContainer.MsoForwardSyncRecipientCookie, msoMultiObjectCookieManager);
                MsoCookieConverter.FromMultiValuedCookieToMultiObjectCookie(serviceInstanceName, msoMainStreamCookieContainer.MsoForwardSyncNonRecipientCookie, msoMultiObjectCookieManager2);
                ridmasterSession.UseConfigNC = true;
                ADObjectId orgContainerId = ridmasterSession.GetOrgContainerId();
                ADRawEntry adrawEntry     = ridmasterSession.ReadADRawEntry(orgContainerId.Parent, MsoCookieConverter.E14MsoMainStreamCookieContainerSchema.CookieProperties);
                MsoCookieConverter.FromMultiValuedCookieToMultiObjectCookie(serviceInstanceName, adrawEntry.propertyBag[MsoCookieConverter.E14MsoMainStreamCookieContainerSchema.MsoForwardSyncRecipientCookie] as IEnumerable <byte[]>, msoMultiObjectCookieManager);
                MsoCookieConverter.FromMultiValuedCookieToMultiObjectCookie(serviceInstanceName, adrawEntry.propertyBag[MsoCookieConverter.E14MsoMainStreamCookieContainerSchema.MsoForwardSyncNonRecipientCookie] as IEnumerable <byte[]>, msoMultiObjectCookieManager2);
            }
        }
Ejemplo n.º 8
0
        public override void WriteCookie(byte[] cookie, IEnumerable <string> filteredContextIds, DateTime timestamp, bool isUpgradingCookie, ServerVersion version, bool more)
        {
            if (cookie == null || cookie.Length == 0)
            {
                throw new ArgumentNullException("cookie");
            }
            MsoMainStreamCookieContainer        msoMainStreamCookieContainer = this.cookieSession.GetMsoMainStreamCookieContainer(base.ServiceInstanceName);
            MultiValuedProperty <byte[]>        multiValuedProperty          = this.RetrievePersistedCookies(msoMainStreamCookieContainer);
            List <MsoMainStreamCookieWithIndex> list = new List <MsoMainStreamCookieWithIndex>();

            for (int i = multiValuedProperty.Count - 1; i >= 0; i--)
            {
                MsoMainStreamCookie msoMainStreamCookie = null;
                Exception           ex = null;
                if (MsoMainStreamCookie.TryFromStorageCookie(multiValuedProperty[i], out msoMainStreamCookie, out ex) && string.Equals(base.ServiceInstanceName, msoMainStreamCookie.ServiceInstanceName, StringComparison.OrdinalIgnoreCase))
                {
                    list.Add(new MsoMainStreamCookieWithIndex(msoMainStreamCookie, i));
                }
            }
            List <MsoMainStreamCookieWithIndex> list2 = this.SortMainStreamCookieList(list);

            if (list2.Count >= 2)
            {
                MsoMainStreamCookieWithIndex msoMainStreamCookieWithIndex  = list2[list2.Count - 1];
                MsoMainStreamCookieWithIndex msoMainStreamCookieWithIndex2 = list2[list2.Count - 2];
                if (msoMainStreamCookieWithIndex.Cookie.TimeStamp < new DateTime(msoMainStreamCookieWithIndex2.Cookie.TimeStamp.Ticks + this.cookieHistoryInterval.Ticks, DateTimeKind.Utc))
                {
                    multiValuedProperty.RemoveAt(msoMainStreamCookieWithIndex.Index);
                }
                else if (list2.Count >= this.maxCookieHistoryCount)
                {
                    multiValuedProperty.RemoveAt(list2[0].Index);
                }
            }
            base.UpdateSyncPropertySetVersion(isUpgradingCookie, version, more);
            MsoMainStreamCookie msoMainStreamCookie2 = new MsoMainStreamCookie(base.ServiceInstanceName, cookie, timestamp, base.SyncPropertySetVersion, base.IsSyncPropertySetUpgrading);

            multiValuedProperty.Add(msoMainStreamCookie2.ToStorageCookie());
            this.cookieSession.Save(msoMainStreamCookieContainer);
            this.LogPersistCookieEvent();
        }
Ejemplo n.º 9
0
 protected abstract MultiValuedProperty <byte[]> RetrievePersistedCookies(MsoMainStreamCookieContainer container);
Ejemplo n.º 10
0
        public MultiValuedProperty <byte[]> RetrievePersistedCookies()
        {
            MsoMainStreamCookieContainer msoMainStreamCookieContainer = this.cookieSession.GetMsoMainStreamCookieContainer(base.ServiceInstanceName);

            return(this.RetrievePersistedCookies(msoMainStreamCookieContainer));
        }