Ejemplo n.º 1
0
 internal static void ContentMailboxInfoSetter(object value, IPropertyBag propertyBag)
 {
     propertyBag[PublicFolderSchema.ReplicaListBinary] = ((value != null) ? ReplicaListProperty.GetBytesFromStringArray(new string[]
     {
         ((PublicFolderContentMailboxInfo)value).ToString()
     }) : null);
 }
Ejemplo n.º 2
0
        internal static PublicFolderContentMailboxInfo ContentMailboxInfoGetter(IPropertyBag propertyBag)
        {
            string contentMailboxInfo = null;

            byte[] array = propertyBag[PublicFolderSchema.ReplicaListBinary] as byte[];
            if (array != null)
            {
                string[] stringArrayFromBytes = ReplicaListProperty.GetStringArrayFromBytes(array);
                if (stringArrayFromBytes.Length > 0)
                {
                    contentMailboxInfo = stringArrayFromBytes[0];
                }
            }
            return(new PublicFolderContentMailboxInfo(contentMailboxInfo));
        }
Ejemplo n.º 3
0
        public override bool IsContentAvailableInTargetMailbox(FolderRecWrapper destinationFolderRec)
        {
            FolderMapping folderMapping = destinationFolderRec as FolderMapping;

            if (folderMapping.IsSystemPublicFolder || destinationFolderRec.IsPublicFolderDumpster)
            {
                return(false);
            }
            byte[] array = destinationFolderRec.FolderRec[PropTag.ReplicaList] as byte[];
            if (array != null)
            {
                StorePropertyDefinition replicaList = CoreFolderSchema.ReplicaList;
                string[] stringArrayFromBytes       = ReplicaListProperty.GetStringArrayFromBytes(array);
                Guid     a;
                return(stringArrayFromBytes.Length > 0 && GuidHelper.TryParseGuid(stringArrayFromBytes[0], out a) && a == base.TargetMailboxGuid);
            }
            return(true);
        }
Ejemplo n.º 4
0
 private void CheckFolderRestorePossible(Guid sourceMailboxGuid)
 {
     base.EnumerateFolderHierarchy(EnumHierarchyFlags.AllFolders, delegate(FolderRecWrapper fRec, FolderMap.EnumFolderContext ctx)
     {
         FolderMapping folderMapping = (FolderMapping)fRec;
         if ((folderMapping.Flags & FolderMappingFlags.Include) != FolderMappingFlags.None || (folderMapping.Flags & FolderMappingFlags.InheritedInclude) != FolderMappingFlags.None)
         {
             byte[] array = (byte[])folderMapping.FolderRec[PropTag.ReplicaList];
             if (array != null)
             {
                 string[] stringArrayFromBytes = ReplicaListProperty.GetStringArrayFromBytes(array);
                 Guid empty = Guid.Empty;
                 if (stringArrayFromBytes.Length > 0 && GuidHelper.TryParseGuid(stringArrayFromBytes[0], out empty) && empty == sourceMailboxGuid)
                 {
                     throw new FolderIsLivePermanentException(HexConverter.ByteArrayToHexString(folderMapping.EntryId));
                 }
             }
         }
     });
 }
Ejemplo n.º 5
0
        protected override FolderRecWrapper CreateDestinationFolder(SyncContext syncContext, FolderRecWrapper srcFolderRec, FolderRecWrapper destParentRec)
        {
            CreateFolderFlags createFolderFlags = CreateFolderFlags.None;

            if (base.IsRoot && base.IsPublicFolderMigration && base.DestMailbox.IsCapabilitySupported(MRSProxyCapabilities.CanStoreCreatePFDumpster))
            {
                createFolderFlags = CreateFolderFlags.CreatePublicFolderDumpster;
            }
            byte[] entryId;
            this.CreateFolder(PublicFolderMigrator.dummyEnumFolderContext, srcFolderRec, createFolderFlags, out entryId);
            FolderRecWrapper folderRecWrapper = syncContext.CreateTargetFolderRec(srcFolderRec);

            folderRecWrapper.FolderRec.EntryId  = entryId;
            folderRecWrapper.FolderRec.ParentId = destParentRec.EntryId;
            List <PropValueData> list = new List <PropValueData>(folderRecWrapper.FolderRec.AdditionalProps);

            list.Add(new PropValueData(PropTag.ReplicaList, ReplicaListProperty.GetBytesFromStringArray(new string[]
            {
                this.GetContentMailboxGuid(srcFolderRec).ToString()
            })));
            folderRecWrapper.FolderRec.AdditionalProps = list.ToArray();
            return(folderRecWrapper);
        }
Ejemplo n.º 6
0
        private void CreateDumpsterFoldersForWellKnownFolders()
        {
            FolderHierarchy folderHierarchy = base.DestMailboxWrapper.FolderMap as FolderHierarchy;

            foreach (FolderMapping folderMapping in new List <FolderMapping>(8)
            {
                folderHierarchy.GetWellKnownFolder(WellKnownFolderType.Root),
                folderHierarchy.GetWellKnownFolder(WellKnownFolderType.IpmSubtree),
                folderHierarchy.GetWellKnownFolder(WellKnownFolderType.NonIpmSubtree),
                folderHierarchy.GetWellKnownFolder(WellKnownFolderType.EFormsRegistry),
                folderHierarchy.GetWellKnownFolder(WellKnownFolderType.PublicFolderDumpsterRoot),
                folderHierarchy.GetWellKnownFolder(WellKnownFolderType.PublicFolderTombstonesRoot),
                folderHierarchy.GetWellKnownFolder(WellKnownFolderType.PublicFolderAsyncDeleteState),
                folderHierarchy.GetWellKnownFolder(WellKnownFolderType.PublicFolderInternalSubmission)
            })
            {
                List <PropValueData> list = new List <PropValueData>(2);
                using (IDestinationFolder folder = base.DestMailbox.GetFolder(folderMapping.EntryId))
                {
                    if (folder == null)
                    {
                        MrsTracer.Service.Error("Something deleted destination folder from under us", new object[0]);
                        throw new UnexpectedErrorPermanentException(-2147221238);
                    }
                    if (!this.AssociatedDumpsterExists(folder))
                    {
                        byte[] value = this.CreateAssociatedDumpsterFolder(folderMapping.FolderName, ReplicaListProperty.GetBytesFromStringArray(new string[]
                        {
                            base.TargetMailboxGuid.ToString()
                        }), folderMapping.EntryId);
                        list.Add(new PropValueData(PropTag.IpmWasteBasketEntryId, value));
                        folder.SetProps(list.ToArray());
                    }
                }
            }
        }
Ejemplo n.º 7
0
        public override void CopyFolderProperties(FolderRecWrapper sourceFolderRecWrapper, ISourceFolder sourceFolder, IDestinationFolder destFolder, FolderRecDataFlags dataToCopy, out bool wasPropertyCopyingSkipped)
        {
            Guid empty  = Guid.Empty;
            bool isRoot = base.IsRoot;
            bool flag   = false;

            wasPropertyCopyingSkipped = false;
            FolderMapping folderMapping = sourceFolderRecWrapper as FolderMapping;

            while (folderMapping.WKFType != WellKnownFolderType.Root)
            {
                if (folderMapping.IsLegacyPublicFolder)
                {
                    return;
                }
                folderMapping = (folderMapping.Parent as FolderMapping);
            }
            if (destFolder == null)
            {
                if (!isRoot || ((FolderMapping)sourceFolderRecWrapper).IsSystemPublicFolder)
                {
                    MrsTracer.Service.Debug("Skipping final property copying for \"{0}\" folder since it's contents don't reside in this mailbox", new object[]
                    {
                        sourceFolderRecWrapper.FullFolderName
                    });
                    return;
                }
                throw new FolderCopyFailedPermanentException(sourceFolderRecWrapper.FullFolderName);
            }
            else
            {
                PropValueData[] props = destFolder.GetProps(new PropTag[]
                {
                    PropTag.ReplicaList,
                    PropTag.IpmWasteBasketEntryId
                });
                IDataConverter <PropValue, PropValueData> dataConverter = new PropValueConverter();
                PropValue nativeRepresentation = dataConverter.GetNativeRepresentation(props[0]);
                byte[]    array = nativeRepresentation.Value as byte[];
                if (!nativeRepresentation.IsNull() && !nativeRepresentation.IsError() && array != null)
                {
                    StorePropertyDefinition replicaList = CoreFolderSchema.ReplicaList;
                    string[] stringArrayFromBytes       = ReplicaListProperty.GetStringArrayFromBytes(array);
                    if (stringArrayFromBytes.Length > 0 && GuidHelper.TryParseGuid(stringArrayFromBytes[0], out empty))
                    {
                        flag = (empty == base.TargetMailboxGuid);
                    }
                }
                FolderStateSnapshot folderStateSnapshot = base.ICSSyncState[sourceFolderRecWrapper.EntryId];
                FolderState         state = folderStateSnapshot.State;
                if (sourceFolder.GetFolderRec(this.GetAdditionalFolderPtags(), GetFolderRecFlags.None).IsGhosted)
                {
                    folderStateSnapshot.State |= FolderState.IsGhosted;
                }
                else
                {
                    folderStateSnapshot.State &= ~FolderState.IsGhosted;
                }
                if (state != folderStateSnapshot.State)
                {
                    base.SaveICSSyncState(false);
                }
                if (!isRoot && !flag)
                {
                    return;
                }
                List <PropValueData> list = new List <PropValueData>(2);
                bool flag2 = false;
                if (flag)
                {
                    PropValue nativeRepresentation2 = dataConverter.GetNativeRepresentation(sourceFolder.GetProps(new PropTag[]
                    {
                        PropTag.PfProxy
                    })[0]);
                    if (!nativeRepresentation2.IsNull() && !nativeRepresentation2.IsError())
                    {
                        byte[] array2 = nativeRepresentation2.Value as byte[];
                        if (array2 != null && array2.Length == 16 && new Guid(array2) != Guid.Empty)
                        {
                            Guid a     = Guid.Empty;
                            bool flag3 = base.Flags.HasFlag(MailboxCopierFlags.CrossOrg);
                            if (flag3)
                            {
                                a = destFolder.LinkMailPublicFolder(LinkMailPublicFolderFlags.EntryId, sourceFolderRecWrapper.EntryId);
                            }
                            else
                            {
                                a = destFolder.LinkMailPublicFolder(LinkMailPublicFolderFlags.ObjectGuid, array2);
                            }
                            if (a != Guid.Empty)
                            {
                                list.Add(new PropValueData(PropTag.PfProxy, a.ToByteArray()));
                                list.Add(new PropValueData(PropTag.PfProxyRequired, true));
                                flag2 = true;
                            }
                            else
                            {
                                base.Report.Append(new ReportEntry(MrsStrings.ReportFailedToLinkADPublicFolder(sourceFolderRecWrapper.FullFolderName, BitConverter.ToString(array2), BitConverter.ToString(sourceFolderRecWrapper.EntryId)), ReportEntryType.Warning));
                            }
                        }
                    }
                }
                if (!flag2)
                {
                    list.Add(new PropValueData(PropTag.PfProxy, Guid.Empty.ToByteArray()));
                    list.Add(new PropValueData(PropTag.PfProxyRequired, false));
                }
                List <PropValueData> list2 = new List <PropValueData>(9);
                if (isRoot)
                {
                    if (!flag)
                    {
                        dataToCopy &= (FolderRecDataFlags.SecurityDescriptors | FolderRecDataFlags.FolderAcls | FolderRecDataFlags.ExtendedAclInformation);
                    }
                    list2.AddRange(list);
                }
                else
                {
                    byte[] sessionSpecificEntryId = this.hierarchyMailbox.GetSessionSpecificEntryId(sourceFolderRecWrapper.EntryId);
                    using (IDestinationFolder folder = this.hierarchyMailbox.GetFolder(sessionSpecificEntryId))
                    {
                        if (folder == null)
                        {
                            MrsTracer.Service.Error("Something deleted destination hierarchy folder from under us", new object[0]);
                            throw new UnexpectedErrorPermanentException(-2147221238);
                        }
                        if (list.Count > 0)
                        {
                            folder.SetProps(list.ToArray());
                        }
                    }
                }
                base.CopyFolderProperties(sourceFolderRecWrapper, sourceFolder, destFolder, dataToCopy, out wasPropertyCopyingSkipped);
                PropTag[] pta = new PropTag[]
                {
                    PropTag.DisablePeruserRead,
                    PropTag.OverallAgeLimit,
                    PropTag.RetentionAgeLimit,
                    PropTag.PfQuotaStyle,
                    PropTag.PfOverHardQuotaLimit,
                    PropTag.PfStorageQuota,
                    PropTag.PfMsgSizeLimit
                };
                foreach (PropValueData propValueData in sourceFolder.GetProps(pta))
                {
                    PropValue nativeRepresentation3 = dataConverter.GetNativeRepresentation(propValueData);
                    if (!nativeRepresentation3.IsNull() && !nativeRepresentation3.IsError())
                    {
                        if (propValueData.PropTag == 1721303043 && (int)propValueData.Value > 0)
                        {
                            propValueData.Value = (int)EnhancedTimeSpan.FromDays((double)((int)propValueData.Value)).TotalSeconds;
                        }
                        list2.Add(propValueData);
                    }
                }
                if (list2.Count > 0)
                {
                    destFolder.SetProps(list2.ToArray());
                }
                return;
            }
        }
Ejemplo n.º 8
0
        public override void CreateFolder(FolderMap.EnumFolderContext context, FolderRecWrapper sourceFolderRecWrapper, CreateFolderFlags createFolderFlags, out byte[] newFolderEntryId)
        {
            if (sourceFolderRecWrapper.IsInternalAccess)
            {
                throw new InternalAccessFolderCreationIsNotSupportedException();
            }
            newFolderEntryId = null;
            FolderMapping   folderMapping   = sourceFolderRecWrapper as FolderMapping;
            FolderHierarchy folderHierarchy = base.DestMailboxWrapper.FolderMap as FolderHierarchy;

            byte[]        sessionSpecificEntryId = base.DestMailbox.GetSessionSpecificEntryId(folderMapping.EntryId);
            FolderMapping folderMapping2         = folderMapping.Parent as FolderMapping;
            bool          isRoot = base.IsRoot;

            byte[] parentId;
            switch (folderMapping2.WKFType)
            {
            case WellKnownFolderType.Root:
            case WellKnownFolderType.NonIpmSubtree:
            case WellKnownFolderType.IpmSubtree:
            case WellKnownFolderType.EFormsRegistry:
                parentId = folderHierarchy.GetWellKnownFolder(folderMapping2.WKFType).EntryId;
                break;

            default:
                if (isRoot || this.ShouldCreateUnderParentInSecondary())
                {
                    parentId = base.DestMailbox.GetSessionSpecificEntryId(folderMapping.ParentId);
                }
                else
                {
                    parentId = folderHierarchy.GetWellKnownFolder(WellKnownFolderType.IpmSubtree).EntryId;
                }
                break;
            }
            byte[] entryId   = folderMapping.FolderRec.EntryId;
            byte[] parentId2 = folderMapping.FolderRec.ParentId;
            folderMapping.FolderRec.EntryId  = sessionSpecificEntryId;
            folderMapping.FolderRec.ParentId = parentId;
            base.DestMailbox.CreateFolder(folderMapping.FolderRec, createFolderFlags, out newFolderEntryId);
            folderMapping.FolderRec.EntryId  = entryId;
            folderMapping.FolderRec.ParentId = parentId2;
            List <PropValueData> list           = new List <PropValueData>(2);
            Guid contentMailboxGuid             = this.GetContentMailboxGuid(sourceFolderRecWrapper);
            StorePropertyDefinition replicaList = CoreFolderSchema.ReplicaList;

            byte[] bytesFromStringArray = ReplicaListProperty.GetBytesFromStringArray(new string[]
            {
                contentMailboxGuid.ToString()
            });
            list.Add(new PropValueData(PropTag.ReplicaList, bytesFromStringArray));
            using (IDestinationFolder folder = base.DestMailbox.GetFolder(sessionSpecificEntryId))
            {
                if (folder == null)
                {
                    MrsTracer.Service.Error("Something deleted destination folder from under us", new object[0]);
                    throw new UnexpectedErrorPermanentException(-2147221238);
                }
                if (isRoot && !this.AssociatedDumpsterExists(folder))
                {
                    byte[] value = this.CreateAssociatedDumpsterFolder(folderMapping.FolderName, bytesFromStringArray, sessionSpecificEntryId);
                    list.Add(new PropValueData(PropTag.IpmWasteBasketEntryId, value));
                }
                folder.SetProps(list.ToArray());
            }
        }
Ejemplo n.º 9
0
        public static FolderRec Create(StoreSession storageSession, PropValue[] pva)
        {
            byte[]               array      = null;
            byte[]               array2     = null;
            FolderType           folderType = FolderType.Generic;
            string               text       = null;
            DateTime             dateTime   = DateTime.MinValue;
            List <PropValueData> list       = new List <PropValueData>();

            foreach (PropValue native in pva)
            {
                if (!native.IsNull() && !native.IsError())
                {
                    PropTag propTag = native.PropTag;
                    if (propTag <= PropTag.EntryId)
                    {
                        if (propTag == PropTag.ParentEntryId)
                        {
                            array2 = native.GetBytes();
                            goto IL_CD;
                        }
                        if (propTag == PropTag.EntryId)
                        {
                            array = native.GetBytes();
                            goto IL_CD;
                        }
                    }
                    else
                    {
                        if (propTag == PropTag.DisplayName)
                        {
                            text = native.GetString();
                            goto IL_CD;
                        }
                        if (propTag == PropTag.LastModificationTime)
                        {
                            dateTime = native.GetDateTime();
                            goto IL_CD;
                        }
                        if (propTag == PropTag.FolderType)
                        {
                            folderType = (FolderType)native.GetInt();
                            goto IL_CD;
                        }
                    }
                    list.Add(DataConverter <PropValueConverter, PropValue, PropValueData> .GetData(native));
                }
                IL_CD :;
            }
            if (array != null)
            {
                FolderRec folderRec = new FolderRec(array, array2, folderType, text, dateTime, (list.Count > 0) ? list.ToArray() : null);
                if (storageSession != null && folderRec[PropTag.ReplicaList] != null)
                {
                    folderRec.IsGhosted = !CoreFolder.IsContentAvailable(storageSession, CoreFolder.GetContentMailboxInfo(ReplicaListProperty.GetStringArrayFromBytes((byte[])folderRec[PropTag.ReplicaList])));
                }
                return(folderRec);
            }
            return(null);
        }