Ejemplo n.º 1
0
 private static StoreObjectId CreateStoreObjectIdFromString(string owaStoreObjectIdString, string itemPrefix, int indexOfLastSeparatorChar)
 {
     if (indexOfLastSeparatorChar == itemPrefix.Length)
     {
         throw new OwaInvalidIdFormatException(string.Format("There should be two separators \"{0}\" in the id of the public item. Invalid Id: {1}", ".", owaStoreObjectIdString));
     }
     return(OwaStoreObjectId.CreateStoreObjectId(owaStoreObjectIdString.Substring(itemPrefix.Length + 1, indexOfLastSeparatorChar - itemPrefix.Length - 1)));
 }
        // Token: 0x06002071 RID: 8305 RVA: 0x00078BD8 File Offset: 0x00076DD8
        private static void ConvertLegacyItemIdFormatIfNecessary(SimpleConfiguration <OtherMailboxConfigEntry> otherMailboxConfig, CallContext callContext)
        {
            bool flag = false;

            for (int i = otherMailboxConfig.Entries.Count - 1; i >= 0; i--)
            {
                OtherMailboxConfigEntry otherMailboxConfigEntry = otherMailboxConfig.Entries[i];
                if (!string.IsNullOrEmpty(otherMailboxConfigEntry.InboxFolderOwaStoreObjectId))
                {
                    flag = true;
                    bool flag2 = false;
                    try
                    {
                        OwaStoreObjectId  owaStoreObjectId  = OwaStoreObjectId.CreateFromString(otherMailboxConfigEntry.InboxFolderOwaStoreObjectId);
                        ExchangePrincipal exchangePrincipal = (owaStoreObjectId.MailboxOwnerLegacyDN != null) ? ExchangePrincipal.FromLegacyDN(callContext.SessionCache.GetMailboxIdentityMailboxSession().GetADSessionSettings(), owaStoreObjectId.MailboxOwnerLegacyDN) : callContext.AccessingPrincipal;
                        otherMailboxConfigEntry.PrincipalSMTPAddress        = exchangePrincipal.MailboxInfo.PrimarySmtpAddress.ToString();
                        otherMailboxConfigEntry.InboxFolderOwaStoreObjectId = null;
                        flag2 = true;
                    }
                    catch (OwaInvalidIdFormatException)
                    {
                    }
                    catch (OwaInvalidRequestException)
                    {
                    }
                    catch (ObjectNotFoundException)
                    {
                    }
                    finally
                    {
                        if (!flag2)
                        {
                            otherMailboxConfig.Entries.RemoveAt(i);
                        }
                    }
                }
            }
            if (flag)
            {
                otherMailboxConfig.Save(callContext);
            }
        }
Ejemplo n.º 3
0
        private static string ParseLegacyDnBase64String(string legacyDnBase64String)
        {
            string text = null;

            try
            {
                text = Encoding.UTF8.GetString(Convert.FromBase64String(legacyDnBase64String));
            }
            catch (ArgumentException innerException)
            {
                throw new OwaInvalidIdFormatException(string.Format("Invalid legacyDN. Invalid Id string: {0}", legacyDnBase64String), innerException);
            }
            catch (FormatException innerException2)
            {
                throw new OwaInvalidIdFormatException(string.Format("Invalid legacyDN. Invalid Id string: {0}", legacyDnBase64String), innerException2);
            }
            if (string.IsNullOrEmpty(text) || !OwaStoreObjectId.IsValidLegacyDN(text))
            {
                throw new OwaInvalidIdFormatException(string.Format("Invalid legacy distinguished name: {0}", (text == null) ? "null" : text));
            }
            return(text);
        }
Ejemplo n.º 4
0
 public TargetFolderMRUEntry(OwaStoreObjectId owaStoreObjectIdFolderId)
 {
     this.owaStoreObjectIdFolderId = owaStoreObjectIdFolderId.ToString();
 }
Ejemplo n.º 5
0
        internal static OwaStoreObjectId CreateFromStoreObjectId(StoreObjectId storeObjectId, OwaStoreObjectId relatedStoreObjectId)
        {
            if (storeObjectId == null)
            {
                throw new ArgumentNullException("storeObjectId");
            }
            StoreObjectId        storeObjectId2       = null;
            OwaStoreObjectIdType owaStoreObjectIdType = OwaStoreObjectIdType.MailBoxObject;

            if (IdConverter.IsFromPublicStore(storeObjectId))
            {
                if (IdConverter.IsMessageId(storeObjectId))
                {
                    owaStoreObjectIdType = OwaStoreObjectIdType.PublicStoreItem;
                    storeObjectId2       = IdConverter.GetParentIdFromMessageId(storeObjectId);
                }
                else
                {
                    owaStoreObjectIdType = OwaStoreObjectIdType.PublicStoreFolder;
                }
            }
            else if (relatedStoreObjectId != null)
            {
                if (!relatedStoreObjectId.IsConversationId)
                {
                    owaStoreObjectIdType = relatedStoreObjectId.OwaStoreObjectIdType;
                }
                else if (relatedStoreObjectId.OwaStoreObjectIdType == OwaStoreObjectIdType.ArchiveConversation)
                {
                    owaStoreObjectIdType = OwaStoreObjectIdType.ArchiveMailboxObject;
                }
            }
            return(new OwaStoreObjectId(owaStoreObjectIdType, storeObjectId, storeObjectId2, (relatedStoreObjectId == null) ? null : relatedStoreObjectId.MailboxOwnerLegacyDN));
        }
Ejemplo n.º 6
0
        internal static OwaStoreObjectId CreateFromString(string owaStoreObjectIdString)
        {
            OwaStoreObjectIdType owaStoreObjectIdType = OwaStoreObjectIdType.MailBoxObject;

            if (owaStoreObjectIdString.StartsWith("PSF.", StringComparison.Ordinal))
            {
                owaStoreObjectIdType = OwaStoreObjectIdType.PublicStoreFolder;
            }
            else if (owaStoreObjectIdString.StartsWith("PSI.", StringComparison.Ordinal))
            {
                owaStoreObjectIdType = OwaStoreObjectIdType.PublicStoreItem;
            }
            else if (owaStoreObjectIdString.StartsWith("OUM.", StringComparison.Ordinal))
            {
                owaStoreObjectIdType = OwaStoreObjectIdType.OtherUserMailboxObject;
            }
            else if (owaStoreObjectIdString.StartsWith("CID.", StringComparison.Ordinal))
            {
                owaStoreObjectIdType = OwaStoreObjectIdType.Conversation;
            }
            else if (owaStoreObjectIdString.StartsWith("AMB.", StringComparison.Ordinal))
            {
                owaStoreObjectIdType = OwaStoreObjectIdType.ArchiveMailboxObject;
            }
            else if (owaStoreObjectIdString.StartsWith("ACI.", StringComparison.Ordinal))
            {
                owaStoreObjectIdType = OwaStoreObjectIdType.ArchiveConversation;
            }
            else if (owaStoreObjectIdString.StartsWith("GS.", StringComparison.Ordinal))
            {
                owaStoreObjectIdType = OwaStoreObjectIdType.GSCalendar;
            }
            StoreObjectId folderStoreObjectId  = null;
            StoreObjectId folderStoreObjectId2 = null;
            string        text = null;

            switch (owaStoreObjectIdType)
            {
            case OwaStoreObjectIdType.PublicStoreFolder:
                folderStoreObjectId = OwaStoreObjectId.CreateStoreObjectId(owaStoreObjectIdString.Substring("PSF".Length + 1));
                OwaStoreObjectId.ValidateFolderId(folderStoreObjectId);
                break;

            case OwaStoreObjectIdType.PublicStoreItem:
            {
                int num = owaStoreObjectIdString.LastIndexOf(".", StringComparison.Ordinal);
                if (num == "PSI".Length)
                {
                    throw new OwaInvalidIdFormatException(string.Format("There should be two separator \"{0}\" in the id of the public item. Invalid Id string: {1}", ".", owaStoreObjectIdString));
                }
                folderStoreObjectId2 = OwaStoreObjectId.CreateStoreObjectId(owaStoreObjectIdString.Substring("PSI".Length + 1, num - "PSI".Length - 1));
                folderStoreObjectId  = OwaStoreObjectId.CreateStoreObjectId(owaStoreObjectIdString.Substring(num + 1));
                OwaStoreObjectId.ValidateFolderId(folderStoreObjectId2);
                break;
            }

            case OwaStoreObjectIdType.Conversation:
            {
                string[] array = owaStoreObjectIdString.Split(new char[]
                    {
                        "."[0]
                    });
                OwaStoreObjectId result;
                if (array.Length == 4)
                {
                    result = new OwaStoreObjectId(ConversationId.Create(array[1]), string.IsNullOrEmpty(array[2]) ? null : OwaStoreObjectId.CreateStoreObjectId(array[2]), string.IsNullOrEmpty(array[3]) ? null : OwaStoreObjectId.CreateInstanceKey(array[3]));
                }
                else if (array.Length == 3)
                {
                    result = new OwaStoreObjectId(ConversationId.Create(array[1]), OwaStoreObjectId.CreateStoreObjectId(array[2]), null);
                }
                else
                {
                    if (array.Length != 2)
                    {
                        throw new OwaInvalidRequestException(string.Format("There should be one or two separator \"{0}\" in the id of the conversation item", "."));
                    }
                    result = new OwaStoreObjectId(ConversationId.Create(array[1]), null, null);
                }
                return(result);
            }

            case OwaStoreObjectIdType.OtherUserMailboxObject:
            {
                int num = owaStoreObjectIdString.LastIndexOf(".", StringComparison.Ordinal);
                folderStoreObjectId = OwaStoreObjectId.CreateStoreObjectIdFromString(owaStoreObjectIdString, "OUM", num);
                text = OwaStoreObjectId.ParseLegacyDnBase64String(owaStoreObjectIdString.Substring(num + 1));
                break;
            }

            case OwaStoreObjectIdType.ArchiveMailboxObject:
            {
                int num = owaStoreObjectIdString.LastIndexOf(".", StringComparison.Ordinal);
                folderStoreObjectId = OwaStoreObjectId.CreateStoreObjectIdFromString(owaStoreObjectIdString, "AMB", num);
                text = OwaStoreObjectId.ParseLegacyDnBase64String(owaStoreObjectIdString.Substring(num + 1));
                break;
            }

            case OwaStoreObjectIdType.ArchiveConversation:
            {
                string[] array = owaStoreObjectIdString.Split(new char[]
                    {
                        "."[0]
                    });
                OwaStoreObjectId result;
                if (array.Length == 5)
                {
                    text   = OwaStoreObjectId.ParseLegacyDnBase64String(array[3]);
                    result = new OwaStoreObjectId(ConversationId.Create(array[1]), string.IsNullOrEmpty(array[2]) ? null : OwaStoreObjectId.CreateStoreObjectId(array[2]), text, string.IsNullOrEmpty(array[4]) ? null : OwaStoreObjectId.CreateInstanceKey(array[4]));
                }
                else if (array.Length == 4)
                {
                    text   = OwaStoreObjectId.ParseLegacyDnBase64String(array[3]);
                    result = new OwaStoreObjectId(ConversationId.Create(array[1]), OwaStoreObjectId.CreateStoreObjectId(array[2]), text, null);
                }
                else
                {
                    if (array.Length != 3)
                    {
                        throw new OwaInvalidRequestException(string.Format("There should be two or three separator \"{0}\" in the id of the archive conversation item", "."));
                    }
                    text   = OwaStoreObjectId.ParseLegacyDnBase64String(array[2]);
                    result = new OwaStoreObjectId(ConversationId.Create(array[1]), null, text, null);
                }
                return(result);
            }

            case OwaStoreObjectIdType.GSCalendar:
            {
                string[] array = owaStoreObjectIdString.Split(new char[]
                    {
                        "."[0]
                    });
                if (array.Length != 2)
                {
                    throw new OwaInvalidRequestException(string.Format("There should be two separator \"{0}\" in the id of the GS calendar item", "."));
                }
                text = OwaStoreObjectId.ParseLegacyDnBase64String(array[1]);
                break;
            }

            default:
                return(OwaStoreObjectId.CreateFromStoreObjectId(OwaStoreObjectId.CreateStoreObjectId(owaStoreObjectIdString), null));
            }
            return(new OwaStoreObjectId(owaStoreObjectIdType, folderStoreObjectId, folderStoreObjectId2, text));
        }