/// <summary>
 /// Initializes a new instance of the FolderEntryID class.
 /// </summary>
 /// <param name="objectType">Identify store object is a mailbox or a public folder.</param>
 public FolderEntryID(StoreObjectType objectType)
 {
     if (objectType == StoreObjectType.Mailbox)
     {
         this.folderType = new byte[] { 0x01, 0x00 };
     }
     else
     {
         this.folderType = new byte[] { 0x03, 0x00 };
     }
 }
 /// <summary>
 /// Initializes a new instance of the FolderEntryID class.
 /// </summary>
 /// <param name="objectType">Identify store object is a mailbox or a public folder.</param>
 /// <param name="providerUID">Provider id value which can get in logon response.</param>
 /// <param name="databaseGUID">DatabaseGUID of specific folder, which can get in folder's longterm id.</param>
 /// <param name="globalCounter">Global counter of specific folder, which can get in folder's longterm id.</param>
 public FolderEntryID(StoreObjectType objectType, byte[] providerUID, byte[] databaseGUID, byte[] globalCounter)
 {
     this.providerUID = providerUID;
     this.dataBaseGUID = databaseGUID;
     this.globalCounter = globalCounter;
     if (objectType == StoreObjectType.Mailbox)
     {
         this.folderType = new byte[] { 0x01, 0x00 };
     }
     else
     {
         this.folderType = new byte[] { 0x03, 0x00 };
     }
 }
 /// <summary>
 /// Initializes a new instance of the StoreObjectEntryID class.
 /// </summary>
 public StoreObjectEntryID()
 {
     this.objectType = StoreObjectType.Mailbox;
 }
        /// <summary>
        /// Deserialized byte array to an ActionBlock instance
        /// </summary>
        /// <param name="buffer">Byte array contain data of an ActionBlock instance.</param>
        /// <returns>Bytes count that deserialized in buffer.</returns>
        public uint Deserialize(byte[] buffer)
        {
            BufferReader reader = new BufferReader(buffer);
            uint flags = reader.ReadUInt32();
            if (this.Flags != flags)
            {
                string errorMessage = "Flags MUST be 0x00000000, the actual value is " + flags.ToString() + "!";
                throw new ArgumentException(errorMessage);
            }

            byte[] providerUID = reader.ReadBytes(16);
            if (!Common.CompareByteArray(this.ProviderUID, providerUID))
            {
                string errorMessage = "ProviderUID MUST be %x38.A1.BB.10.05.E5.10.1A.A1.BB.08.00.2B.2A.56.C2., the actual value is " + providerUID.ToString() + "!";
                throw new ArgumentException(errorMessage);
            }

            byte version = reader.ReadByte();
            if (this.Version != version)
            {
                string errorMessage = "Version MUST be zero., the actual value is " + version.ToString() + "!";
                throw new ArgumentException(errorMessage);
            }

            byte flag = reader.ReadByte();
            if (this.Flag != flag)
            {
                string errorMessage = "Flag MUST be zero, the actual value is " + flag.ToString() + "!";
                throw new ArgumentException(errorMessage);
            }

            byte[] dllFileName = reader.ReadBytes(14);
            if (!Common.CompareByteArray(this.DLLFileName, dllFileName))
            {
                string errorMessage = "DLLFileName MUST be set to the following value which represents \"emsmdb.dll\": %x45.4D.53.4D.44.42.2E.44.4C.4C.00.00.00.00., the actual value is " + dllFileName.ToString() + "!";
                throw new ArgumentException(errorMessage);
            }

            uint wrappedFlags = reader.ReadUInt32();
            if (this.WrappedFlags != wrappedFlags)
            {
                string errorMessage = "WrappedFlags MUST be 0x00000000, the actual value is " + wrappedFlags.ToString() + "!";
                throw new ArgumentException(errorMessage);
            }

            byte[] wrappedProviderUID = reader.ReadBytes(16);
            if (Common.CompareByteArray(this.mailboxWrappedProviderUID, wrappedProviderUID))
            {
                this.objectType = StoreObjectType.Mailbox;
            }
            else if (Common.CompareByteArray(this.publicFolderWrappedProviderUID, wrappedProviderUID))
            {
                this.objectType = StoreObjectType.PublicFolder;
            }
            else
            {
                string errorMessage = "WrappedProviderUID is not mailbox or public folder, the actual wrappedProviderUID value is " + wrappedProviderUID.ToString() + "!";
                throw new ArgumentException(errorMessage);
            }

            uint wrappedType = reader.ReadUInt32();
            if (this.WrappedType != wrappedType)
            {
                if (this.ObjectType == StoreObjectType.Mailbox)
                {
                    string errorMessage = "For Mailbox Store object, WrappedType MUST be %x0C.00.00.00, the actual value is " + StoreObjectType.Mailbox.ToString() + "!";
                    throw new ArgumentException(errorMessage);
                }
                else
                {
                    string errorMessage = "For Public folder Store object, WrappedType MUST be %x06.00.00.00, the actual value is " + wrappedType.ToString() + "!";
                    throw new ArgumentException(errorMessage);
                }
            }

            this.ServerShortname = reader.ReadASCIIString();
            this.MailBoxDN = reader.ReadASCIIString();
            return reader.Position;
        }
예제 #5
0
 private StoreObjectIdentifier(StoreObjectType storeObjectType, string name, string schema = null)
 {
     StoreObjectType = storeObjectType;
     Name            = name;
     Schema          = schema;
 }
 /// <summary>
 /// Initializes a new instance of the StoreObjectEntryID class.
 /// </summary>
 public StoreObjectEntryID()
 {
     this.objectType = StoreObjectType.Mailbox;
 }
        /// <summary>
        /// Deserialized byte array to an ActionBlock instance
        /// </summary>
        /// <param name="buffer">Byte array contain data of an ActionBlock instance.</param>
        /// <returns>Bytes count that deserialized in buffer.</returns>
        public uint Deserialize(byte[] buffer)
        {
            BufferReader reader = new BufferReader(buffer);
            uint         flags  = reader.ReadUInt32();

            if (this.Flags != flags)
            {
                string errorMessage = "Flags MUST be 0x00000000, the actual value is " + flags.ToString() + "!";
                throw new ArgumentException(errorMessage);
            }

            byte[] providerUID = reader.ReadBytes(16);
            if (!Common.CompareByteArray(this.ProviderUID, providerUID))
            {
                string errorMessage = "ProviderUID MUST be %x38.A1.BB.10.05.E5.10.1A.A1.BB.08.00.2B.2A.56.C2., the actual value is " + providerUID.ToString() + "!";
                throw new ArgumentException(errorMessage);
            }

            byte version = reader.ReadByte();

            if (this.Version != version)
            {
                string errorMessage = "Version MUST be zero., the actual value is " + version.ToString() + "!";
                throw new ArgumentException(errorMessage);
            }

            byte flag = reader.ReadByte();

            if (this.Flag != flag)
            {
                string errorMessage = "Flag MUST be zero, the actual value is " + flag.ToString() + "!";
                throw new ArgumentException(errorMessage);
            }

            byte[] dllFileName = reader.ReadBytes(14);
            if (!Common.CompareByteArray(this.DLLFileName, dllFileName))
            {
                string errorMessage = "DLLFileName MUST be set to the following value which represents \"emsmdb.dll\": %x45.4D.53.4D.44.42.2E.44.4C.4C.00.00.00.00., the actual value is " + dllFileName.ToString() + "!";
                throw new ArgumentException(errorMessage);
            }

            uint wrappedFlags = reader.ReadUInt32();

            if (this.WrappedFlags != wrappedFlags)
            {
                string errorMessage = "WrappedFlags MUST be 0x00000000, the actual value is " + wrappedFlags.ToString() + "!";
                throw new ArgumentException(errorMessage);
            }

            byte[] wrappedProviderUID = reader.ReadBytes(16);
            if (Common.CompareByteArray(this.mailboxWrappedProviderUID, wrappedProviderUID))
            {
                this.objectType = StoreObjectType.Mailbox;
            }
            else if (Common.CompareByteArray(this.publicFolderWrappedProviderUID, wrappedProviderUID))
            {
                this.objectType = StoreObjectType.PublicFolder;
            }
            else
            {
                string errorMessage = "WrappedProviderUID is not mailbox or public folder, the actual wrappedProviderUID value is " + wrappedProviderUID.ToString() + "!";
                throw new ArgumentException(errorMessage);
            }

            uint wrappedType = reader.ReadUInt32();

            if (this.WrappedType != wrappedType)
            {
                if (this.ObjectType == StoreObjectType.Mailbox)
                {
                    string errorMessage = "For Mailbox Store object, WrappedType MUST be %x0C.00.00.00, the actual value is " + StoreObjectType.Mailbox.ToString() + "!";
                    throw new ArgumentException(errorMessage);
                }
                else
                {
                    string errorMessage = "For Public folder Store object, WrappedType MUST be %x06.00.00.00, the actual value is " + wrappedType.ToString() + "!";
                    throw new ArgumentException(errorMessage);
                }
            }

            this.ServerShortname = reader.ReadASCIIString();
            this.MailBoxDN       = reader.ReadASCIIString();
            return(reader.Position);
        }
예제 #8
0
        private static StoreObjectType?TryDetectFolderTreeDataStoreObjectType(ICorePropertyBag propertyBag, string itemClass, StoreObjectType detectedType)
        {
            StoreObjectType?result = null;

            if (ObjectClass.IsFolderTreeData(itemClass))
            {
                propertyBag.Load(new StorePropertyDefinition[]
                {
                    FolderTreeDataSchema.GroupSection,
                    FolderTreeDataSchema.Type
                });
                FolderTreeDataSection?valueAsNullable  = propertyBag.GetValueAsNullable <FolderTreeDataSection>(FolderTreeDataSchema.GroupSection);
                FolderTreeDataType?   valueAsNullable2 = propertyBag.GetValueAsNullable <FolderTreeDataType>(FolderTreeDataSchema.Type);
                if (valueAsNullable == FolderTreeDataSection.Calendar)
                {
                    if (valueAsNullable2 == FolderTreeDataType.Header)
                    {
                        result = new StoreObjectType?(StoreObjectType.CalendarGroup);
                    }
                    else if (valueAsNullable2 == FolderTreeDataType.NormalFolder || valueAsNullable2 == FolderTreeDataType.SharedFolder)
                    {
                        result = new StoreObjectType?(StoreObjectType.CalendarGroupEntry);
                    }
                }
                else if (valueAsNullable == FolderTreeDataSection.First)
                {
                    result = new StoreObjectType?(StoreObjectType.FavoriteFolderEntry);
                }
                else if (valueAsNullable == FolderTreeDataSection.Tasks)
                {
                    if (valueAsNullable2 == FolderTreeDataType.Header)
                    {
                        result = new StoreObjectType?(StoreObjectType.TaskGroup);
                    }
                    else if (valueAsNullable2 == FolderTreeDataType.NormalFolder)
                    {
                        result = new StoreObjectType?(StoreObjectType.TaskGroupEntry);
                    }
                }
            }
            return(result);
        }
예제 #9
0
 internal static FolderCreateInfo GetFolderCreateInfo(StoreObjectType folderType)
 {
     return(FolderCreateInfo.folderCreateInfoDictionary[folderType]);
 }
예제 #10
0
 public new static ContactsFolder Create(StoreSession session, StoreId parentFolderId, StoreObjectType folderType, string displayName, CreateMode createMode)
 {
     EnumValidator.ThrowIfInvalid <CreateMode>(createMode, "createMode");
     EnumValidator.ThrowIfInvalid <StoreObjectType>(folderType, StoreObjectType.ContactsFolder);
     return((ContactsFolder)Folder.Create(session, parentFolderId, StoreObjectType.ContactsFolder, displayName, createMode));
 }
예제 #11
0
 public new static ContactsFolder Create(StoreSession session, StoreId parentFolderId, StoreObjectType folderType)
 {
     EnumValidator.ThrowIfInvalid <StoreObjectType>(folderType, StoreObjectType.ContactsFolder);
     return(ContactsFolder.Create(session, parentFolderId));
 }
예제 #12
0
        private static Schema GetSchema(StoreObjectType objectType)
        {
            switch (objectType)
            {
            case StoreObjectType.Folder:
            case StoreObjectType.CalendarFolder:
            case StoreObjectType.ContactsFolder:
            case StoreObjectType.TasksFolder:
            case StoreObjectType.NotesFolder:
            case StoreObjectType.JournalFolder:
            case StoreObjectType.SearchFolder:
            case StoreObjectType.OutlookSearchFolder:
            case StoreObjectType.ShortcutFolder:
                return(FolderSchema.Instance);

            case StoreObjectType.Message:
            case StoreObjectType.ConflictMessage:
            case StoreObjectType.TaskRequest:
            case StoreObjectType.Note:
            case StoreObjectType.OofMessage:
            case StoreObjectType.ExternalOofMessage:
                return(MessageItemSchema.Instance);

            case StoreObjectType.MeetingMessage:
            case StoreObjectType.MeetingCancellation:
                return(MeetingMessageInstanceSchema.Instance);

            case StoreObjectType.MeetingRequest:
                return(MeetingRequestSchema.Instance);

            case StoreObjectType.MeetingResponse:
                return(MeetingResponseSchema.Instance);

            case StoreObjectType.CalendarItem:
                return(CalendarItemSchema.Instance);

            case StoreObjectType.CalendarItemOccurrence:
                return(CalendarItemOccurrenceSchema.Instance);

            case StoreObjectType.Contact:
                return(ContactSchema.Instance);

            case StoreObjectType.DistributionList:
                return(DistributionListSchema.Instance);

            case StoreObjectType.Task:
                return(TaskSchema.Instance);

            case StoreObjectType.Post:
                return(PostItemSchema.Instance);

            case StoreObjectType.Report:
                return(ReportMessageSchema.Instance);

            case StoreObjectType.MeetingForwardNotification:
                return(MeetingForwardNotificationSchema.Instance);

            case StoreObjectType.ConversationActionItem:
                return(ConversationActionItemSchema.Instance);

            case StoreObjectType.SharingMessage:
                return(SharingMessageItemSchema.Instance);

            case StoreObjectType.MeetingInquiryMessage:
                return(MeetingInquiryMessageSchema.Instance);

            case StoreObjectType.MailboxAssociationGroup:
                return(MailboxAssociationGroupSchema.Instance);

            case StoreObjectType.MailboxAssociationUser:
                return(MailboxAssociationUserSchema.Instance);

            case StoreObjectType.GroupMailboxRequestMessage:
                return(GroupMailboxJoinRequestMessageSchema.Instance);

            case StoreObjectType.ReminderMessage:
                return(ReminderMessageSchema.Instance);

            case StoreObjectType.Configuration:
                return(ConfigurationItemSchema.Instance);

            case StoreObjectType.HierarchySyncMetadata:
                return(HierarchySyncMetadataItemSchema.Instance);
            }
            return(ItemSchema.Instance);
        }
예제 #13
0
 private SharingDataType(string containerClass, string externalName, bool isExternallySharable, string publishName, string publishResourceName, LocalizedString displayName, DefaultFolderType defaultFolderType, StoreObjectType storeObjectType)
 {
     Util.ThrowOnNullOrEmptyArgument(containerClass, "containerClass");
     Util.ThrowOnNullOrEmptyArgument(externalName, "externalName");
     this.PublishResourceName  = publishResourceName;
     this.ContainerClass       = containerClass;
     this.ExternalName         = externalName;
     this.IsExternallySharable = isExternallySharable;
     this.PublishName          = publishName;
     this.DisplayName          = displayName;
     this.DefaultFolderType    = defaultFolderType;
     this.StoreObjectType      = storeObjectType;
 }
예제 #14
0
 private static StoreObjectType?TryDetectRightsManagementStoreObjectType(ICorePropertyBag propertyBag, string itemClass, StoreObjectType detectedType)
 {
     if (detectedType != StoreObjectType.Message || !ObjectClass.IsRightsManagedContentClass(propertyBag.GetValueOrDefault <string>(CoreObjectSchema.ContentClass, null)))
     {
         return(null);
     }
     return(new StoreObjectType?(StoreObjectType.RightsManagedMessage));
 }
예제 #15
0
 private static StoreObjectType?TryDetectShortcutMessageEntryStoreObjectType(ICorePropertyBag propertyBag, string itemClass, StoreObjectType detectedType)
 {
     if (detectedType != StoreObjectType.Message || !ObjectClass.IsShortcutMessageEntry(propertyBag.GetValueOrDefault <int>(CoreItemSchema.FavLevelMask, -1)))
     {
         return(null);
     }
     return(new StoreObjectType?(StoreObjectType.ShortcutMessage));
 }
 private static void ParseChangeKeyString(string changeKey, out byte[] realChangeKey, out StoreObjectType objectType)
 {
     try
     {
         byte[] array = Convert.FromBase64String(changeKey);
         int    num   = array.Length;
         int    num2  = 0;
         if (num < 4)
         {
             throw new WebServiceProxyInvalidResponseException(Strings.InvalidChangeKeyReturned);
         }
         objectType = (StoreObjectType)BitConverter.ToInt32(array, num2);
         num2      += 4;
         if (!EnumValidator.IsValidValue <StoreObjectType>(objectType))
         {
             throw new WebServiceProxyInvalidResponseException(Strings.InvalidChangeKeyReturned);
         }
         if (num2 == num)
         {
             realChangeKey = null;
         }
         else
         {
             int num3 = BitConverter.ToInt32(array, num2);
             num2 += 4;
             if (num3 <= 0)
             {
                 realChangeKey = null;
             }
             else
             {
                 if (num3 > 512)
                 {
                     throw new WebServiceProxyInvalidResponseException(Strings.InvalidChangeKeyReturned);
                 }
                 if (num3 != num - num2)
                 {
                     throw new WebServiceProxyInvalidResponseException(Strings.InvalidChangeKeyReturned);
                 }
                 realChangeKey = new byte[num3];
                 Array.Copy(array, num2, realChangeKey, 0, num3);
                 num2 += num3;
             }
         }
     }
     catch (FormatException innerException)
     {
         throw new WebServiceProxyInvalidResponseException(Strings.InvalidChangeKeyReturned, innerException);
     }
     catch (ArgumentOutOfRangeException innerException2)
     {
         throw new WebServiceProxyInvalidResponseException(Strings.InvalidChangeKeyReturned, innerException2);
     }
 }
예제 #17
0
        public static VersionedId Deserialize(byte[] providerSpecificId, byte[] byteArrayChangeKey, StoreObjectType objectType)
        {
            if (providerSpecificId == null || byteArrayChangeKey == null)
            {
                throw new ArgumentNullException();
            }
            StoreObjectId itemId = StoreObjectId.FromProviderSpecificId(providerSpecificId, objectType);

            return(new VersionedId(itemId, byteArrayChangeKey));
        }
예제 #18
0
        public void New()
        {
            ExTraceGlobals.MailCallTracer.TraceDebug((long)this.GetHashCode(), "TreeEventHandler.New");
            OwaStoreObjectId owaStoreObjectId = (OwaStoreObjectId)base.GetParameter("destId");

            if (owaStoreObjectId.IsOtherMailbox)
            {
                throw new OwaInvalidRequestException("Cannot add new folder underneath a shared folder");
            }
            string text       = (string)base.GetParameter("fC");
            string text2      = (string)base.GetParameter("fN");
            bool   isExpanded = (bool)base.GetParameter("exp");

            if (Utilities.IsDefaultFolderId(base.UserContext, owaStoreObjectId, DefaultFolderType.SearchFolders))
            {
                throw new OwaInvalidRequestException("Cannot Create new Search Folder through OWA");
            }
            if (Utilities.IsELCRootFolder(owaStoreObjectId, base.UserContext))
            {
                throw new OwaInvalidRequestException("Cannot create new folders under the root ELC folder.");
            }
            text2 = text2.Trim();
            if (text2.Length == 0)
            {
                throw new OwaEventHandlerException("User did not provide name for new folder", LocalizedStrings.GetNonEncoded(-41080803), true);
            }
            StoreObjectType objectType = owaStoreObjectId.StoreObjectId.ObjectType;

            if (!this.CanFolderHaveSubFolders(owaStoreObjectId))
            {
                throw new OwaInvalidRequestException("Cannot Create new Search Folder through OWA");
            }
            using (Folder folder = Utilities.CreateSubFolder(owaStoreObjectId, objectType, text2, base.UserContext))
            {
                folder.ClassName = text;
                try
                {
                    folder.Save();
                }
                catch (ObjectExistedException)
                {
                    throw;
                }
                catch (StoragePermanentException innerException)
                {
                    throw new OwaAccessDeniedException(LocalizedStrings.GetNonEncoded(995407892), innerException);
                }
                folder.Load();
                OwaStoreObjectId newFolderId = OwaStoreObjectId.CreateFromStoreObject(folder);
                this.RenderFolderTreeChangedNode(owaStoreObjectId, newFolderId, isExpanded, owaStoreObjectId.IsArchive, (FolderTreeRenderType)base.GetParameter("rdt"));
                NavigationTreeDirtyFlag navigationTreeDirtyFlag = FolderTreeNode.GetAffectedTreeFromContainerClass(text);
                if (owaStoreObjectId.IsArchive)
                {
                    navigationTreeDirtyFlag |= NavigationTreeDirtyFlag.Favorites;
                }
                if (navigationTreeDirtyFlag != NavigationTreeDirtyFlag.Favorites || owaStoreObjectId.IsArchive)
                {
                    RenderingUtilities.RenderNavigationTreeDirtyFlag(this.Writer, base.UserContext, navigationTreeDirtyFlag, (NavigationModule[])base.GetParameter("cms"));
                }
            }
        }
 /// <summary>
 /// Parse the FolderEntryID structure.
 /// </summary>
 /// <param name="s">A stream containing the FolderEntryID structure</param>
 public override void Parse(Stream s)
 {
     base.Parse(s);
     this.Flags = ReadUint();
     byte[] tempProviderUID = ReadBytes(16);
     byte[] VerifyProviderUID = { 0x1A, 0x44, 0x73, 0x90, 0xAA, 0x66, 0x11, 0xCD, 0x9B, 0xC8, 0x00, 0xAA, 0x00, 0x2F, 0xC4, 0x5A };
     if (tempProviderUID == VerifyProviderUID)
     {
         this.ProviderUID = tempProviderUID;
     }
     else
     {
         this.ProviderUID = new Guid(tempProviderUID);
     }
     this.FolderType = (StoreObjectType)ReadUshort();
     this.DatabaseGuid = ReadGuid();
     this.GlobalCounter = ReadBytes(6);
     this.Pad = ReadUshort();
 }
예제 #20
0
        public ICoreItem OpenAttachedItem(ICollection <PropertyDefinition> propertiesToLoad, AttachmentPropertyBag attachmentBag, bool isNew)
        {
            MapiMessage            mapiMessage            = null;
            PersistablePropertyBag persistablePropertyBag = null;
            CoreItem      coreItem      = null;
            bool          flag          = false;
            StoreObjectId storeObjectId = null;

            byte[]    array = null;
            ICoreItem result;

            try
            {
                StoreObjectPropertyBag storeObjectPropertyBag = (StoreObjectPropertyBag)attachmentBag.PersistablePropertyBag;
                MapiAttach             mapiAttach             = (MapiAttach)storeObjectPropertyBag.MapiProp;
                StoreSession           session           = this.AttachmentCollection.ContainerItem.Session;
                OpenPropertyFlags      openPropertyFlags = isNew ? OpenPropertyFlags.Create : (this.AttachmentCollection.IsReadOnly ? OpenPropertyFlags.BestAccess : OpenPropertyFlags.BestAccess);
                openPropertyFlags |= OpenPropertyFlags.DeferredErrors;
                string text   = storeObjectPropertyBag.TryGetProperty(InternalSchema.ItemClass) as string;
                Schema schema = (text != null) ? ObjectClass.GetSchema(text) : MessageItemSchema.Instance;
                propertiesToLoad = InternalSchema.Combine <PropertyDefinition>(schema.AutoloadProperties, propertiesToLoad);
                StoreSession session2 = this.AttachmentCollection.ContainerItem.Session;
                bool         flag2    = false;
                try
                {
                    if (session2 != null)
                    {
                        session2.BeginMapiCall();
                        session2.BeginServerHealthCall();
                        flag2 = true;
                    }
                    if (StorageGlobals.MapiTestHookBeforeCall != null)
                    {
                        StorageGlobals.MapiTestHookBeforeCall(MethodBase.GetCurrentMethod());
                    }
                    mapiMessage = mapiAttach.OpenEmbeddedMessage(openPropertyFlags);
                }
                catch (MapiPermanentException ex)
                {
                    throw StorageGlobals.TranslateMapiException(ServerStrings.MapiCannotOpenEmbeddedMessage, ex, session2, this, "{0}. MapiException = {1}.", new object[]
                    {
                        string.Format("MapiAttachmentProvider::OpenAttachedItem", new object[0]),
                        ex
                    });
                }
                catch (MapiRetryableException ex2)
                {
                    throw StorageGlobals.TranslateMapiException(ServerStrings.MapiCannotOpenEmbeddedMessage, ex2, session2, this, "{0}. MapiException = {1}.", new object[]
                    {
                        string.Format("MapiAttachmentProvider::OpenAttachedItem", new object[0]),
                        ex2
                    });
                }
                finally
                {
                    try
                    {
                        if (session2 != null)
                        {
                            session2.EndMapiCall();
                            if (flag2)
                            {
                                session2.EndServerHealthCall();
                            }
                        }
                    }
                    finally
                    {
                        if (StorageGlobals.MapiTestHookAfterCall != null)
                        {
                            StorageGlobals.MapiTestHookAfterCall(MethodBase.GetCurrentMethod());
                        }
                    }
                }
                persistablePropertyBag = new StoreObjectPropertyBag(session, mapiMessage, propertiesToLoad);
                if (!isNew)
                {
                    StoreObjectType storeObjectType = ItemBuilder.ReadStoreObjectTypeFromPropertyBag(persistablePropertyBag);
                    ItemCreateInfo  itemCreateInfo  = ItemCreateInfo.GetItemCreateInfo(storeObjectType);
                    propertiesToLoad = InternalSchema.Combine <PropertyDefinition>(itemCreateInfo.Schema.AutoloadProperties, propertiesToLoad);
                    if (this.AttachmentCollection.IsReadOnly)
                    {
                        StoreId.SplitStoreObjectIdAndChangeKey(StoreObjectId.DummyId, out storeObjectId, out array);
                    }
                    persistablePropertyBag = new AcrPropertyBag(persistablePropertyBag, itemCreateInfo.AcrProfile, storeObjectId, new RetryBagFactory(session), array);
                }
                coreItem = new CoreItem(session, persistablePropertyBag, storeObjectId, array, isNew ? Origin.New : Origin.Existing, ItemLevel.Attached, propertiesToLoad, ItemBindOption.None);
                if (text != null && isNew)
                {
                    coreItem.PropertyBag[InternalSchema.ItemClass] = text;
                }
                flag   = true;
                result = coreItem;
            }
            finally
            {
                if (!flag)
                {
                    if (coreItem != null)
                    {
                        coreItem.Dispose();
                        coreItem = null;
                    }
                    if (persistablePropertyBag != null)
                    {
                        persistablePropertyBag.Dispose();
                        persistablePropertyBag = null;
                    }
                    if (mapiMessage != null)
                    {
                        mapiMessage.Dispose();
                        mapiMessage = null;
                    }
                }
            }
            return(result);
        }
예제 #21
0
        public static SyncStateUpgradeResult CheckAndUpgradeSyncStates(MailboxSession mailboxSession, DeviceIdentity deviceIdentity)
        {
            if (mailboxSession == null)
            {
                throw new ArgumentNullException("mailboxSession");
            }
            SafeHGlobalHandle   safeHGlobalHandle   = SafeHGlobalHandle.InvalidHandle;
            TiFolderSyncUpgrade tiFolderSyncUpgrade = new TiFolderSyncUpgrade();

            tiFolderSyncUpgrade.MailboxSession = mailboxSession;
            MailboxUtility           mailboxUtility           = new MailboxUtility();
            MailboxUtilityDeviceInfo mailboxUtilityDeviceInfo = null;
            MemoryStream             memoryStream             = null;

            try
            {
                mailboxUtility.MailboxSessionForUtility = mailboxSession;
                mailboxUtilityDeviceInfo = mailboxUtility.GetDevice(deviceIdentity);
                if (mailboxUtilityDeviceInfo == null)
                {
                    AirSyncDiagnostics.TraceDebug <DeviceIdentity>(ExTraceGlobals.TiUpgradeTracer, null, "Failed to retrieve device info for: {0}", deviceIdentity);
                    return(SyncStateUpgradeResult.NoTiSyncState);
                }
                AirSyncDiagnostics.TraceDebug <DeviceIdentity>(ExTraceGlobals.TiUpgradeTracer, null, "Starting sync state upgrade for device: {0}", deviceIdentity);
                safeHGlobalHandle = NativeMethods.AllocHGlobal(Marshal.SizeOf(typeof(FolderInfo)));
                StoreObjectId storeObjectId = null;
                storeObjectId = mailboxUtilityDeviceInfo.StoreObjectId;
                HashSet <string> folderList             = mailboxUtilityDeviceInfo.FolderList;
                FolderInfo       folderInfo             = default(FolderInfo);
                bool             containsFoldersyncFile = false;
                memoryStream = mailboxUtility.GetSyncState(storeObjectId, "FolderSyncFile");
                if (memoryStream != null)
                {
                    using (SafeHGlobalHandle safeHGlobalHandle2 = NativeMethods.AllocHGlobal((int)memoryStream.Length))
                    {
                        Marshal.Copy(memoryStream.GetBuffer(), 0, safeHGlobalHandle2.DangerousGetHandle(), (int)memoryStream.Length);
                        int num = SyncStateUpgrader.Foldersync_upgrade(safeHGlobalHandle2, (uint)memoryStream.Length, safeHGlobalHandle);
                        if (num != 0)
                        {
                            throw new AirSyncPermanentException(false);
                        }
                    }
                    folderInfo             = (FolderInfo)Marshal.PtrToStructure(safeHGlobalHandle.DangerousGetHandle(), typeof(FolderInfo));
                    containsFoldersyncFile = true;
                    MailboxUtility.ReclaimStream(memoryStream);
                    memoryStream = null;
                }
                Dictionary <string, StoreObjectType> dictionary2;
                Dictionary <string, StoreObjectId>   dictionary = SyncStateUpgrader.UpgradeFolderSyncHierarchySyncState(tiFolderSyncUpgrade, containsFoldersyncFile, folderInfo, deviceIdentity, out dictionary2);
                if (dictionary == null)
                {
                    mailboxUtility.DeleteFolder(mailboxUtilityDeviceInfo.StoreObjectId, true);
                }
                else
                {
                    SyncStateUpgradeHelper syncStateUpgradeHelper = new SyncStateUpgradeHelper(mailboxSession, tiFolderSyncUpgrade.SyncStateStorage);
                    foreach (string key in dictionary2.Keys)
                    {
                        StoreObjectType storeObjectType = dictionary2[key];
                        if (storeObjectType != StoreObjectType.Folder && storeObjectType != StoreObjectType.ContactsFolder && storeObjectType != StoreObjectType.CalendarFolder && storeObjectType != StoreObjectType.TasksFolder)
                        {
                            AirSyncDiagnostics.TraceDebug <StoreObjectType>(ExTraceGlobals.TiUpgradeTracer, null, "Removing unknown Ti folder of type {0}", storeObjectType);
                            dictionary.Remove(key);
                        }
                    }
                    if (!syncStateUpgradeHelper.UpgradeSyncState(dictionary, dictionary2, folderList, mailboxUtility, storeObjectId))
                    {
                        AirSyncDiagnostics.TraceDebug <string>(ExTraceGlobals.TiUpgradeTracer, null, "Failed to upgrade folders for {0}", mailboxUtilityDeviceInfo.DisplayName);
                        mailboxUtility.DeleteFolder(mailboxUtilityDeviceInfo.StoreObjectId, true);
                        return(SyncStateUpgradeResult.UpgradeFailed);
                    }
                    tiFolderSyncUpgrade.UpdateLastFolderId(syncStateUpgradeHelper.MaxFolderSeen);
                }
                AirSyncDiagnostics.FaultInjectionTracer.TraceTest(3236310333U);
            }
            catch (Exception arg)
            {
                if (mailboxUtilityDeviceInfo != null)
                {
                    mailboxUtility.DeleteSyncStateStorage(new DeviceIdentity(mailboxUtilityDeviceInfo.DisplayName, mailboxUtilityDeviceInfo.ParentDisplayName, "AirSync"));
                }
                AirSyncDiagnostics.TraceDebug <DeviceIdentity, Exception>(ExTraceGlobals.TiUpgradeTracer, null, "Sync state upgrade failed for device: {0}\r\nException:\r\n{1}", deviceIdentity, arg);
                throw;
            }
            finally
            {
                if (memoryStream != null)
                {
                    MailboxUtility.ReclaimStream(memoryStream);
                    memoryStream = null;
                }
                if (mailboxUtilityDeviceInfo != null)
                {
                    mailboxUtility.DeleteFolder(mailboxUtilityDeviceInfo.StoreObjectId, true);
                }
                if (tiFolderSyncUpgrade != null)
                {
                    tiFolderSyncUpgrade.Close();
                    tiFolderSyncUpgrade = null;
                }
                safeHGlobalHandle.Close();
            }
            AirSyncDiagnostics.TraceDebug <DeviceIdentity>(ExTraceGlobals.TiUpgradeTracer, null, "Finished sync state upgrade for device: {0}", deviceIdentity);
            return(SyncStateUpgradeResult.UpgradeComplete);
        }
예제 #22
0
        public static StoreObjectIdentifier?Create([NotNull] IReadOnlyEntityType entityType, StoreObjectType type)
        {
            Check.NotNull(entityType, nameof(entityType));

            switch (type)
            {
            case StoreObjectType.Table:
                var tableName = entityType.GetTableName();
                return(tableName == null ? (StoreObjectIdentifier?)null : Table(tableName, entityType.GetSchema()));

            case StoreObjectType.View:
                var viewName = entityType.GetViewName();
                return(viewName == null ? (StoreObjectIdentifier?)null : View(viewName, entityType.GetViewSchema()));

            case StoreObjectType.SqlQuery:
                var query = entityType.GetSqlQuery();
                return(query == null ? (StoreObjectIdentifier?)null : SqlQuery(entityType));

            case StoreObjectType.Function:
                var functionName = entityType.GetFunctionName();
                return(functionName == null ? (StoreObjectIdentifier?)null : DbFunction(functionName));

            default:
                return(null);
            }
        }
 /// <summary>
 /// Initializes a new instance of the StoreObjectEntryID class.
 /// </summary>
 /// <param name="objType">Type of Store object.</param>
 public StoreObjectEntryID(StoreObjectType objType)
 {
     this.objectType = objType;
 }
예제 #24
0
        private bool CopyAndUpgradeCommon(CommonInfo commonInfo, StoreObjectId storeId, string parentServerId, StoreObjectType type, SafeHGlobalHandle pciInfo)
        {
            Dictionary <string, string> dictionary = null;
            List <TagNode> list = null;
            Dictionary <string, CommonNode> dictionary2 = new Dictionary <string, CommonNode>((int)commonInfo.NumCommonNodes);
            string        text          = null;
            long          num           = 1L;
            TiSyncUpgrade tiSyncUpgrade = new TiSyncUpgrade(parentServerId, this.mailboxSession, this.syncStateStorage);

            try
            {
                dictionary = new Dictionary <string, string>((int)commonInfo.NumMapping);
                if (commonInfo.NumMapping > 0U)
                {
                    MappingNodeStruct mappingNodeStruct = (MappingNodeStruct)Marshal.PtrToStructure(commonInfo.Mappingnodes, typeof(MappingNodeStruct));
                    int num2 = mappingNodeStruct.ShortId.LastIndexOf(':');
                    if (num2 != -1)
                    {
                        text = mappingNodeStruct.ShortId.Substring(0, num2);
                        uint num3;
                        if (uint.TryParse(text, out num3))
                        {
                            this.maxFolderSeen = ((this.maxFolderSeen > (int)num3) ? this.maxFolderSeen : ((int)num3));
                        }
                        else
                        {
                            this.needsParentId.Add(tiSyncUpgrade);
                        }
                    }
                    else
                    {
                        this.needsParentId.Add(tiSyncUpgrade);
                    }
                    for (uint num4 = 0U; num4 < commonInfo.NumMapping; num4 += 1U)
                    {
                        int    num5 = mappingNodeStruct.LongId.LastIndexOf(':');
                        string key;
                        if (num5 != -1)
                        {
                            key = mappingNodeStruct.LongId.Substring(num5 + 1);
                        }
                        else
                        {
                            key = mappingNodeStruct.LongId;
                        }
                        dictionary.Add(key, mappingNodeStruct.ShortId);
                        num2 = mappingNodeStruct.ShortId.LastIndexOf(':');
                        if (num2 != -1)
                        {
                            string s = mappingNodeStruct.ShortId.Substring(num2 + 1);
                            uint   num6;
                            if (uint.TryParse(s, out num6))
                            {
                                num = ((num > (long)((ulong)num6)) ? num : ((long)((ulong)num6)));
                            }
                        }
                        if (num4 < commonInfo.NumMapping - 1U)
                        {
                            mappingNodeStruct = (MappingNodeStruct)Marshal.PtrToStructure(mappingNodeStruct.Next, typeof(MappingNodeStruct));
                        }
                    }
                }
                else
                {
                    this.needsParentId.Add(tiSyncUpgrade);
                }
                CommonNodeStruct commonNodeStruct;
                if (commonInfo.NumCommonNodes > 0U)
                {
                    commonNodeStruct = (CommonNodeStruct)Marshal.PtrToStructure(commonInfo.Nodes, typeof(CommonNodeStruct));
                }
                else
                {
                    commonNodeStruct = default(CommonNodeStruct);
                }
                for (uint num7 = 0U; num7 < commonInfo.NumCommonNodes; num7 += 1U)
                {
                    if (commonNodeStruct.SentToClient == 1)
                    {
                        if (!dictionary.ContainsKey(commonNodeStruct.ServerId))
                        {
                            dictionary.Add(commonNodeStruct.ServerId, commonNodeStruct.ServerId);
                        }
                        ExDateTime endTimeIn = (commonNodeStruct.EndTime == 0L) ? ExDateTime.MinValue : ExDateTime.FromFileTimeUtc(commonNodeStruct.EndTime);
                        dictionary2.Add(commonNodeStruct.ServerId, new CommonNode(commonNodeStruct.ServerId, commonNodeStruct.VersionId, commonNodeStruct.SentToClient, commonNodeStruct.IsEmail, commonNodeStruct.Read, commonNodeStruct.IsCalendar, endTimeIn));
                    }
                    if (num7 < commonInfo.NumCommonNodes - 1U)
                    {
                        commonNodeStruct = (CommonNodeStruct)Marshal.PtrToStructure(commonNodeStruct.Next, typeof(CommonNodeStruct));
                    }
                }
                list = new List <TagNode>((int)commonInfo.NumSupportedTags);
                TagNodeStruct tagNodeStruct = default(TagNodeStruct);
                if (commonInfo.NumSupportedTags > 0U)
                {
                    tagNodeStruct = (TagNodeStruct)Marshal.PtrToStructure(commonInfo.Tagnodes, typeof(TagNodeStruct));
                }
                for (uint num8 = 0U; num8 < commonInfo.NumSupportedTags; num8 += 1U)
                {
                    list.Add(new TagNode(tagNodeStruct.NameSpace, tagNodeStruct.Tag));
                    if (num8 < commonInfo.NumSupportedTags - 1U)
                    {
                        tagNodeStruct = (TagNodeStruct)Marshal.PtrToStructure(tagNodeStruct.Next, typeof(TagNodeStruct));
                    }
                }
            }
            finally
            {
                SyncStateUpgradeHelper.Commoninfo_cleanup(pciInfo);
            }
            uint version;

            switch (commonInfo.Version)
            {
            case 65542U:
                version = 20U;
                break;

            case 65543U:
                version = 21U;
                break;

            case 65544U:
                version = 25U;
                break;

            default:
                version = 10U;
                break;
            }
            return(tiSyncUpgrade.Upgrade(storeId, dictionary2, dictionary, list, type, new string(commonInfo.SyncKey), text, (int)num, version));
        }
        // Token: 0x06002FC9 RID: 12233 RVA: 0x0011611C File Offset: 0x0011431C
        internal static bool SetBody(Item item, string body, Markup markup, StoreObjectType storeObjectType, UserContext userContext)
        {
            bool flag = false;

            switch (markup)
            {
            case Markup.Html:
            {
                string                 targetCharsetName;
                BodyCharsetFlags       bodyCharsetOptions     = BodyConversionUtilities.GetBodyCharsetOptions(userContext, out targetCharsetName);
                BodyFormat             targetFormat           = (storeObjectType != StoreObjectType.CalendarItem && storeObjectType != StoreObjectType.MeetingMessage) ? BodyFormat.TextHtml : BodyFormat.ApplicationRtf;
                BodyWriteConfiguration bodyWriteConfiguration = new BodyWriteConfiguration(BodyFormat.TextHtml);
                bodyWriteConfiguration.SetTargetFormat(targetFormat, targetCharsetName, bodyCharsetOptions);
                OwaSafeHtmlInboundCallbacks owaSafeHtmlInboundCallbacks = null;
                owaSafeHtmlInboundCallbacks = new OwaSafeHtmlInboundCallbacks(item, userContext);
                bodyWriteConfiguration.SetHtmlOptions(HtmlStreamingFlags.None, owaSafeHtmlInboundCallbacks);
                try
                {
                    Body body2 = item.Body;
                    if (userContext.IsIrmEnabled && Utilities.IsIrmDecrypted(item))
                    {
                        body2 = ((RightsManagedMessageItem)item).ProtectedBody;
                    }
                    using (TextWriter textWriter = body2.OpenTextWriter(bodyWriteConfiguration))
                    {
                        textWriter.Write(body);
                    }
                }
                catch (InvalidCharsetException innerException)
                {
                    throw new OwaEventHandlerException(LocalizedStrings.GetNonEncoded(1825027020), LocalizedStrings.GetNonEncoded(1825027020), innerException);
                }
                catch (TextConvertersException innerException2)
                {
                    throw new OwaEventHandlerException(LocalizedStrings.GetNonEncoded(1825027020), LocalizedStrings.GetNonEncoded(1825027020), innerException2);
                }
                Utilities.MakeModifiedCalendarItemOccurrence(item);
                bool flag2 = false;
                if (owaSafeHtmlInboundCallbacks != null)
                {
                    flag2 = owaSafeHtmlInboundCallbacks.AttachmentNeedsSave();
                }
                if (flag2 && !Utilities.IsClearSigned(item))
                {
                    flag = AttachmentUtility.ApplyAttachmentsUpdates(item, owaSafeHtmlInboundCallbacks);
                    item.Load();
                }
                break;
            }

            case Markup.PlainText:
                ItemUtility.SetItemBody(item, BodyFormat.TextPlain, body);
                flag = AttachmentUtility.PromoteInlineAttachments(item);
                if (flag)
                {
                    item.Load();
                }
                break;
            }
            return(flag);
        }
예제 #26
0
        /// <summary>
        ///     This is an internal API that supports the Entity Framework Core infrastructure and not subject to
        ///     the same compatibility standards as public APIs. It may be changed or removed without notice in
        ///     any release. You should only use it directly in your code with extreme caution and knowing that
        ///     doing so can result in application failures when updating to a new Entity Framework Core release.
        /// </summary>
        public static IEnumerable <IForeignKey> FindRowInternalForeignKeys(
            [NotNull] this IEntityType entityType, [CanBeNull] string name, [CanBeNull] string schema, StoreObjectType objectType)
        {
            var primaryKey = entityType.FindPrimaryKey();

            if (primaryKey == null ||
                name == null)
            {
                yield break;
            }

            foreach (var fk in entityType.GetForeignKeys())
            {
                var principalEntityType = fk.PrincipalEntityType;
                if (!fk.PrincipalKey.IsPrimaryKey() ||
                    principalEntityType == fk.DeclaringEntityType ||
                    !fk.IsUnique
#pragma warning disable EF1001 // Internal EF Core API usage.
                    || !PropertyListComparer.Instance.Equals(fk.Properties, primaryKey.Properties))
#pragma warning restore EF1001 // Internal EF Core API usage.
                {
                    continue;
                }

                switch (objectType)
                {
                case StoreObjectType.Table:
                    if (name == principalEntityType.GetTableName() &&
                        schema == principalEntityType.GetSchema())
                    {
                        yield return(fk);
                    }
                    break;

                case StoreObjectType.View:
                    if (name == principalEntityType.GetViewName() &&
                        schema == principalEntityType.GetViewSchema())
                    {
                        yield return(fk);
                    }
                    break;

                default:
                    throw new NotImplementedException(objectType.ToString());
                }
            }
        }
        private void ProcessMessageRequest(MessageAction action)
        {
            bool        flag        = false;
            MessageItem messageItem = null;
            bool        flag2       = base.IsParameterSet("Id");
            bool        flag3       = false;

            RecipientInfoAC[] array = (RecipientInfoAC[])base.GetParameter("Recips");
            if (array != null && array.Length != 0)
            {
                AutoCompleteCache.UpdateAutoCompleteCacheFromRecipientInfoList(array, base.OwaContext.UserContext);
            }
            try
            {
                messageItem = this.GetMessageItem(flag2);
                base.SaveHideMailTipsByDefault();
                switch (action)
                {
                case MessageAction.Send:
                case MessageAction.Save:
                {
                    StoreObjectType storeObjectType = StoreObjectType.Message;
                    if (ObjectClass.IsMeetingRequest(messageItem.ClassName) || ObjectClass.IsMeetingCancellation(messageItem.ClassName) || ObjectClass.IsMeetingResponse(messageItem.ClassName))
                    {
                        storeObjectType = StoreObjectType.MeetingMessage;
                    }
                    flag = base.UpdateMessage(messageItem, storeObjectType);
                    break;
                }

                case MessageAction.SendMime:
                case MessageAction.SaveMime:
                    this.ImportMessageMime(messageItem);
                    flag3 = (base.IsParameterSet("SavToSnt") && !(bool)base.GetParameter("SavToSnt"));
                    if (action == MessageAction.SendMime && base.IsParameterSet("Encrypted") && (bool)base.GetParameter("Encrypted") && base.IsParameterSet("DavSubmitData"))
                    {
                        messageItem[MessageItemSchema.DavSubmitData] = (string)base.GetParameter("DavSubmitData");
                    }
                    else
                    {
                        base.UpdateRecipients(messageItem);
                    }
                    break;
                }
                if (action == MessageAction.Save || action == MessageAction.SaveMime)
                {
                    ExTraceGlobals.MailTracer.TraceDebug((long)this.GetHashCode(), "Saving message");
                    Utilities.SaveItem(messageItem, flag2);
                    base.WriteIdAndChangeKey(messageItem, flag2);
                    if (!flag2 && ExTraceGlobals.MailDataTracer.IsTraceEnabled(TraceType.DebugTrace))
                    {
                        ExTraceGlobals.MailDataTracer.TraceDebug <string>((long)this.GetHashCode(), "EditMessageEventHandler.ProcessMessageRequest - New message ID is '{0}'", messageItem.Id.ObjectId.ToBase64String());
                    }
                }
                else if (action == MessageAction.Send || action == MessageAction.SendMime)
                {
                    if (flag)
                    {
                        throw new OwaEventHandlerException("Unresolved recipients", LocalizedStrings.GetNonEncoded(2063734279));
                    }
                    RightsManagedMessageItem rightsManagedMessageItem = messageItem as RightsManagedMessageItem;
                    bool flag4 = rightsManagedMessageItem != null && rightsManagedMessageItem.Restriction != null;
                    if (messageItem.Recipients.Count == 0 && (action == MessageAction.Send || action != MessageAction.SendMime || !base.IsParameterSet("Encrypted") || !(bool)base.GetParameter("Encrypted")))
                    {
                        throw new OwaEventHandlerException("No recipients", LocalizedStrings.GetNonEncoded(1878192149));
                    }
                    if (Utilities.RecipientsOnlyHaveEmptyPDL <Recipient>(base.UserContext, messageItem.Recipients))
                    {
                        base.RenderPartialFailure(1389137820);
                    }
                    else
                    {
                        ExTraceGlobals.MailTracer.TraceDebug((long)this.GetHashCode(), "Sending message");
                        try
                        {
                            if (flag3)
                            {
                                messageItem.SendWithoutSavingMessage();
                            }
                            else
                            {
                                messageItem.Send();
                            }
                            if (null != base.FromParticipant)
                            {
                                Participant v = new Participant(base.UserContext.ExchangePrincipal);
                                if (!base.FromParticipant.AreAddressesEqual(v))
                                {
                                    RecipientInfoCacheEntry fromRecipientEntry = base.GetFromRecipientEntry(base.FromParticipant.EmailAddress);
                                    if (fromRecipientEntry != null)
                                    {
                                        RecipientCache recipientCache = SendFromCache.TryGetCache(base.UserContext);
                                        if (recipientCache != null)
                                        {
                                            recipientCache.AddEntry(fromRecipientEntry);
                                        }
                                    }
                                }
                            }
                        }
                        catch (Exception ex)
                        {
                            ExTraceGlobals.MailDataTracer.TraceError <string>((long)this.GetHashCode(), "EditMessageEventHandler.ProcessMessageRequestmessage - Exception: {0}", ex.Message);
                            if (Utilities.ShouldSendChangeKeyForException(ex))
                            {
                                ExTraceGlobals.MailDataTracer.TraceDebug <string>((long)this.GetHashCode(), "EditMessageEventHandler.ProcessMessageRequestmessage attempt to send change key on exception: {0}", ex.Message);
                                base.SaveIdAndChangeKeyInCustomErrorInfo(messageItem);
                            }
                            throw;
                        }
                        if (Globals.ArePerfCountersEnabled)
                        {
                            OwaSingleCounters.MessagesSent.Increment();
                            if (flag4)
                            {
                                OwaSingleCounters.IRMMessagesSent.Increment();
                            }
                        }
                    }
                }
            }
            finally
            {
                if (messageItem != null)
                {
                    messageItem.Dispose();
                    messageItem = null;
                }
            }
        }
 /// <summary>
 /// Get store object EntryID bytes array.
 /// </summary>
 /// <param name="storeObjectType">Identify the store object is a mailbox or a public folder.</param>
 /// <param name="serverShortName">Server short name string.</param>
 /// <param name="mailboxDN">Mailbox DN string.</param>
 /// <returns>Store object EntryID bytes array.</returns>
 public byte[] GetStoreObjectEntryID(StoreObjectType storeObjectType, string serverShortName, string mailboxDN)
 {
     StoreObjectEntryID objectEntryId = new StoreObjectEntryID(storeObjectType)
     {
         ServerShortname = serverShortName,
         MailBoxDN = mailboxDN
     };
     return objectEntryId.Serialize();
 }
 /// <summary>
 /// Initializes a new instance of the StoreObjectEntryID class.
 /// </summary>
 /// <param name="objType">Type of Store object.</param>
 public StoreObjectEntryID(StoreObjectType objType)
 {
     this.objectType = objType;
 }
예제 #30
0
 private PolicyAllowedMemberRights(StoreObjectType storeObjectType, SharingPolicyAction action, MemberRights allowedRights)
 {
     this.storeObjectType = storeObjectType;
     this.action          = action;
     this.allowedRights   = allowedRights;
 }
 /// <inheritdoc />
 public override string ToString() => StoreObjectType.ToString() + " " + DisplayName();
예제 #32
0
        // Token: 0x0600184D RID: 6221 RVA: 0x0008E8B4 File Offset: 0x0008CAB4
        private static bool ParseSupportedTags(int version, List <TagNode> tags, StoreObjectType type)
        {
            if (tags.Count == 0 || version < 21)
            {
                return(true);
            }
            Dictionary <string, bool> dictionary = new Dictionary <string, bool>(tags.Count);

            foreach (TagNode tagNode in tags)
            {
                if (tagNode.NameSpace == 2)
                {
                    tagNode.NameSpace = 1;
                }
                else
                {
                    if (tagNode.NameSpace != 3)
                    {
                        return(false);
                    }
                    tagNode.NameSpace = 4;
                }
                int    tag  = (int)tagNode.NameSpace << 8 | (int)(tagNode.Tag + 4);
                string name = TiSyncUpgrade.wbxmlSchema.GetName(tag);
                dictionary.Add(name, false);
            }
            IAirSyncVersionFactory airSyncVersionFactory = AirSyncProtocolVersionParserBuilder.FromVersion(version);
            AirSyncSchemaState     airSyncSchemaState;

            switch (type)
            {
            case StoreObjectType.Folder:
                airSyncSchemaState = airSyncVersionFactory.CreateEmailSchema(null);
                break;

            case StoreObjectType.CalendarFolder:
                airSyncSchemaState = airSyncVersionFactory.CreateCalendarSchema();
                break;

            case StoreObjectType.ContactsFolder:
                airSyncSchemaState = airSyncVersionFactory.CreateContactsSchema();
                break;

            case StoreObjectType.TasksFolder:
                airSyncSchemaState = airSyncVersionFactory.CreateTasksSchema();
                break;

            default:
                return(false);
            }
            AirSyncSetToDefaultStrategy airSyncSetToDefaultStrategy = new AirSyncSetToDefaultStrategy(dictionary);
            AirSyncDataObject           airSyncDataObject           = airSyncSchemaState.GetAirSyncDataObject(new Hashtable(), airSyncSetToDefaultStrategy);

            try
            {
                airSyncSetToDefaultStrategy.Validate(airSyncDataObject);
            }
            catch (ConversionException)
            {
                return(false);
            }
            return(true);
        }
        private static IProperty FindSharedObjectRootPrimaryKeyProperty([NotNull] IProperty property, StoreObjectType storeObjectType)
        {
            Check.NotNull(property, nameof(property));

            var principalProperty = property;
            HashSet <IEntityType> visitedTypes = null;

            while (true)
            {
                var linkingRelationship = principalProperty.FindSharedObjectLink(storeObjectType);
                if (linkingRelationship == null)
                {
                    break;
                }

                if (visitedTypes == null)
                {
                    visitedTypes = new HashSet <IEntityType> {
                        linkingRelationship.DeclaringEntityType
                    };
                }

                if (!visitedTypes.Add(linkingRelationship.PrincipalEntityType))
                {
                    return(null);
                }

                principalProperty = linkingRelationship.PrincipalKey.Properties[linkingRelationship.Properties.IndexOf(principalProperty)];
            }

            return(principalProperty == property ? null : principalProperty);
        }
예제 #34
0
        // Token: 0x0600184C RID: 6220 RVA: 0x0008E670 File Offset: 0x0008C870
        public bool Upgrade(StoreObjectId storeId, Dictionary <string, CommonNode> items, Dictionary <string, string> mapping, List <TagNode> tags, StoreObjectType type, string synckeyIn, string shortParentId, int nextShortId, uint version)
        {
            if (storeId == null)
            {
                AirSyncDiagnostics.TraceDebug(ExTraceGlobals.TiUpgradeTracer, this, "Input to TiSyncUpgrade.Upgrade is null: field storeId");
                throw new ArgumentNullException("storeId");
            }
            if (items == null)
            {
                AirSyncDiagnostics.TraceDebug(ExTraceGlobals.TiUpgradeTracer, this, "Input to TiSyncUpgrade.Upgrade is null: field items");
                throw new ArgumentNullException("items");
            }
            if (mapping == null)
            {
                AirSyncDiagnostics.TraceDebug(ExTraceGlobals.TiUpgradeTracer, this, "Input to TiSyncUpgrade.Upgrade is null: field mapping");
                throw new ArgumentNullException("mapping");
            }
            if (tags == null)
            {
                AirSyncDiagnostics.TraceDebug(ExTraceGlobals.TiUpgradeTracer, this, "Input to TiSyncUpgrade.Upgrade is null: field tags");
                throw new ArgumentNullException("tags");
            }
            if (synckeyIn == null)
            {
                AirSyncDiagnostics.TraceDebug(ExTraceGlobals.TiUpgradeTracer, this, "Input to TiSyncUpgrade.Upgrade is null: field synckeyIn");
                throw new ArgumentNullException("synckeyIn");
            }
            if (shortParentId == null && mapping.Count > 0)
            {
                AirSyncDiagnostics.TraceDebug(ExTraceGlobals.TiUpgradeTracer, this, "Input to TiSyncUpgrade.Upgrade is null: field shortParentId, and mapping.Count > 0");
                throw new ArgumentNullException("shortParentId");
            }
            Dictionary <StoreObjectId, string> dictionary = new Dictionary <StoreObjectId, string>();

            this.storeId = storeId;
            try
            {
                this.LoadE12SyncState(storeId, shortParentId, nextShortId);
                Folder sourceFolder = null;
                try
                {
                    sourceFolder = Folder.Bind(this.mailboxSession, storeId, null);
                }
                catch (ObjectNotFoundException)
                {
                    return(false);
                }
                if (!TiSyncUpgrade.ParseSupportedTags((int)version, tags, type))
                {
                    return(false);
                }
                Dictionary <string, CommonNode> items2 = new Dictionary <string, CommonNode>(items);
                ItemSyncUpgrade itemSyncUpgrade        = new ItemSyncUpgrade();
                dictionary = itemSyncUpgrade.Upgrade(this.syncState, items, sourceFolder, this.mailboxSession);
                if (dictionary == null)
                {
                    return(false);
                }
                DateTimeCustomSyncFilter dateTimeFilter = new DateTimeCustomSyncFilter(this.syncState);
                this.UpdateFilter(dictionary, dateTimeFilter, items2);
                this.UpdateMapping(dictionary, mapping);
                this.syncState[CustomStateDatumType.AirSyncProtocolVersion] = new Int32Data((int)version);
                ((ItemIdMapping)this.syncState[CustomStateDatumType.IdMapping]).CommitChanges();
                string text = synckeyIn;
                int    num  = text.LastIndexOf("}");
                if (num >= 0)
                {
                    text = text.Substring(num + 1, text.Length - num - 1);
                }
                uint data = (uint)int.Parse(text, CultureInfo.InvariantCulture);
                this.syncState[CustomStateDatumType.SyncKey] = new UInt32Data(data);
                this.syncState.Commit();
            }
            finally
            {
                if (this.syncState != null)
                {
                    this.syncState.Dispose();
                }
            }
            return(true);
        }
        // Token: 0x06002DB9 RID: 11705 RVA: 0x00102FA4 File Offset: 0x001011A4
        private void NonEditResponseInternal(bool sendResponse)
        {
            ResponseType     responseType     = (ResponseType)base.GetParameter("Rsp");
            StoreObjectType  storeObjectType  = (StoreObjectType)base.GetParameter("ItemType");
            MeetingRequest   meetingRequest   = null;
            CalendarItemBase calendarItemBase = null;

            try
            {
                StoreObjectType storeObjectType2 = storeObjectType;
                if (storeObjectType2 != StoreObjectType.MeetingRequest)
                {
                    if (storeObjectType2 == StoreObjectType.CalendarItem)
                    {
                        calendarItemBase = base.GetRequestItem <CalendarItemBase>(new PropertyDefinition[0]);
                        MeetingUtilities.ThrowIfMeetingResponseInvalid(calendarItemBase);
                    }
                }
                else
                {
                    this.properties = new PropertyDefinition[]
                    {
                        MeetingMessageSchema.CalendarProcessed,
                        StoreObjectSchema.ParentItemId
                    };
                    meetingRequest   = this.GetMeetingRequest(this.properties);
                    calendarItemBase = MeetingUtilities.UpdateCalendarItem(meetingRequest);
                    if (calendarItemBase == null)
                    {
                        throw new OwaInvalidRequestException(string.Format("calendarItem associated with meetingRequest with Id {0} is null.", base.GetParameter("Id")));
                    }
                }
                this.UpdateItem(calendarItemBase);
                Utilities.SaveItem(calendarItemBase);
                calendarItemBase.Load();
                MeetingUtilities.NonEditResponse(responseType, calendarItemBase, sendResponse, null);
                calendarItemBase.Load();
                if (meetingRequest != null)
                {
                    this.UpdateItem(meetingRequest);
                    Utilities.SaveItem(meetingRequest);
                    MeetingUtilities.DeleteMeetingRequestAfterResponse(meetingRequest);
                }
                if (storeObjectType == StoreObjectType.CalendarItem)
                {
                    this.Writer.Write("<div id=nid>");
                    this.Writer.Write(OwaStoreObjectId.CreateFromStoreObject(calendarItemBase).ToBase64String());
                    this.Writer.Write("</div>");
                }
            }
            finally
            {
                if (meetingRequest != null)
                {
                    meetingRequest.Dispose();
                    meetingRequest = null;
                }
                if (calendarItemBase != null)
                {
                    calendarItemBase.Dispose();
                    calendarItemBase = null;
                }
            }
        }
예제 #36
0
        public bool Rename(StoreObjectId destinationId, string folderName)
        {
            if (destinationId == null)
            {
                throw new ArgumentNullException("destinationId");
            }
            if (folderName == null)
            {
                throw new ArgumentNullException("folderName");
            }
            folderName = folderName.Trim();
            if (folderName.Length == 0)
            {
                this.owaContext[OwaContextProperty.InfobarMessage] = InfobarMessage.CreateLocalized(615663605, InfobarMessageType.Error);
                return(false);
            }
            if (folderName.Length > 256)
            {
                this.owaContext[OwaContextProperty.InfobarMessage] = InfobarMessage.CreateLocalized(-1198351885, InfobarMessageType.Error);
                return(false);
            }
            StoreObjectType  objectType = destinationId.ObjectType;
            FolderSaveResult folderSaveResult;

            try
            {
                Folder folder2;
                Folder folder = folder2 = Folder.Bind(this.owaContext.UserContext.MailboxSession, destinationId);
                try
                {
                    folder.DisplayName = folderName;
                    folderSaveResult   = folder.Save();
                }
                finally
                {
                    if (folder2 != null)
                    {
                        ((IDisposable)folder2).Dispose();
                    }
                }
            }
            catch (ObjectNotFoundException)
            {
                this.owaContext[OwaContextProperty.InfobarMessage] = InfobarMessage.CreateLocalized(2106120183, InfobarMessageType.Error);
                return(false);
            }
            catch (ObjectValidationException)
            {
                this.owaContext[OwaContextProperty.InfobarMessage] = InfobarMessage.CreateLocalized(2103130667, InfobarMessageType.Error);
                return(false);
            }
            catch (InvalidOperationException)
            {
                this.owaContext[OwaContextProperty.InfobarMessage] = InfobarMessage.CreateLocalized(2103130667, InfobarMessageType.Error);
                return(false);
            }
            catch (StoragePermanentException e)
            {
                InfobarMessage.PutExceptionInfoIntoContextInfobarMessage(e, this.owaContext);
                return(false);
            }
            catch (StorageTransientException e2)
            {
                InfobarMessage.PutExceptionInfoIntoContextInfobarMessage(e2, this.owaContext);
                return(false);
            }
            if (folderSaveResult.OperationResult != OperationResult.Succeeded)
            {
                if (folderSaveResult.PropertyErrors.Length > 0)
                {
                    switch (folderSaveResult.PropertyErrors[0].PropertyErrorCode)
                    {
                    case PropertyErrorCode.MapiCallFailed:
                        this.owaContext[OwaContextProperty.InfobarMessage] = InfobarMessage.CreateLocalized(2103130667, InfobarMessageType.Error);
                        return(false);

                    case PropertyErrorCode.FolderNameConflict:
                        this.owaContext[OwaContextProperty.InfobarMessage] = InfobarMessage.CreateLocalized(1602494619, InfobarMessageType.Error);
                        return(false);
                    }
                }
                this.owaContext[OwaContextProperty.InfobarMessage] = InfobarMessage.CreateLocalized(2103130667, InfobarMessageType.Error);
                return(false);
            }
            this.owaContext[OwaContextProperty.InfobarMessage] = InfobarMessage.CreateText(string.Format(LocalizedStrings.GetNonEncoded(-889243793), folderName), InfobarMessageType.Informational);
            return(true);
        }
        /// <summary>
        /// Verify the FolderEntryID structure.
        /// </summary>
        /// <param name="folderEntryID">The FolderEntryID to be verified.</param>
        /// <param name="storeObjectType">Store Object Type.</param>
        private void VerifyFolderEntryID(FolderEntryID folderEntryID, StoreObjectType storeObjectType)
        {
            // Add the debug information.
            Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXCDATA_R2225");

            // Verify MS-OXCDATA requirement: MS-OXCDATA_R2225.
            Site.CaptureRequirementIfAreEqual<int>(
                0,
                BitConverter.ToInt32(folderEntryID.Flag, 0),
                "MS-OXCDATA",
                2225,
                @"[In Folder EntryID Structure] Flags (4 bytes): This value MUST be set to 0x00000000.");

            // Add the debug information.
            Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXCDATA_R2229");

            // Verify MS-OXCDATA requirement: MS-OXCDATA_R2229.
            Site.CaptureRequirementIfAreEqual<int>(
                16,
                folderEntryID.DataBaseGUID.Length,
                "MS-OXCDATA",
                2229,
                @"[In Folder EntryID Structure] DatabaseGuid (16 bytes): A GUID associated with the Store object and corresponding to the ReplicaId field of the FID structure.");

            // Add the debug information.
            Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXCDATA_R2230");

            // Verify MS-OXCDATA requirement: MS-OXCDATA_R2230.
            Site.CaptureRequirementIfAreEqual<int>(
                6,
                folderEntryID.GlobalCounter.Length,
                "MS-OXCDATA",
                2230,
                @"[In Folder EntryID Structure] GlobalCounter (6 bytes): An unsigned integer identifying the folder.");

            // Add the debug information.
            Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXCDATA_R2231");

            // Verify MS-OXCDATA requirement: MS-OXCDATA_R2231.
            Site.CaptureRequirementIfAreEqual<short>(
                0,
               BitConverter.ToInt16(folderEntryID.Pad, 0),
               "MS-OXCDATA",
                2231,
                @"[In Folder EntryID Structure] Pad (2 bytes): This value MUST be set to zero.");

            // Add the debug information.
            Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXORULE_R301");

            // The structure of FolderEId is verified by the requirements MS-OXCDATA_R2225, MS-OXCDATA_R2229, MS-OXCDATA_R2230, and MS-OXCDATA_R2231.
            // Verify MS-OXORULE_R301.
            Site.CaptureRequirement(
                301,
                @"[In OP_MOVE and OP_COPY ActionData Structure] [Buffer Format for Standard Rules] FolderEID (variable): A structure that identifies the destination folder.");

            if (storeObjectType == StoreObjectType.Mailbox)
            {
                // Add the debug information.
                Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXCDATA_R2226");

                // Verify MS-OXCDATA requirement: MS-OXCDATA_R2226.
                Site.CaptureRequirementIfAreEqual<byte[]>(
                    this.mailboxGUID,
                    folderEntryID.ProviderUID,
                    "MS-OXCDATA",
                    2226,
                    @"[In Folder EntryID Structure] Provider UID (16 bytes): For a folder in a private mailbox, this value MUST be set to value of the MailboxGuid field from the RopLogon ROP response buffer ([MS-OXCROPS] section 2.2.3.1).");
            }
        }
 internal RightsNotAllowedByPolicyException(RightsNotAllowedRecipient[] rightsNotAllowedRecipients, StoreObjectType storeObjectType, string folderName) : base(ServerStrings.RightsNotAllowedByPolicy(storeObjectType.ToString(), folderName))
 {
     if (rightsNotAllowedRecipients == null)
     {
         throw new ArgumentNullException("rightsNotAllowedRecipients");
     }
     if (rightsNotAllowedRecipients.Length == 0)
     {
         throw new ArgumentException("rightsNotAllowedRecipients");
     }
     this.rightsNotAllowedRecipients = rightsNotAllowedRecipients;
 }
 /// <summary>
 /// Parse the MessageEntryID structure.
 /// </summary>
 /// <param name="s">A stream containing the MessageEntryID structure</param>
 public override void Parse(Stream s)
 {
     base.Parse(s);
     this.Flags = ReadUint();
     byte[] tempProviderUID = ReadBytes(16);
     if (tempProviderUID.ToString() == "%x1A.44.73.90.AA.66.11.CD.9B.C8.00.AA.00.2F.C4.5A")
     {
         this.ProviderUID = tempProviderUID;
     }
     else
     {
         this.ProviderUID = new Guid(tempProviderUID);
     }
     this.MessageType = (StoreObjectType)ReadUshort();
     this.FolderDatabaseGuid = ReadGuid();
     this.FolderGlobalCounter = ReadBytes(6);
     this.Pad_1 = ReadUshort();
     this.MessageDatabaseGuid = ReadGuid();
     this.MessageGlobalCounter = ReadBytes(6);
     this.Pad_2 = ReadUshort();
 }
        /// <summary>
        /// Get folder EntryID bytes array.
        /// </summary>
        /// <param name="storeObjectType">Identify the store object is a mailbox or a public folder.</param>
        /// <param name="objHandle">Logon handle.</param>
        /// <param name="folderid">Folder id value.</param>
        /// <returns>Folder EntryID bytes array.</returns>
        public byte[] GetFolderEntryId(StoreObjectType storeObjectType, uint objHandle, ulong folderid)
        {
            // Get folder longterm id.
            RopLongTermIdFromIdResponse longTermIdFromId = this.GetLongTermId(objHandle, folderid);
            FolderEntryID folderEntryId;
            if (storeObjectType == StoreObjectType.Mailbox)
            {
                folderEntryId = new FolderEntryID(storeObjectType, this.mailboxGUID, longTermIdFromId.LongTermId.DatabaseGuid, longTermIdFromId.LongTermId.GlobalCounter);
            }
            else
            {
                byte[] providerUID = new byte[] { 0x1A, 0x44, 0x73, 0x90, 0xAA, 0x66, 0x11, 0xCD, 0x9B, 0xC8, 0x00, 0xAA, 0x00, 0x2F, 0xC4, 0x5A };
                folderEntryId = new FolderEntryID(storeObjectType, providerUID, longTermIdFromId.LongTermId.DatabaseGuid, longTermIdFromId.LongTermId.GlobalCounter);
            }

            this.VerifyFolderEntryID(folderEntryId, storeObjectType);
            return folderEntryId.Serialize();
        }