Example #1
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));
        }
Example #2
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);
        }
Example #3
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));
                 }
             }
         }
     });
 }
Example #4
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;
            }
        }
Example #5
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);
        }