Esempio n. 1
0
 internal MsoMultiObjectCookieManager(string serviceInstanceName, int maxCookieHistoryCount, TimeSpan cookieHistoryInterval, ForwardSyncCookieType cookieType) : base(serviceInstanceName, maxCookieHistoryCount, cookieHistoryInterval)
 {
     this.cookieSession             = DirectorySessionFactory.Default.CreateTopologyConfigurationSession(false, ConsistencyMode.PartiallyConsistent, ADSessionSettings.FromRootOrgScopeSet(), 71, ".ctor", "f:\\15.00.1497\\sources\\dev\\data\\src\\directory\\Sync\\CookieManager\\MsoMultiObjectCookieManager.cs");
     this.cookieSession.UseConfigNC = false;
     this.cookieType          = cookieType;
     this.cookieRootContainer = MsoMultiObjectCookieManager.CreateOrGetRootContainer(serviceInstanceName, this.cookieSession);
     ForwardSyncCookieHeader[] source = MsoMultiObjectCookieManager.LoadCookieHeaders(this.cookieSession, serviceInstanceName, this.cookieType);
     this.cookieHeaderList = source.ToList <ForwardSyncCookieHeader>();
 }
        public static void ConvertE15toE14MV(SyncServiceInstance serviceInstance, int maxCookieHistoryCount, TimeSpan cookieHistoryInterval)
        {
            ITopologyConfigurationSession ridmasterSession = MsoCookieConverter.GetRIDMasterSession();
            MsoMainStreamCookie           cookieToAdd      = null;
            MsoMainStreamCookie           cookieToAdd2     = null;

            if (serviceInstance.IsMultiObjectCookieEnabled)
            {
                MsoMultiObjectCookieManager msoMultiObjectCookieManager  = new MsoMultiObjectCookieManager(serviceInstance.Name, maxCookieHistoryCount, cookieHistoryInterval, ForwardSyncCookieType.CompanyIncremental);
                MsoMultiObjectCookieManager msoMultiObjectCookieManager2 = new MsoMultiObjectCookieManager(serviceInstance.Name, maxCookieHistoryCount, cookieHistoryInterval, ForwardSyncCookieType.RecipientIncremental);
                ForwardSyncCookie           forwardSyncCookie            = msoMultiObjectCookieManager.ReadMostRecentCookie();
                ForwardSyncCookie           forwardSyncCookie2           = msoMultiObjectCookieManager2.ReadMostRecentCookie();
                if (forwardSyncCookie != null)
                {
                    cookieToAdd = new MsoMainStreamCookie(serviceInstance.Name, forwardSyncCookie.Data, forwardSyncCookie.Timestamp, new ServerVersion(forwardSyncCookie.SyncPropertySetVersion), forwardSyncCookie.IsUpgradingSyncPropertySet);
                }
                if (forwardSyncCookie2 != null)
                {
                    cookieToAdd2 = new MsoMainStreamCookie(serviceInstance.Name, forwardSyncCookie2.Data, forwardSyncCookie2.Timestamp, new ServerVersion(forwardSyncCookie2.SyncPropertySetVersion), forwardSyncCookie2.IsUpgradingSyncPropertySet);
                }
            }
            else
            {
                MsoCompanyMainStreamCookieManager   msoCompanyMainStreamCookieManager   = new MsoCompanyMainStreamCookieManager(serviceInstance.Name, maxCookieHistoryCount, cookieHistoryInterval);
                MsoRecipientMainStreamCookieManager msoRecipientMainStreamCookieManager = new MsoRecipientMainStreamCookieManager(serviceInstance.Name, maxCookieHistoryCount, cookieHistoryInterval);
                cookieToAdd  = msoCompanyMainStreamCookieManager.ReadMostRecentCookie();
                cookieToAdd2 = msoRecipientMainStreamCookieManager.ReadMostRecentCookie();
            }
            ridmasterSession.UseConfigNC = true;
            MsoCookieConverter.E14MsoMainStreamCookieContainer[] array = ridmasterSession.Find <MsoCookieConverter.E14MsoMainStreamCookieContainer>(ridmasterSession.GetOrgContainerId().Parent, QueryScope.SubTree, null, null, 1);
            if (array == null || array.Length == 0)
            {
                throw new ExchangeConfigurationContainerNotFoundException();
            }
            List <MsoMainStreamCookie> list  = MsoCookieConverter.GetOrderedE14CookieList(array[0].MsoForwardSyncNonRecipientCookie);
            List <MsoMainStreamCookie> list2 = MsoCookieConverter.GetOrderedE14CookieList(array[0].MsoForwardSyncRecipientCookie);

            list  = MsoCookieConverter.AddCookieToE14MVList(serviceInstance.Name, maxCookieHistoryCount, cookieHistoryInterval, cookieToAdd, list);
            list2 = MsoCookieConverter.AddCookieToE14MVList(serviceInstance.Name, maxCookieHistoryCount, cookieHistoryInterval, cookieToAdd2, list2);
            array[0].MsoForwardSyncNonRecipientCookie.Clear();
            foreach (MsoMainStreamCookie msoMainStreamCookie in list)
            {
                array[0].MsoForwardSyncNonRecipientCookie.Add(msoMainStreamCookie.ToStorageCookie());
            }
            array[0].MsoForwardSyncRecipientCookie.Clear();
            foreach (MsoMainStreamCookie msoMainStreamCookie2 in list2)
            {
                array[0].MsoForwardSyncRecipientCookie.Add(msoMainStreamCookie2.ToStorageCookie());
            }
            ridmasterSession.Save(array[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);
            }
        }
        private static void FromMultiValuedCookieToMultiObjectCookie(string serviceInstanceName, IEnumerable <byte[]> multiValueCookieAttribute, MsoMultiObjectCookieManager msoMultiObjectCookieManager)
        {
            List <MsoMainStreamCookie> ordredCookieList = MsoCookieConverter.GetOrdredCookieList(serviceInstanceName, multiValueCookieAttribute);

            if (ordredCookieList.Count > 0)
            {
                ForwardSyncCookie   forwardSyncCookie   = msoMultiObjectCookieManager.ReadMostRecentCookie();
                MsoMainStreamCookie msoMainStreamCookie = ordredCookieList.Last <MsoMainStreamCookie>();
                if (forwardSyncCookie == null || msoMainStreamCookie.TimeStamp > forwardSyncCookie.Timestamp)
                {
                    msoMultiObjectCookieManager.WriteCookie(msoMainStreamCookie.RawCookie, null, msoMainStreamCookie.TimeStamp, msoMainStreamCookie.IsSyncPropertySetUpgrading, msoMainStreamCookie.SyncPropertySetVersion, true);
                }
            }
        }