コード例 #1
0
        // Token: 0x060009C3 RID: 2499 RVA: 0x00039960 File Offset: 0x00037B60
        private void WriteFolderXml(XmlDocument xmlResponse, XmlElement foldersNode, object[] folderProperties)
        {
            StoreObjectId objectId          = ((VersionedId)folderProperties[0]).ObjectId;
            StoreObjectId storeObjectId     = (StoreObjectId)folderProperties[1];
            string        orAddSyncFolderId = GetHierarchyCommand.GetOrAddSyncFolderId(this.folderIdMappingSyncState, objectId);
            string        innerText         = storeObjectId.Equals(base.MailboxSession.GetDefaultFolderId(DefaultFolderType.Root)) ? "0" : GetHierarchyCommand.GetOrAddSyncFolderId(this.folderIdMappingSyncState, storeObjectId);
            string        innerText2        = folderProperties[2] as string;
            string        airSyncFolderType = AirSyncUtility.GetAirSyncFolderType(base.MailboxSession, objectId);
            XmlElement    xmlElement        = xmlResponse.CreateElement("Folder", "FolderHierarchy:");

            foldersNode.AppendChild(xmlElement);
            XmlElement xmlElement2 = xmlResponse.CreateElement("DisplayName", "FolderHierarchy:");

            xmlElement2.InnerText = innerText2;
            xmlElement.AppendChild(xmlElement2);
            XmlElement xmlElement3 = xmlResponse.CreateElement("ServerId", "FolderHierarchy:");

            xmlElement3.InnerText = orAddSyncFolderId;
            xmlElement.AppendChild(xmlElement3);
            XmlElement xmlElement4 = xmlResponse.CreateElement("Type", "FolderHierarchy:");

            xmlElement4.InnerText = airSyncFolderType;
            xmlElement.AppendChild(xmlElement4);
            XmlElement xmlElement5 = xmlResponse.CreateElement("ParentId", "FolderHierarchy:");

            xmlElement5.InnerText = innerText;
            xmlElement.AppendChild(xmlElement5);
        }
コード例 #2
0
        protected override void ConvertSyncIdsToXsoIds(FolderCommand.FolderRequest folderRequest)
        {
            SyncCollection.CollectionTypes collectionType = AirSyncUtility.GetCollectionType(folderRequest.SyncServerId);
            if (collectionType != SyncCollection.CollectionTypes.Mailbox && collectionType != SyncCollection.CollectionTypes.Unknown)
            {
                base.ProtocolLogger.SetValue(ProtocolLoggerData.Error, "DeleteOfVFolder");
                AirSyncPermanentException ex = new AirSyncPermanentException(StatusCode.Sync_InvalidSyncKey, base.ConstructErrorXml(StatusCode.Sync_InvalidSyncKey), null, false);
                throw ex;
            }
            SyncPermissions syncPermissions;

            folderRequest.ServerId = base.GetXsoFolderId(folderRequest.SyncServerId, out syncPermissions);
            if (folderRequest.ServerId == null)
            {
                base.ProtocolLogger.SetValue(ProtocolLoggerData.Error, "DeleteOfInvalidId");
                AirSyncPermanentException ex2 = new AirSyncPermanentException(StatusCode.Sync_ProtocolError, base.ConstructErrorXml(StatusCode.Sync_ProtocolError), null, false);
                throw ex2;
            }
            if (syncPermissions == SyncPermissions.FullAccess)
            {
                return;
            }
            if (base.Version < 140)
            {
                throw new InvalidOperationException("Pre-Version 14 device should not see a non-FullAccess folder! Folder Access Level: " + syncPermissions);
            }
            base.ProtocolLogger.SetValue(ProtocolLoggerData.Error, "DeleteOfNonFullAccessFolder");
            AirSyncPermanentException ex3 = new AirSyncPermanentException(StatusCode.Sync_InvalidSyncKey, base.ConstructErrorXml(StatusCode.Sync_InvalidSyncKey), null, false);

            throw ex3;
        }
コード例 #3
0
        // Token: 0x060017A3 RID: 6051 RVA: 0x0008C504 File Offset: 0x0008A704
        public static ISyncStatusData Load(SyncStateStorage syncStateStorage)
        {
            SyncStatusData  syncStatusData = null;
            bool            flag           = false;
            ISyncStatusData result;

            try
            {
                syncStatusData = new SyncStatusData();
                syncStatusData.syncStatusSyncState = AirSyncUtility.GetOrCreateSyncStatusSyncState(syncStateStorage);
                syncStatusData.clientCategoryList  = syncStatusData.GetClientCategoryList();
                syncStatusData.lastClientIdsSent   = syncStatusData.GetLastIdsSeen();
                syncStatusData.dirty = false;
                syncStatusData.clientCategoryListModified = false;
                syncStatusData.lastClientIdsSentModified  = false;
                flag   = true;
                result = syncStatusData;
            }
            finally
            {
                if (!flag && syncStatusData != null)
                {
                    syncStatusData.Dispose();
                    syncStatusData = null;
                }
            }
            return(result);
        }
コード例 #4
0
        private string ConstructUserMailDeviceInformationTable()
        {
            StringBuilder stringBuilder = new StringBuilder("<table>");

            if (this.globalInfo.DeviceAccessState != DeviceAccessState.DeviceDiscovery)
            {
                stringBuilder.AppendFormat("<tr><td>{0}</td><td>{1}</td></tr>", AirSyncUtility.HtmlEncode(Strings.ABQMailBodyDeviceModel.ToString(this.cultureInfo), false), AirSyncUtility.HtmlEncode(this.globalInfo.DeviceModel, false));
                stringBuilder.AppendFormat("<tr><td>{0}</td><td>{1}</td></tr>", AirSyncUtility.HtmlEncode(Strings.ABQMailBodyDeviceType.ToString(this.cultureInfo), false), AirSyncUtility.HtmlEncode(this.context.DeviceIdentity.DeviceType, false));
                stringBuilder.AppendFormat("<tr><td>{0}</td><td>{1}</td></tr>", AirSyncUtility.HtmlEncode(Strings.ABQMailBodyDeviceID.ToString(this.cultureInfo), false), AirSyncUtility.HtmlEncode(this.context.DeviceIdentity.DeviceId, false));
                stringBuilder.AppendFormat("<tr><td>{0}</td><td>{1}</td></tr>", AirSyncUtility.HtmlEncode(Strings.ABQMailBodyDeviceOS.ToString(this.cultureInfo), false), AirSyncUtility.HtmlEncode(this.globalInfo.DeviceOS, false));
                stringBuilder.AppendFormat("<tr><td>{0}</td><td>{1}</td></tr>", AirSyncUtility.HtmlEncode(Strings.ABQMailBodyDeviceUserAgent.ToString(this.cultureInfo), false), AirSyncUtility.HtmlEncode(this.globalInfo.UserAgent, false));
                stringBuilder.AppendFormat("<tr><td>{0}</td><td>{1}</td></tr>", AirSyncUtility.HtmlEncode(Strings.ABQMailBodyDeviceIMEI.ToString(this.cultureInfo), false), AirSyncUtility.HtmlEncode(this.globalInfo.DeviceImei, false));
                stringBuilder.AppendFormat("<tr><td>{0}</td><td>{1}</td></tr>", AirSyncUtility.HtmlEncode(Strings.ABQMailBodyEASVersion.ToString(this.cultureInfo), false), AirSyncUtility.HtmlEncode(this.globalInfo.DeviceActiveSyncVersion, false));
                stringBuilder.AppendFormat("<tr><td>{0}</td><td>{1}</td></tr>", AirSyncUtility.HtmlEncode(Strings.ABQMailBodyDeviceAccessState.ToString(this.cultureInfo), false), AirSyncUtility.HtmlEncode(this.globalInfo.DeviceAccessState.ToString(), false));
                stringBuilder.AppendFormat("<tr><td>{0}</td><td>{1}</td></tr>", AirSyncUtility.HtmlEncode(Strings.ABQMailBodyDeviceAccessStateReason.ToString(this.cultureInfo), false), AirSyncUtility.HtmlEncode(this.globalInfo.DeviceAccessStateReason.ToString(), false));
            }
            else
            {
                stringBuilder.AppendFormat("<tr><td>{0}</td><td>{1}</td></tr>", AirSyncUtility.HtmlEncode(Strings.ABQMailBodyDeviceType.ToString(this.cultureInfo), false), AirSyncUtility.HtmlEncode(this.context.DeviceIdentity.DeviceType, false));
                stringBuilder.AppendFormat("<tr><td>{0}</td><td>{1}</td></tr>", AirSyncUtility.HtmlEncode(Strings.ABQMailBodyDeviceID.ToString(this.cultureInfo), false), AirSyncUtility.HtmlEncode(this.context.DeviceIdentity.DeviceId, false));
                stringBuilder.AppendFormat("<tr><td>{0}</td><td>{1}</td></tr>", AirSyncUtility.HtmlEncode(Strings.ABQMailBodyDeviceUserAgent.ToString(this.cultureInfo), false), AirSyncUtility.HtmlEncode(this.context.Request.UserAgent, false));
                stringBuilder.AppendFormat("<tr><td>{0}</td><td>{1}</td></tr>", AirSyncUtility.HtmlEncode(Strings.ABQMailBodyEASVersion.ToString(this.cultureInfo), false), AirSyncUtility.HtmlEncode(this.globalInfo.DeviceActiveSyncVersion, false));
                stringBuilder.AppendFormat("<tr><td>{0}</td><td>{1}</td></tr>", AirSyncUtility.HtmlEncode(Strings.ABQMailBodyDeviceAccessState.ToString(this.cultureInfo), false), AirSyncUtility.HtmlEncode(this.globalInfo.DeviceAccessState.ToString(), false));
                stringBuilder.AppendFormat("<tr><td>{0}</td><td>{1}</td></tr>", AirSyncUtility.HtmlEncode(Strings.ABQMailBodyDeviceAccessStateReason.ToString(this.cultureInfo), false), AirSyncUtility.HtmlEncode(this.globalInfo.DeviceAccessStateReason.ToString(), false));
            }
            stringBuilder.Append("</table>");
            return(stringBuilder.ToString());
        }
コード例 #5
0
        public override OperationResult DeleteSyncItem(SyncCommandItem syncCommandItem, bool deletesAsMoves)
        {
            AirSyncDiagnostics.TraceInfo(ExTraceGlobals.RequestsTracer, this, "SyncCollection.DeleteSyncItem(SyncCommandItem)");
            EntitySyncProviderFactory entitySyncProviderFactory = (EntitySyncProviderFactory)base.SyncProviderFactory;
            StoreObjectId             folderId = entitySyncProviderFactory.FolderId;

            if (AirSyncUtility.GetAirSyncFolderTypeClass(folderId) == "Calendar")
            {
                CancelEventParameters parameters;
                if (syncCommandItem.XmlNode != null)
                {
                    try
                    {
                        parameters = EventParametersParser.ParseCancel(syncCommandItem.XmlNode);
                        goto IL_72;
                    }
                    catch (RequestParsingException ex)
                    {
                        throw new AirSyncPermanentException(StatusCode.Sync_ProtocolError, ex.LocalizedString, ex, false)
                              {
                                  ErrorStringForProtocolLogger = ex.LogMessage
                              };
                    }
                }
                parameters = new CancelEventParameters();
IL_72:
                this.DeleteItem(syncCommandItem.Id, parameters);
                return(OperationResult.Succeeded);
            }
            return(this.DeleteSyncItem(syncCommandItem.ServerId, deletesAsMoves));
        }
コード例 #6
0
        private StoreObjectId GetStoreObjectId(string folderId)
        {
            SyncCollection.CollectionTypes collectionType = AirSyncUtility.GetCollectionType(folderId);
            if (collectionType != SyncCollection.CollectionTypes.Mailbox && collectionType != SyncCollection.CollectionTypes.Unknown)
            {
                throw new AirSyncPermanentException(StatusCode.InvalidCombinationOfIDs, false)
                      {
                          ErrorStringForProtocolLogger = "BadIdComboInConversationMove"
                      };
            }
            if (this.folderIdMapping == null)
            {
                using (CustomSyncState customSyncState = this.syncStateStorage.GetCustomSyncState(new FolderIdMappingSyncStateInfo(), new PropertyDefinition[0]))
                {
                    if (customSyncState == null)
                    {
                        throw new AirSyncPermanentException(StatusCode.Sync_ClientServerConversion, false)
                              {
                                  ErrorStringForProtocolLogger = "NoSyncStateInConversationMove"
                              };
                    }
                    if (customSyncState[CustomStateDatumType.IdMapping] == null)
                    {
                        throw new AirSyncPermanentException(StatusCode.Sync_ClientServerConversion, false)
                              {
                                  ErrorStringForProtocolLogger = "NoIdMappingInConversationMove"
                              };
                    }
                    this.folderIdMapping = (FolderIdMapping)customSyncState[CustomStateDatumType.IdMapping];
                    this.fullFolderTree  = (FolderTree)customSyncState[CustomStateDatumType.FullFolderTree];
                }
            }
            ISyncItemId syncItemId = this.folderIdMapping[folderId];

            if (syncItemId == null)
            {
                throw new AirSyncPermanentException(StatusCode.Sync_ClientServerConversion, false)
                      {
                          ErrorStringForProtocolLogger = "NoFldrIdInMappingInConversationMove"
                      };
            }
            MailboxSyncItemId mailboxSyncItemId = syncItemId as MailboxSyncItemId;

            if (mailboxSyncItemId == null)
            {
                throw new AirSyncPermanentException(StatusCode.InvalidIDs, false)
                      {
                          ErrorStringForProtocolLogger = "BadIdInConversationMove"
                      };
            }
            if (this.fullFolderTree.IsSharedFolder(mailboxSyncItemId) || this.fullFolderTree.GetPermissions(mailboxSyncItemId) != SyncPermissions.FullAccess)
            {
                throw new AirSyncPermanentException(StatusCode.Sync_Retry, false)
                      {
                          ErrorStringForProtocolLogger = "DeniedInConversationMove"
                      };
            }
            return((StoreObjectId)mailboxSyncItemId.NativeId);
        }
コード例 #7
0
 // Token: 0x06000D02 RID: 3330 RVA: 0x0004676C File Offset: 0x0004496C
 private void ParseXmlRequest()
 {
     if (base.XmlRequest.Name != "MoveItems")
     {
         base.ProtocolLogger.SetValue(ProtocolLoggerData.Error, "InvalidParentTag");
         throw new AirSyncPermanentException(HttpStatusCode.InternalServerError, StatusCode.InvalidXML, null, false);
     }
     using (XmlNodeList elementsByTagName = base.XmlRequest.GetElementsByTagName("Move", "Move:"))
     {
         if (elementsByTagName.Count < 1 || elementsByTagName.Count >= GlobalSettings.MaxNoOfItemsMove)
         {
             base.ProtocolLogger.SetValue(ProtocolLoggerData.Error, (elementsByTagName.Count < 1) ? "NoMoveTags" : "MITooManyOperations");
             throw new AirSyncPermanentException(HttpStatusCode.InternalServerError, StatusCode.InvalidXML, null, false);
         }
         foreach (object obj in elementsByTagName)
         {
             XmlNode xmlNode = (XmlNode)obj;
             string  text    = null;
             string  text2   = null;
             string  text3   = null;
             try
             {
                 text  = xmlNode["SrcMsgId", "Move:"].InnerText;
                 text2 = xmlNode["SrcFldId", "Move:"].InnerText;
                 text3 = xmlNode["DstFldId", "Move:"].InnerText;
             }
             catch (NullReferenceException innerException)
             {
                 base.ProtocolLogger.SetValue(ProtocolLoggerData.Error, "MessageOrFolderIdNotSpecified");
                 throw new AirSyncPermanentException(HttpStatusCode.InternalServerError, StatusCode.InvalidXML, innerException, false);
             }
             if ((AirSyncUtility.GetCollectionType(text2) != SyncCollection.CollectionTypes.Mailbox && AirSyncUtility.GetCollectionType(text2) != SyncCollection.CollectionTypes.Unknown) || (AirSyncUtility.GetCollectionType(text3) != SyncCollection.CollectionTypes.Mailbox && AirSyncUtility.GetCollectionType(text3) != SyncCollection.CollectionTypes.Unknown))
             {
                 this.AppendItemXmlNode(text, 105.ToString(CultureInfo.InvariantCulture), text3);
             }
             else
             {
                 StoreObjectId     xsoItemId          = this.GetXsoItemId(text2, text);
                 MailboxSyncItemId mailboxSyncItemId  = this.FolderIdMapping[text2] as MailboxSyncItemId;
                 MailboxSyncItemId mailboxSyncItemId2 = this.FolderIdMapping[text3] as MailboxSyncItemId;
                 StoreObjectId     srcFldId           = (mailboxSyncItemId == null) ? null : ((StoreObjectId)mailboxSyncItemId.NativeId);
                 StoreObjectId     dstFldId           = (mailboxSyncItemId2 == null) ? null : ((StoreObjectId)mailboxSyncItemId2.NativeId);
                 if (mailboxSyncItemId != null && (!this.FullFolderTree.Contains(mailboxSyncItemId) || this.FullFolderTree.GetPermissions(mailboxSyncItemId) != SyncPermissions.FullAccess || this.FullFolderTree.IsSharedFolder(mailboxSyncItemId)))
                 {
                     base.ProtocolLogger.SetValue(ProtocolLoggerData.Error, "MoveFromNonFullAccessFolder");
                     throw new AirSyncPermanentException(HttpStatusCode.InternalServerError, StatusCode.Success, null, false);
                 }
                 if (mailboxSyncItemId2 != null && (!this.FullFolderTree.Contains(mailboxSyncItemId2) || this.FullFolderTree.GetPermissions(mailboxSyncItemId2) != SyncPermissions.FullAccess || this.FullFolderTree.IsSharedFolder(mailboxSyncItemId2)))
                 {
                     base.ProtocolLogger.SetValue(ProtocolLoggerData.Error, "MoveToNonFullAccessFolder");
                     throw new AirSyncPermanentException(HttpStatusCode.InternalServerError, StatusCode.Sync_ProtocolVersionMismatch, null, false);
                 }
                 this.ValidateItem(text, xsoItemId, srcFldId, dstFldId);
             }
         }
     }
 }
コード例 #8
0
        public bool TryGetProperty <T>(StorePropertyDefinition propDef, out T propertyValue)
        {
            bool result;

            lock (this.lockObject)
            {
                result = AirSyncUtility.TryGetPropertyFromBag <T>(this.customSyncState.StoreObject, propDef, out propertyValue);
            }
            return(result);
        }
コード例 #9
0
        private QueryFilter ParseContains(XmlNode parentNode)
        {
            if (parentNode.ChildNodes.Count != 2)
            {
                throw new SearchProtocolErrorException
                      {
                          ErrorStringForProtocolLogger = "SearchProtocolError7"
                      };
            }
            XmlNode xmlNode  = parentNode.ChildNodes[0];
            XmlNode xmlNode2 = parentNode.ChildNodes[1];

            if ("Search:" != xmlNode2.NamespaceURI || "Value" != xmlNode2.Name)
            {
                throw new SearchProtocolErrorException
                      {
                          ErrorStringForProtocolLogger = "SearchProtocolError8"
                      };
            }
            string innerText = xmlNode2.InnerText;
            string name;

            if ((name = xmlNode.Name) != null)
            {
                QueryFilter result;
                if (!(name == "From"))
                {
                    if (!(name == "CategoryId"))
                    {
                        goto IL_FE;
                    }
                    int num;
                    if (!int.TryParse(innerText, NumberStyles.None, CultureInfo.InvariantCulture, out num) || num % 2 != 1)
                    {
                        throw new SearchProtocolErrorException
                              {
                                  ErrorStringForProtocolLogger = "SearchProtocolError11"
                              };
                    }
                    string text = AirSyncUtility.ConvertSytemCategoryIdToKeywordsFormat(num);
                    result = new TextFilter(ItemSchema.Categories, text, MatchOptions.SubString, MatchFlags.Default);
                }
                else
                {
                    result = new TextFilter(ItemSchema.SentRepresentingEmailAddress, innerText, MatchOptions.SubString, MatchFlags.Loose);
                }
                return(result);
            }
IL_FE:
            throw new SearchProtocolErrorException
                  {
                      ErrorStringForProtocolLogger = "BadNode(" + xmlNode.Name + ")InSearch"
                  };
        }
コード例 #10
0
        private void ConstructAdminNotificationMail(MessageItem messageToAdmin)
        {
            StringBuilder stringBuilder = new StringBuilder("<html>");

            stringBuilder.Append("<style>\r\n        body\r\n        {\r\n            font-family: Tahoma;\r\n            background-color: rgb(255,255,255);\r\n            color: #000000; font-size:x-small;\r\n            width: 600px;\r\n        }\r\n        p\r\n        {\r\n            margin-left:0px ;\r\n            margin-bottom:8px\r\n        }\r\n        table\r\n        {\r\n            font-family: Tahoma;\r\n            background-color: rgb(255,255,255);\r\n            color: #000000;\r\n            font-size:x-small;\r\n            border:0px ;\r\n            text-align:left;\r\n            margin-left:20px\r\n        }\r\n        </style>");
            stringBuilder.Append("<body>");
            messageToAdmin.Subject = EASServerStrings.AdminMailSubject(this.context.User.ADUser.DisplayName, this.context.User.ADUser.Alias);
            stringBuilder.AppendFormat("<p>{0}</p>", AirSyncUtility.HtmlEncode(EASServerStrings.AdminMailBody1, false));
            Uri userActiveSyncOptionsPageUrl = this.GetUserActiveSyncOptionsPageUrl();

            if (userActiveSyncOptionsPageUrl == null)
            {
                stringBuilder.AppendFormat("<p>{0}</p>", AirSyncUtility.HtmlEncode(EASServerStrings.AdminMailBody2, false));
            }
            else
            {
                string arg  = string.Format("<a href=\"{0}\">{1}</a>", userActiveSyncOptionsPageUrl.AbsoluteUri, userActiveSyncOptionsPageUrl.AbsoluteUri);
                string arg2 = string.Format(AirSyncUtility.HtmlEncode(EASServerStrings.AdminMailBody4, false), arg);
                stringBuilder.AppendFormat("<p>{0}</p>", arg2);
            }
            stringBuilder.Append("<p>");
            stringBuilder.Append(AirSyncUtility.HtmlEncode(EASServerStrings.AdminMailDeviceInformation, false));
            stringBuilder.Append("<table>");
            stringBuilder.AppendFormat("<tr><td>{0}</td><td>{1}</td></tr>", AirSyncUtility.HtmlEncode(EASServerStrings.AdminMailUser, false), AirSyncUtility.HtmlEncode(this.context.User.ExchangePrincipal.MailboxInfo.PrimarySmtpAddress.ToString(), false));
            stringBuilder.AppendFormat("<tr><td>{0}</td><td>{1}</td></tr>", AirSyncUtility.HtmlEncode(EASServerStrings.AdminMailBodyDeviceModel, false), AirSyncUtility.HtmlEncode(this.globalInfo.DeviceModel, false));
            stringBuilder.AppendFormat("<tr><td>{0}</td><td>{1}</td></tr>", AirSyncUtility.HtmlEncode(EASServerStrings.AdminMailBodyDeviceType, false), AirSyncUtility.HtmlEncode(this.context.DeviceIdentity.DeviceType, false));
            stringBuilder.AppendFormat("<tr><td>{0}</td><td>{1}</td></tr>", AirSyncUtility.HtmlEncode(EASServerStrings.AdminMailBodyDeviceID, false), AirSyncUtility.HtmlEncode(this.context.DeviceIdentity.DeviceId, false));
            stringBuilder.AppendFormat("<tr><td>{0}</td><td>{1}</td></tr>", AirSyncUtility.HtmlEncode(EASServerStrings.AdminMailBodyDeviceOS, false), AirSyncUtility.HtmlEncode(this.globalInfo.DeviceOS, false));
            stringBuilder.AppendFormat("<tr><td>{0}</td><td>{1}</td></tr>", AirSyncUtility.HtmlEncode(EASServerStrings.AdminMailBodyDeviceUserAgent, false), AirSyncUtility.HtmlEncode(this.globalInfo.UserAgent, false));
            stringBuilder.AppendFormat("<tr><td>{0}</td><td>{1}</td></tr>", AirSyncUtility.HtmlEncode(EASServerStrings.AdminMailDevicePhoneNumber, false), AirSyncUtility.HtmlEncode(DeviceInfo.ObfuscatePhoneNumber(this.globalInfo.DevicePhoneNumber), false));
            stringBuilder.AppendFormat("<tr><td>{0}</td><td>{1}</td></tr>", AirSyncUtility.HtmlEncode(EASServerStrings.AdminMailBodyDeviceIMEI, false), AirSyncUtility.HtmlEncode(this.globalInfo.DeviceImei, false));
            stringBuilder.AppendFormat("<tr><td>{0}</td><td>{1}</td></tr>", AirSyncUtility.HtmlEncode(EASServerStrings.AdminMailBodyEASVersion, false), AirSyncUtility.HtmlEncode(this.globalInfo.DeviceActiveSyncVersion, false));
            stringBuilder.AppendFormat("<tr><td>{0}</td><td>{1}</td></tr>", AirSyncUtility.HtmlEncode(EASServerStrings.AdminMailDevicePolicyApplied, false), (this.globalInfo.DevicePolicyApplied != null) ? AirSyncUtility.HtmlEncode(this.globalInfo.DevicePolicyApplied.ToString(), false) : null);
            stringBuilder.AppendFormat("<tr><td>{0}</td><td>{1}</td></tr>", AirSyncUtility.HtmlEncode(EASServerStrings.AdminMailDevicePolicyStatus, false), AirSyncUtility.HtmlEncode(this.globalInfo.DevicePolicyApplicationStatus.ToString(), false));
            stringBuilder.AppendFormat("<tr><td>{0}</td><td>{1}</td></tr>", AirSyncUtility.HtmlEncode(EASServerStrings.AdminMailBodyDeviceAccessState, false), AirSyncUtility.HtmlEncode(this.globalInfo.DeviceAccessState.ToString(), false));
            stringBuilder.AppendFormat("<tr><td>{0}</td><td>{1}</td></tr>", AirSyncUtility.HtmlEncode(EASServerStrings.AdminMailBodyDeviceAccessStateReason, false), AirSyncUtility.HtmlEncode(this.globalInfo.DeviceAccessStateReason.ToString(), false));
            stringBuilder.AppendFormat("<tr><td>{0}</td><td>{1}</td></tr>", AirSyncUtility.HtmlEncode(EASServerStrings.AdminMailDeviceAccessControlRule, false), (this.globalInfo.DeviceAccessControlRule != null) ? AirSyncUtility.HtmlEncode(this.globalInfo.DeviceAccessControlRule.ToString(), false) : null);
            stringBuilder.Append("</table></p>");
            StringBuilder stringBuilder2 = new StringBuilder();

            foreach (SmtpAddress smtpAddress in this.organizationSettings.AdminMailRecipients)
            {
                stringBuilder2.AppendFormat("{0},", smtpAddress.ToString());
            }
            stringBuilder.AppendFormat("<p>{0}</p>", AirSyncUtility.HtmlEncode(EASServerStrings.AdminMailBodySentAt(ExDateTime.Now.ToString(), stringBuilder2.ToString()), false));
            stringBuilder.Append("</body></html>");
            using (TextWriter textWriter = messageToAdmin.Body.OpenTextWriter(BodyFormat.TextHtml))
            {
                textWriter.Write(stringBuilder.ToString());
            }
        }
コード例 #11
0
 internal static void CreateAttachment(IItem parentItem, Attachment16Data attachmentData)
 {
     AirSyncDiagnostics.TraceDebug <byte>(ExTraceGlobals.RequestsTracer, null, "CreateAttachment with AttachMethod:{0}", attachmentData.Method);
     if (attachmentData.Method == 1)
     {
         if (attachmentData.Content == null)
         {
             throw new ConversionException(string.Format(" Attachment content can not be null.", new object[0]));
         }
         IStreamAttachment streamAttachment = parentItem.IAttachmentCollection.CreateIAttachment(AttachmentType.Stream) as IStreamAttachment;
         AttachmentHelper.CopyCommonAttachmentProperties(streamAttachment, attachmentData);
         using (Stream contentStream = streamAttachment.GetContentStream())
         {
             contentStream.Write(attachmentData.Content, 0, attachmentData.Content.Length);
         }
         streamAttachment.Save();
     }
     else
     {
         if (attachmentData.Method != 5)
         {
             throw new ConversionException(string.Format("UnSupported Value '{0}' for Attachment Method. Only 1 & 5 is supported AttachemntType", attachmentData.Method));
         }
         ItemAttachment itemAttachment = parentItem.IAttachmentCollection.CreateIAttachment(AttachmentType.EmbeddedMessage) as ItemAttachment;
         AttachmentHelper.CopyCommonAttachmentProperties(itemAttachment, attachmentData);
         using (Stream stream = new MemoryStream(attachmentData.Content))
         {
             stream.Seek(0L, SeekOrigin.Begin);
             InboundConversionOptions inboundConversionOptions = AirSyncUtility.GetInboundConversionOptions();
             inboundConversionOptions.ClearCategories = false;
             try
             {
                 using (Item item = itemAttachment.GetItem())
                 {
                     ItemConversion.ConvertAnyMimeToItem(item, stream, inboundConversionOptions);
                     item.Save(SaveMode.NoConflictResolution);
                 }
             }
             catch (ExchangeDataException innerException)
             {
                 throw new AirSyncPermanentException(HttpStatusCode.BadRequest, StatusCode.InvalidMIME, innerException, false);
             }
             catch (ConversionFailedException innerException2)
             {
                 throw new AirSyncPermanentException(HttpStatusCode.BadRequest, StatusCode.InvalidMIME, innerException2, false);
             }
         }
         itemAttachment.Save();
     }
     AirSyncDiagnostics.TraceDebug <int>(ExTraceGlobals.RequestsTracer, null, "AttachmentHelper:CreateAttachments:: AttachmentCreated successful. AttachmentCount:{0}", parentItem.IAttachmentCollection.Count);
 }
コード例 #12
0
        // Token: 0x06000C2F RID: 3119 RVA: 0x0003FD5C File Offset: 0x0003DF5C
        private void BuildMultiPartResponse(XmlDocument xmlResponse)
        {
            StringBuilder stringBuilder = null;

            if (base.MailboxLoggingEnabled && base.MailboxLogger != null)
            {
                stringBuilder = new StringBuilder();
                stringBuilder.Append("----------------------- Multipart Response ---------------------\r\n");
            }
            using (BinaryWriter binaryWriter = new BinaryWriter(base.OutputStream))
            {
                AirSyncStream airSyncStream = new AirSyncStream();
                base.Context.Response.BuildMultiPartWbXmlResponse(xmlResponse, airSyncStream);
                this.multipartStreams.Insert(0, airSyncStream);
                binaryWriter.Write(this.multipartStreams.Count);
                if (stringBuilder != null)
                {
                    stringBuilder.AppendFormat("Number of Parts: {0}\r\n", this.multipartStreams.Count);
                }
                int num = 4 + this.multipartStreams.Count * 8;
                for (int i = 0; i < this.multipartStreams.Count; i++)
                {
                    long length = this.multipartStreams[i].Length;
                    binaryWriter.Write(num);
                    binaryWriter.Write((int)length);
                    if (stringBuilder != null)
                    {
                        stringBuilder.AppendFormat("Part {0}: offset {1}, size {2}\r\n", i, num, length);
                    }
                    num += (int)length;
                }
                for (int j = 0; j < this.multipartStreams.Count; j++)
                {
                    StreamHelper.CopyStream(this.multipartStreams[j], base.OutputStream, (int)this.multipartStreams[j].Length);
                    if (stringBuilder != null && j == 0)
                    {
                        stringBuilder.AppendLine();
                        this.multipartStreams[j].Seek(0L, SeekOrigin.Begin);
                        using (WbxmlReader wbxmlReader = new WbxmlReader(this.multipartStreams[j]))
                        {
                            stringBuilder.Append(AirSyncUtility.BuildOuterXml(wbxmlReader.ReadXmlDocument(), !GlobalSettings.EnableMailboxLoggingVerboseMode));
                        }
                        stringBuilder.AppendLine();
                    }
                }
                if (stringBuilder != null)
                {
                    base.MailboxLogger.SetData(MailboxLogDataName.ResponseBody, stringBuilder.ToString());
                }
            }
        }
コード例 #13
0
        internal void ConstructMDMQuarantineNotificationMail(bool IsEnrolled, out string messageSubject, out string messageItemBody)
        {
            messageSubject = (IsEnrolled ? Strings.MDMNonCompliantMailSubject.ToString(this.cultureInfo) : Strings.MDMQuarantinedMailSubject.ToString(this.cultureInfo));
            StringBuilder stringBuilder = new StringBuilder("<html>");

            stringBuilder.Append("<style>\r\n        body\r\n        {\r\n            font-family: Tahoma;\r\n            background-color: rgb(255,255,255);\r\n            color: #000000; font-size:x-small;\r\n            width: 600px;\r\n        }\r\n        p\r\n        {\r\n            margin-left:0px ;\r\n            margin-bottom:8px\r\n        }\r\n        table\r\n        {\r\n            font-family: Tahoma;\r\n            background-color: rgb(255,255,255);\r\n            color: #000000;\r\n            font-size:x-small;\r\n            border:0px ;\r\n            text-align:left;\r\n            margin-left:20px\r\n        }\r\n        </style>");
            stringBuilder.Append("<body>");
            DeviceIdentity deviceIdentity = this.context.DeviceIdentity;
            OrganizationId organizationId = this.context.User.OrganizationId;
            string         text           = (organizationId == OrganizationId.ForestWideOrgId) ? string.Empty : organizationId.OrganizationalUnit.Name;
            Guid           guid           = Guid.NewGuid();

            if (IsEnrolled)
            {
                stringBuilder.AppendFormat("<p>{0}</p>", AirSyncUtility.HtmlEncode(Strings.MDMNonCompliantMailBody, this.cultureInfo, false));
                stringBuilder.AppendFormat("<a href=\"{0}\">{1}</a>", AirSyncUtility.HtmlEncode(string.Format(GlobalSettings.MDMComplianceStatusUrl.AbsoluteUri, deviceIdentity.DeviceId), false), AirSyncUtility.HtmlEncode(Strings.MDMNonCompliantMailBodyLinkText, this.cultureInfo, false));
            }
            else if (GlobalSettings.DeviceTypesWithBasicMDMNotification.Contains(deviceIdentity.DeviceType.ToLower()))
            {
                stringBuilder.AppendFormat("<p>{0}</p>", AirSyncUtility.HtmlEncode(Strings.MDMQuarantinedMailBody, this.cultureInfo, false));
                stringBuilder.AppendLine(AirSyncUtility.HtmlEncode(Strings.MDMQuarantinedMailBodyStep1, this.cultureInfo, false));
                stringBuilder.AppendFormat("<a href=\"{0}\">{1}</a>", AirSyncUtility.HtmlEncode(string.Format(GlobalSettings.MdmEnrollmentUrlWithBasicSteps.ToString(), deviceIdentity.DeviceId), false), AirSyncUtility.HtmlEncode(Strings.MDMQuarantinedMailBodyEnrollLink, this.cultureInfo, false));
                stringBuilder.Append("<br/>");
                stringBuilder.AppendLine(AirSyncUtility.HtmlEncode(Strings.MDMQuarantinedMailBodyStep2, this.cultureInfo, false));
                stringBuilder.AppendFormat("<a href=\"{0}\">{1}</a>", AirSyncUtility.HtmlEncode(string.Format(GlobalSettings.MDMComplianceStatusUrl.AbsoluteUri, deviceIdentity.DeviceId), false), AirSyncUtility.HtmlEncode(Strings.MDMNonCompliantMailBodyLinkText, this.cultureInfo, false));
                string arg = string.Format("<a href=\"{0}\">{1}</a>", AirSyncUtility.HtmlEncode(string.Format(GlobalSettings.MdmActivationUrlWithBasicSteps, deviceIdentity.DeviceId), false), AirSyncUtility.HtmlEncode(Strings.MDMQuarantinedMailBodyRetryLink, this.cultureInfo, false));
                stringBuilder.AppendFormat("<p>{0}</p>", string.Format(Strings.MDMQuarantinedMailBasicRetryText.ToString(this.cultureInfo), arg));
            }
            else
            {
                stringBuilder.AppendFormat("<p>{0}</p>", AirSyncUtility.HtmlEncode(Strings.MDMQuarantinedMailBody, this.cultureInfo, false));
                stringBuilder.AppendLine(AirSyncUtility.HtmlEncode(Strings.MDMQuarantinedMailBodyStep1, this.cultureInfo, false));
                stringBuilder.AppendFormat("<a href=\"{0}\">{1}</a>", AirSyncUtility.HtmlEncode(string.Format(GlobalSettings.MDMEnrollmentUrl.AbsoluteUri, deviceIdentity.DeviceId), false), AirSyncUtility.HtmlEncode(Strings.MDMQuarantinedMailBodyEnrollLink, this.cultureInfo, false));
                stringBuilder.Append("<br/>");
                stringBuilder.AppendLine(AirSyncUtility.HtmlEncode(Strings.MDMQuarantinedMailBodyStep2, this.cultureInfo, false));
                stringBuilder.AppendFormat("<a href=\"{0}\">{1}</a>", AirSyncUtility.HtmlEncode(string.Format(GlobalSettings.MDMActivationUrl, new object[]
                {
                    GlobalSettings.ADRegistrationServiceUrl,
                    text,
                    deviceIdentity.DeviceId,
                    guid
                }), false), AirSyncUtility.HtmlEncode(Strings.MDMQuarantinedMailBodyActivateLink, this.cultureInfo, false));
                stringBuilder.Append("<br/>");
                stringBuilder.AppendLine(AirSyncUtility.HtmlEncode(Strings.MDMQuarantinedMailBodyStep3, this.cultureInfo, false));
                stringBuilder.AppendFormat("<a href=\"{0}\">{1}</a>", AirSyncUtility.HtmlEncode(string.Format(GlobalSettings.MDMComplianceStatusUrl.AbsoluteUri, deviceIdentity.DeviceId), false), AirSyncUtility.HtmlEncode(Strings.MDMNonCompliantMailBodyLinkText, this.cultureInfo, false));
                AirSyncDiagnostics.TraceDebug <Guid>(ExTraceGlobals.RequestsTracer, null, "ABQMail:MdmQuarantine email traceID {0}", guid);
                this.context.ProtocolLogger.AppendValue(ProtocolLoggerData.GraphApiCallData, string.Format("tId:{0}", guid));
            }
            stringBuilder.Append("</body></html>");
            messageItemBody = stringBuilder.ToString();
        }
コード例 #14
0
        private bool LoadRightsManagementLicenseData(Item mailboxItem, RightsManagementLicenseData rightsManagementLicenseData)
        {
            if (!BodyConversionUtilities.IsMessageRestrictedAndDecoded(mailboxItem) && !BodyConversionUtilities.IsIRMFailedToDecode(mailboxItem))
            {
                return(false);
            }
            if (BodyConversionUtilities.IsIRMFailedToDecode(mailboxItem))
            {
                rightsManagementLicenseData.InitNoRightsTemplate();
                return(true);
            }
            RightsManagedMessageItem rightsManagedMessageItem = mailboxItem as RightsManagedMessageItem;

            rightsManagementLicenseData.EditAllowed               = new bool?(rightsManagedMessageItem.UsageRights.IsUsageRightGranted(ContentRight.Edit));
            rightsManagementLicenseData.ReplyAllowed              = new bool?(rightsManagedMessageItem.UsageRights.IsUsageRightGranted(ContentRight.Reply));
            rightsManagementLicenseData.ReplyAllAllowed           = new bool?(rightsManagedMessageItem.UsageRights.IsUsageRightGranted(ContentRight.ReplyAll));
            rightsManagementLicenseData.ForwardAllowed            = new bool?(rightsManagedMessageItem.UsageRights.IsUsageRightGranted(ContentRight.Forward));
            rightsManagementLicenseData.PrintAllowed              = new bool?(rightsManagedMessageItem.UsageRights.IsUsageRightGranted(ContentRight.Print));
            rightsManagementLicenseData.ExtractAllowed            = new bool?(rightsManagedMessageItem.UsageRights.IsUsageRightGranted(ContentRight.Extract));
            rightsManagementLicenseData.ProgrammaticAccessAllowed = new bool?(rightsManagedMessageItem.UsageRights.IsUsageRightGranted(ContentRight.ObjectModel));
            rightsManagementLicenseData.Owner = new bool?(rightsManagedMessageItem.UsageRights.IsUsageRightGranted(ContentRight.Owner));
            if (!AirSyncUtility.IsProtectedVoicemailItem(mailboxItem))
            {
                rightsManagementLicenseData.ExportAllowed = new bool?(rightsManagedMessageItem.UsageRights.IsUsageRightGranted(ContentRight.Export));
            }
            else
            {
                rightsManagementLicenseData.ExportAllowed = new bool?(false);
            }
            if (rightsManagedMessageItem.UsageRights.IsUsageRightGranted(ContentRight.Forward) && (!rightsManagedMessageItem.Restriction.RequiresRepublishingWhenRecipientsChange || rightsManagedMessageItem.CanRepublish))
            {
                rightsManagementLicenseData.ModifyRecipientsAllowed = new bool?(true);
            }
            else
            {
                rightsManagementLicenseData.ModifyRecipientsAllowed = new bool?(false);
            }
            rightsManagementLicenseData.ContentExpiryDate = new ExDateTime?(rightsManagedMessageItem.UserLicenseExpiryTime);
            rightsManagementLicenseData.ContentOwner      = rightsManagedMessageItem.ConversationOwner.EmailAddress;
            RmsTemplate restriction = rightsManagedMessageItem.Restriction;

            if (restriction != null)
            {
                Guid id = restriction.Id;
                rightsManagementLicenseData.TemplateID          = restriction.Id.ToString();
                rightsManagementLicenseData.TemplateName        = restriction.GetName(Command.CurrentCommand.MailboxSession.PreferedCulture);
                rightsManagementLicenseData.TemplateDescription = restriction.GetDescription(Command.CurrentCommand.MailboxSession.PreferedCulture);
            }
            return(true);
        }
コード例 #15
0
 private bool InternalHandleException(Exception ex)
 {
     if (this.command != null)
     {
         this.command.HandleException(ex);
         return(true);
     }
     if (AirSyncUtility.HandleNonCriticalException(ex, true))
     {
         this.Kill();
         return(true);
     }
     return(false);
 }
コード例 #16
0
        // Token: 0x06000C3C RID: 3132 RVA: 0x00040194 File Offset: 0x0003E394
        protected override int InternalExecute(int count)
        {
            FolderSyncState folderSyncState = null;
            int             result;

            try
            {
                string        text          = HttpUtility.UrlDecode(base.FileReference);
                int           num           = text.IndexOf(':');
                ItemIdMapping itemIdMapping = null;
                if (num != -1 && num != text.LastIndexOf(':'))
                {
                    string text2 = text.Substring(0, num);
                    SyncCollection.CollectionTypes collectionType = AirSyncUtility.GetCollectionType(text2);
                    if (collectionType != SyncCollection.CollectionTypes.Mailbox && collectionType != SyncCollection.CollectionTypes.Unknown)
                    {
                        base.ProtocolLogger.SetValue(ProtocolLoggerData.Error, "NoAttachmentsOnVItem");
                        AirSyncPermanentException ex = new AirSyncPermanentException(HttpStatusCode.InternalServerError, StatusCode.InvalidCombinationOfIDs, null, false);
                        throw ex;
                    }
                    folderSyncState = base.SyncStateStorage.GetFolderSyncState(new MailboxSyncProviderFactory(base.Session), text2);
                    if (folderSyncState == null)
                    {
                        throw new ObjectNotFoundException(ServerStrings.MapiCannotOpenAttachmentId(text));
                    }
                    itemIdMapping = (ItemIdMapping)folderSyncState[CustomStateDatumType.IdMapping];
                    if (itemIdMapping == null)
                    {
                        throw new ObjectNotFoundException(ServerStrings.MapiCannotOpenAttachmentId(text));
                    }
                }
                int num2;
                base.ContentType = AttachmentHelper.GetAttachment(base.Session, text, base.OutStream, base.MinRange, count, base.MaxAttachmentSize, itemIdMapping, base.RightsManagementSupport, out num2);
                result           = num2;
            }
            finally
            {
                if (folderSyncState != null)
                {
                    folderSyncState.Dispose();
                    folderSyncState = null;
                }
            }
            return(result);
        }
コード例 #17
0
        // Token: 0x06000883 RID: 2179 RVA: 0x000321EC File Offset: 0x000303EC
        public static int ComputeChangeTrackingHash(MailboxSession mbxsession, StoreObjectId folderId, IStorePropertyBag propertyBag)
        {
            StringBuilder stringBuilder = new StringBuilder(64 + FolderCommand.prefetchProperties.Length * 5);

            if (propertyBag != null)
            {
                AirSyncDiagnostics.TraceDebug(ExTraceGlobals.RequestsTracer, null, "[FolderCommand.ComputeChangeTrackingHash] Using passed folder view for change tracking.");
                string        text          = null;
                StoreObjectId storeObjectId = null;
                bool          flag          = false;
                stringBuilder.Append(AirSyncUtility.TryGetPropertyFromBag <string>(propertyBag, FolderSchema.DisplayName, out text) ? text : '§');
                stringBuilder.Append(AirSyncUtility.TryGetPropertyFromBag <StoreObjectId>(propertyBag, StoreObjectSchema.ParentItemId, out storeObjectId) ? storeObjectId : '§');
                stringBuilder.Append(AirSyncUtility.TryGetPropertyFromBag <bool>(propertyBag, FolderSchema.IsHidden, out flag) ? flag : '§');
                int num = 0;
                stringBuilder.Append(AirSyncUtility.TryGetPropertyFromBag <int>(propertyBag, FolderSchema.ExtendedFolderFlags, out num) && (num & 1073741824) != 0);
            }
            else
            {
                AirSyncDiagnostics.TraceDebug(ExTraceGlobals.RequestsTracer, null, "[FolderCommand.ComputeChangeTrackingHash] !!!!!WARNING!!!!! Using expensive full bind change tracking mechanism.  This is bad if it is done for entire hierarchy!!!");
                using (Folder folder = Folder.Bind(mbxsession, folderId, FolderCommand.prefetchProperties))
                {
                    stringBuilder.Append(folder.DisplayName);
                    stringBuilder.Append(folder.ParentId);
                    foreach (PropertyDefinition propertyDefinition in FolderCommand.prefetchProperties)
                    {
                        object obj = folder.TryGetProperty(propertyDefinition);
                        if (propertyDefinition == FolderSchema.ExtendedFolderFlags)
                        {
                            bool value = !(obj is PropertyError) && ((int)obj & 1073741824) != 0;
                            stringBuilder.Append(value);
                        }
                        else if (obj is PropertyError)
                        {
                            stringBuilder.Append('§');
                        }
                        else
                        {
                            stringBuilder.Append(obj);
                        }
                    }
                }
            }
            return(stringBuilder.ToString().GetHashCode());
        }
コード例 #18
0
        // Token: 0x06000763 RID: 1891 RVA: 0x000291AC File Offset: 0x000273AC
        private StoreObjectId GetStoreObjectId(string folderId)
        {
            if (this.folderIdMapping == null)
            {
                using (CustomSyncState customSyncState = this.syncStateStorage.GetCustomSyncState(new FolderIdMappingSyncStateInfo(), new PropertyDefinition[0]))
                {
                    if (customSyncState == null)
                    {
                        throw new AirSyncPermanentException(StatusCode.Sync_ClientServerConversion, false)
                              {
                                  ErrorStringForProtocolLogger = "NoSyncStateInEmptyFolder"
                              };
                    }
                    if (customSyncState[CustomStateDatumType.IdMapping] == null)
                    {
                        throw new AirSyncPermanentException(StatusCode.Sync_ClientServerConversion, false)
                              {
                                  ErrorStringForProtocolLogger = "NoIdMappingInEmptyFolder"
                              };
                    }
                    this.folderIdMapping = (FolderIdMapping)customSyncState[CustomStateDatumType.IdMapping];
                }
            }
            SyncCollection.CollectionTypes collectionType = AirSyncUtility.GetCollectionType(folderId);
            if (collectionType != SyncCollection.CollectionTypes.Mailbox && collectionType != SyncCollection.CollectionTypes.Unknown)
            {
                throw new AirSyncPermanentException(StatusCode.Sync_Retry, false)
                      {
                          ErrorStringForProtocolLogger = "SpecialFolderInEmptyFolder"
                      };
            }
            MailboxSyncItemId mailboxSyncItemId = this.folderIdMapping[folderId] as MailboxSyncItemId;

            if (mailboxSyncItemId == null)
            {
                throw new AirSyncPermanentException(StatusCode.Sync_ClientServerConversion, false)
                      {
                          ErrorStringForProtocolLogger = "NoIdMappingInEmptyFolder2"
                      };
            }
            return((StoreObjectId)mailboxSyncItemId.NativeId);
        }
コード例 #19
0
        // Token: 0x060005BB RID: 1467 RVA: 0x000221F0 File Offset: 0x000203F0
        private static bool IsRuleValueMatch(ActiveSyncDeviceFilterRule rule, string actualValue)
        {
            switch (rule.Operator)
            {
            case DeviceFilterOperator.Equals:
                return(string.Equals(actualValue, rule.Value, StringComparison.OrdinalIgnoreCase));

            case DeviceFilterOperator.Contains:
                return(AirSyncUtility.AreNotNullOrEmptyAndContains(actualValue, rule.Value));

            case DeviceFilterOperator.StartsWith:
                return(AirSyncUtility.AreNotNullOrEmptyAndStartsWith(actualValue, rule.Value));

            case DeviceFilterOperator.Regex:
                return(AirSyncUtility.AreNotNullOrEmptyAndRegexMatches(actualValue, rule.Value, RegexOptions.IgnoreCase | RegexOptions.Compiled | RegexOptions.CultureInvariant));

            default:
                throw new DeviceFilterInvalidException(EASServerStrings.InvalidDeviceFilterOperatorError(rule.Operator.ToString()));
            }
        }
コード例 #20
0
        private void ConstructUserNotificationMail(MessageItem messageToUser)
        {
            StringBuilder stringBuilder = new StringBuilder("<html>");

            stringBuilder.Append("<style>\r\n        body\r\n        {\r\n            font-family: Tahoma;\r\n            background-color: rgb(255,255,255);\r\n            color: #000000; font-size:x-small;\r\n            width: 600px;\r\n        }\r\n        p\r\n        {\r\n            margin-left:0px ;\r\n            margin-bottom:8px\r\n        }\r\n        table\r\n        {\r\n            font-family: Tahoma;\r\n            background-color: rgb(255,255,255);\r\n            color: #000000;\r\n            font-size:x-small;\r\n            border:0px ;\r\n            text-align:left;\r\n            margin-left:20px\r\n        }\r\n        </style>");
            stringBuilder.Append("<body>");
            switch (this.globalInfo.DeviceAccessState)
            {
            case DeviceAccessState.Blocked:
                messageToUser.Subject = Strings.AccessBlockedMailSubject.ToString(this.cultureInfo);
                stringBuilder.AppendFormat("<p>{0}</p>", AirSyncUtility.HtmlEncode(Strings.AccessBlockedMailBody1.ToString(this.cultureInfo), false));
                break;

            case DeviceAccessState.Quarantined:
                messageToUser.Subject = Strings.QuarantinedMailSubject.ToString(this.cultureInfo);
                stringBuilder.AppendFormat("<p>{0}</p>", AirSyncUtility.HtmlEncode(Strings.QuarantinedMailBody1.ToString(this.cultureInfo), false));
                break;

            case DeviceAccessState.DeviceDiscovery:
                messageToUser.Subject = Strings.DeviceDiscoveryMailSubject.ToString(this.cultureInfo);
                stringBuilder.AppendFormat("<p>{0}</p>", AirSyncUtility.HtmlEncode(Strings.DeviceDiscoveryMailBody1.ToString(this.cultureInfo), false));
                break;

            default:
                throw new InvalidOperationException(string.Format("Don't know how to construct user mail for AccessState: {0}", this.globalInfo.DeviceAccessState));
            }
            if (!string.IsNullOrEmpty(this.organizationSettings.UserMailInsert))
            {
                stringBuilder.AppendFormat("<p>{0}</p>", this.organizationSettings.UserMailInsert);
            }
            stringBuilder.Append("<p>");
            stringBuilder.Append(AirSyncUtility.HtmlEncode(Strings.ABQMailBodyDeviceInformation.ToString(this.cultureInfo), false));
            stringBuilder.Append(this.ConstructUserMailDeviceInformationTable());
            stringBuilder.Append("</p>");
            stringBuilder.AppendFormat("<p>{0}</p>", AirSyncUtility.HtmlEncode(Strings.ABQMailBodySentAt(ExDateTime.Now.ToString(this.cultureInfo), this.context.User.ExchangePrincipal.MailboxInfo.PrimarySmtpAddress.ToString()).ToString(this.cultureInfo), false));
            stringBuilder.Append("</body></html>");
            using (TextWriter textWriter = messageToUser.Body.OpenTextWriter(BodyFormat.TextHtml))
            {
                textWriter.Write(stringBuilder.ToString());
            }
        }
コード例 #21
0
        public static void TraceXmlBody(Trace tracer, object obj, XmlDocument xml)
        {
            if (xml == null)
            {
                throw new ArgumentNullException("xml");
            }
            if (!tracer.IsTraceEnabled(TraceType.DebugTrace))
            {
                return;
            }
            string text = AirSyncUtility.BuildOuterXml(xml);

            string[] separator = new string[]
            {
                "\r\n"
            };
            string[] array = text.Split(separator, StringSplitOptions.RemoveEmptyEntries);
            foreach (string arg in array)
            {
                AirSyncDiagnostics.TraceDebug <string>(tracer, obj, "    {0}", arg);
            }
        }
コード例 #22
0
 // Token: 0x06000D93 RID: 3475 RVA: 0x0004AF14 File Offset: 0x00049114
 internal static void SendBootstrapMailForWM61(IAirSyncUser user)
 {
     if (user == null)
     {
         throw new ArgumentNullException("user");
     }
     if (user.ExchangePrincipal == null)
     {
         throw new ArgumentNullException("user.ExchangePrincipal");
     }
     using (MailboxSession mailboxSession = MailboxSession.OpenAsSystemService(user.ExchangePrincipal, CultureInfo.InvariantCulture, "Client=ActiveSync"))
     {
         CultureInfo preferedCulture = mailboxSession.PreferedCulture;
         string      subject         = Strings.BootstrapMailForWM61Subject.ToString(preferedCulture);
         string      text            = string.Format("<a href=\"{0}\">{1}</a>", GlobalSettings.MobileUpdateInformationURL, AirSyncUtility.HtmlEncode(Strings.BootstrapMailForWM61Body7.ToString(preferedCulture), false));
         string      text2           = string.Format("<a href=\"{0}\">{1}</a>", GlobalSettings.BootstrapCABForWM61HostingURL, AirSyncUtility.HtmlEncode(Strings.BootstrapMailForWM61Body8.ToString(preferedCulture), false));
         string      text3           = string.Empty;
         IOrganizationSettingsData organizationSettingsData = ADNotificationManager.GetOrganizationSettingsData(user);
         if (organizationSettingsData != null && !string.IsNullOrEmpty(organizationSettingsData.OtaNotificationMailInsert))
         {
             text3 = string.Format("<p>{0}</p><hr>", organizationSettingsData.OtaNotificationMailInsert);
         }
         string body = string.Format("<html><head><style>p, li {{font-size:10pt; font-family:Tahoma;}}</style></head><body><p style=\"font-size:12pt; color:darkblue;\"><b>{0}</b></p><p>{1}</p><ul><li>{2}</li><li>{3}</li><li>{4}</li><li>{5}</li><li>{6}</li></ul><p><span style=\"font-size:12pt;\"><b>{7}</b></span><br>{8}</p><hr>{9}<p style=\"font-size:8pt; color:gray;\">{10}</p></body></html>", new object[]
         {
             AirSyncUtility.HtmlEncode(Strings.BootstrapMailForWM61Body1.ToString(preferedCulture), false),
             AirSyncUtility.HtmlEncode(Strings.BootstrapMailForWM61Body2.ToString(preferedCulture), false),
             AirSyncUtility.HtmlEncode(Strings.BootstrapMailForWM61Body3.ToString(preferedCulture), false),
             AirSyncUtility.HtmlEncode(Strings.BootstrapMailForWM61Body4.ToString(preferedCulture), false),
             AirSyncUtility.HtmlEncode(Strings.BootstrapMailForWM61Body5.ToString(preferedCulture), false),
             AirSyncUtility.HtmlEncode(Strings.BootstrapMailForWM61Body6.ToString(preferedCulture), false),
             text,
             text2,
             AirSyncUtility.HtmlEncode(Strings.BootstrapMailForWM61Body9.ToString(preferedCulture), false),
             text3,
             AirSyncUtility.HtmlEncode(Strings.BootstrapMailForWM61Body10.ToString(preferedCulture), false)
         });
         SystemMessageHelper.PostMessage(mailboxSession, subject, body, "IPM.Note", Importance.High);
     }
 }
コード例 #23
0
        public static Stream ConvertItemToMime(StoreObject xsoItem)
        {
            Item item = xsoItem as Item;

            if (item == null)
            {
                throw new UnexpectedTypeException("Item", xsoItem);
            }
            OutboundConversionOptions outboundConversionOptions = AirSyncUtility.GetOutboundConversionOptions();
            PolicyData policyData = ADNotificationManager.GetPolicyData(Command.CurrentCommand.User);

            if (policyData != null && !policyData.AttachmentsEnabled)
            {
                outboundConversionOptions.FilterAttachmentHandler = ((Item item1, Attachment attachment) => false);
            }
            item.Load(StoreObjectSchema.ContentConversionProperties);
            AirSyncStream airSyncStream = new AirSyncStream();

            try
            {
                if (BodyConversionUtilities.IsMessageRestrictedAndDecoded(item))
                {
                    ItemConversion.ConvertItemToMime(((RightsManagedMessageItem)item).DecodedItem, airSyncStream, outboundConversionOptions);
                }
                else
                {
                    ItemConversion.ConvertItemToMime(item, airSyncStream, outboundConversionOptions);
                }
            }
            catch (ConversionFailedException innerException)
            {
                throw new ConversionException(string.Format(CultureInfo.InvariantCulture, "MIME conversion failed for Item {0}", new object[]
                {
                    item
                }), innerException);
            }
            return(airSyncStream);
        }
コード例 #24
0
        private void ConstructAutoBlockNotificationMail(MessageItem messageToUser, TimeSpan blockTime, string adminEmailInsert)
        {
            messageToUser.Subject = Strings.AutoBlockedMailSubject.ToString(this.cultureInfo);
            StringBuilder stringBuilder = new StringBuilder("<html>");

            stringBuilder.Append("<style>\r\n        body\r\n        {\r\n            font-family: Tahoma;\r\n            background-color: rgb(255,255,255);\r\n            color: #000000; font-size:x-small;\r\n            width: 600px;\r\n        }\r\n        p\r\n        {\r\n            margin-left:0px ;\r\n            margin-bottom:8px\r\n        }\r\n        table\r\n        {\r\n            font-family: Tahoma;\r\n            background-color: rgb(255,255,255);\r\n            color: #000000;\r\n            font-size:x-small;\r\n            border:0px ;\r\n            text-align:left;\r\n            margin-left:20px\r\n        }\r\n        </style>");
            stringBuilder.Append("<body>");
            stringBuilder.AppendFormat("<p>{0}</p>", AirSyncUtility.HtmlEncode(string.Format(Strings.AutoBlockedMailBody1.ToString(this.cultureInfo), (int)blockTime.TotalHours + 1), false));
            if (!string.IsNullOrEmpty(adminEmailInsert))
            {
                stringBuilder.AppendFormat("<p>{0}</p>", adminEmailInsert);
            }
            stringBuilder.Append("<p>");
            stringBuilder.Append(AirSyncUtility.HtmlEncode(Strings.ABQMailBodyDeviceInformation.ToString(this.cultureInfo), false));
            stringBuilder.Append(this.ConstructUserMailDeviceInformationTable());
            stringBuilder.Append("</p>");
            stringBuilder.AppendFormat("<p>{0}</p>", AirSyncUtility.HtmlEncode(Strings.ABQMailBodySentAt(ExDateTime.Now.ToString(this.cultureInfo), this.context.User.ExchangePrincipal.MailboxInfo.PrimarySmtpAddress.ToString()).ToString(this.cultureInfo), false));
            stringBuilder.Append("</body></html>");
            using (TextWriter textWriter = messageToUser.Body.OpenTextWriter(BodyFormat.TextHtml))
            {
                textWriter.Write(stringBuilder.ToString());
            }
        }
コード例 #25
0
        protected override void InternalCopyFromModified(IProperty srcProperty)
        {
            IContentProperty contentProperty = (IContentProperty)srcProperty;
            BodyType         nativeType      = contentProperty.GetNativeType();

            if (nativeType == BodyType.Mime && string.Equals(base.XsoItem.ClassName, "IPM.NOTE.MOBILE.MMS", StringComparison.OrdinalIgnoreCase))
            {
                Item itemOut = (Item)base.XsoItem;
                InboundConversionOptions inboundConversionOptions = AirSyncUtility.GetInboundConversionOptions();
                inboundConversionOptions.ClearCategories = false;
                try
                {
                    Stream body = ((IContentProperty)srcProperty).Body;
                    ItemConversion.ConvertAnyMimeToItem(itemOut, body, inboundConversionOptions);
                    goto IL_8A;
                }
                catch (ExchangeDataException ex)
                {
                    throw new ConversionException("Mime conversion for MMS item failed due to InvalidCharSetError", ex.InnerException);
                }
                catch (ConversionFailedException ex2)
                {
                    throw new ConversionException("Mime conversion for MMS item failed due to InvalidMime", ex2.InnerException);
                }
            }
            base.InternalCopyFromModified(srcProperty);
IL_8A:
            if (string.Equals(base.XsoItem.ClassName, "IPM.NOTE.MOBILE.SMS", StringComparison.OrdinalIgnoreCase))
            {
                MessageItem  messageItem  = (MessageItem)base.XsoItem;
                StreamReader streamReader = new StreamReader(((IContentProperty)srcProperty).Body);
                char[]       array        = new char[78];
                int          length       = streamReader.ReadBlock(array, 0, array.Length);
                messageItem.Subject = new string(array, 0, length);
            }
        }
コード例 #26
0
        private Command.ExecutionState ForwardUsingXso(StoreObjectId smartId)
        {
            Item             smartItem        = base.GetSmartItem(smartId);
            MessageItem      messageItem      = null;
            VersionedId      versionedId      = null;
            MessageItem      messageItem2     = null;
            CalendarItemBase calendarItemBase = null;

            try
            {
                StoreObjectId defaultFolderId = base.MailboxSession.GetDefaultFolderId(DefaultFolderType.Drafts);
                messageItem = MessageItem.Create(base.MailboxSession, defaultFolderId);
                base.ParseMimeToMessage(messageItem);
                messageItem.Save(SaveMode.NoConflictResolution);
                messageItem.Load();
                versionedId = messageItem.Id;
                messageItem.Dispose();
                messageItem = MessageItem.Bind(base.MailboxSession, versionedId);
                RmsTemplate            rmsTemplate = null;
                SendMailBase.IrmAction irmAction   = base.GetIrmAction(delegate(RightsManagedMessageItem originalRightsManagedItem)
                {
                    if (originalRightsManagedItem == null)
                    {
                        throw new ArgumentNullException("originalRightsManagedItem");
                    }
                    if (!originalRightsManagedItem.UsageRights.IsUsageRightGranted(ContentRight.Forward))
                    {
                        throw new AirSyncPermanentException(StatusCode.IRM_OperationNotPermitted, false)
                        {
                            ErrorStringForProtocolLogger = "sfcEOperationNotPermitted"
                        };
                    }
                }, ref smartItem, out rmsTemplate);
                Microsoft.Exchange.Data.Storage.BodyFormat bodyFormat = messageItem.Body.Format;
                MeetingMessage meetingMessage = smartItem as MeetingMessage;
                string         text;
                if ((base.ReplaceMime || irmAction == SendMailBase.IrmAction.CreateNewPublishingLicenseAttachOriginalMessage) && meetingMessage != null && !meetingMessage.IsDelegated() && (meetingMessage is MeetingRequest || meetingMessage is MeetingCancellation))
                {
                    text = string.Empty;
                }
                else
                {
                    using (TextReader textReader = messageItem.Body.OpenTextReader(bodyFormat))
                    {
                        text = textReader.ReadToEnd();
                    }
                    Body body = (irmAction == SendMailBase.IrmAction.CreateNewPublishingLicenseInlineOriginalBody || irmAction == SendMailBase.IrmAction.ReusePublishingLicenseInlineOriginalBody) ? ((RightsManagedMessageItem)smartItem).ProtectedBody : smartItem.Body;
                    if (body.Format == Microsoft.Exchange.Data.Storage.BodyFormat.TextHtml)
                    {
                        if (bodyFormat == Microsoft.Exchange.Data.Storage.BodyFormat.TextPlain)
                        {
                            XmlDocument  xmlDocument  = new SafeXmlDocument();
                            XmlNode      xmlNode      = xmlDocument.CreateElement("PRE");
                            XmlAttribute xmlAttribute = xmlDocument.CreateAttribute("STYLE");
                            xmlAttribute.Value = "word-wrap:break-word; font-size:10.0pt; font-family:Tahoma; color:black";
                            xmlNode.Attributes.Append(xmlAttribute);
                            xmlNode.InnerText = text;
                            text = xmlNode.OuterXml;
                        }
                        bodyFormat = Microsoft.Exchange.Data.Storage.BodyFormat.TextHtml;
                    }
                }
                ReplyForwardConfiguration replyForwardConfiguration = new ReplyForwardConfiguration(bodyFormat);
                replyForwardConfiguration.ConversionOptionsForSmime = AirSyncUtility.GetInboundConversionOptions();
                replyForwardConfiguration.AddBodyPrefix(text);
                if (base.Version >= 120)
                {
                    if (smartItem is MessageItem)
                    {
                        messageItem2 = ((MessageItem)smartItem).CreateForward(defaultFolderId, replyForwardConfiguration);
                        if (irmAction == SendMailBase.IrmAction.CreateNewPublishingLicense || irmAction == SendMailBase.IrmAction.CreateNewPublishingLicenseInlineOriginalBody || irmAction == SendMailBase.IrmAction.CreateNewPublishingLicenseAttachOriginalMessage)
                        {
                            messageItem2 = base.GetRightsManagedReplyForward(messageItem2, irmAction, rmsTemplate);
                        }
                    }
                    else if (smartItem is CalendarItem)
                    {
                        CalendarItem calendarItem = (CalendarItem)smartItem;
                        calendarItemBase = base.GetCalendarItemBaseToReplyOrForward(calendarItem);
                        messageItem2     = calendarItemBase.CreateForward(defaultFolderId, replyForwardConfiguration);
                        if (!calendarItem.IsMeeting)
                        {
                            BodyConversionUtilities.CopyBody(messageItem, messageItem2);
                        }
                    }
                    if (messageItem2 == null)
                    {
                        base.ProtocolLogger.SetValue(ProtocolLoggerData.Error, "ForwardFailed");
                        throw new AirSyncPermanentException(HttpStatusCode.InternalServerError, StatusCode.MailSubmissionFailed, null, false);
                    }
                    if (base.ReplaceMime || irmAction == SendMailBase.IrmAction.CreateNewPublishingLicenseAttachOriginalMessage)
                    {
                        RightsManagedMessageItem rightsManagedMessageItem = messageItem2 as RightsManagedMessageItem;
                        if (rightsManagedMessageItem != null)
                        {
                            rightsManagedMessageItem.ProtectedAttachmentCollection.RemoveAll();
                        }
                        else
                        {
                            messageItem2.AttachmentCollection.RemoveAll();
                        }
                    }
                    base.CopyMessageContents(messageItem, messageItem2, false, (irmAction == SendMailBase.IrmAction.CreateNewPublishingLicenseAttachOriginalMessage) ? smartItem : null);
                    base.SendMessage(messageItem2);
                }
                else if (smartItem is MessageItem)
                {
                    using (ItemAttachment itemAttachment = messageItem.AttachmentCollection.AddExistingItem(smartItem))
                    {
                        MessageItem messageItem3 = (MessageItem)smartItem;
                        itemAttachment.FileName = messageItem3.Subject + itemAttachment.FileExtension;
                        itemAttachment.Save();
                    }
                    base.SendMessage(messageItem);
                }
                else if (smartItem is CalendarItem)
                {
                    CalendarItem calendarItem2 = (CalendarItem)smartItem;
                    messageItem2 = calendarItem2.CreateForward(defaultFolderId, replyForwardConfiguration);
                    if (messageItem2 == null)
                    {
                        base.ProtocolLogger.SetValue(ProtocolLoggerData.Error, "ForwardFailed2");
                        throw new AirSyncPermanentException(HttpStatusCode.InternalServerError, StatusCode.MailSubmissionFailed, null, false);
                    }
                    if (!calendarItem2.IsMeeting)
                    {
                        BodyConversionUtilities.CopyBody(messageItem, messageItem2);
                    }
                    base.CopyMessageContents(messageItem, messageItem2, false, null);
                    base.SendMessage(messageItem2);
                }
            }
            finally
            {
                if (messageItem != null)
                {
                    if (versionedId != null)
                    {
                        base.MailboxSession.Delete(DeleteItemFlags.HardDelete, new StoreId[]
                        {
                            versionedId
                        });
                    }
                    messageItem.Dispose();
                }
                if (smartItem != null)
                {
                    smartItem.Dispose();
                }
                if (messageItem2 != null)
                {
                    messageItem2.Dispose();
                }
                if (calendarItemBase != null)
                {
                    calendarItemBase.Dispose();
                }
            }
            return(Command.ExecutionState.Complete);
        }
コード例 #27
0
        // Token: 0x06001589 RID: 5513 RVA: 0x0007F070 File Offset: 0x0007D270
        internal override Command.ExecutionState ExecuteCommand()
        {
            MessageItem      clientMessage    = null;
            Item             item             = null;
            MessageItem      messageItem      = null;
            VersionedId      versionedId      = null;
            CalendarItemBase calendarItemBase = null;

            try
            {
                base.ValidateBody();
                StoreObjectId defaultFolderId = base.MailboxSession.GetDefaultFolderId(DefaultFolderType.Drafts);
                clientMessage = MessageItem.Create(base.MailboxSession, defaultFolderId);
                base.ParseMimeToMessage(clientMessage);
                clientMessage.Save(SaveMode.NoConflictResolution);
                clientMessage.Load();
                versionedId = clientMessage.Id;
                clientMessage.Dispose();
                clientMessage = MessageItem.Bind(base.MailboxSession, versionedId);
                item          = base.GetSmartItem();
                RmsTemplate            rmsTemplate = null;
                bool                   isReplyAll  = false;
                SendMailBase.IrmAction irmAction   = base.GetIrmAction(delegate(RightsManagedMessageItem originalRightsManagedItem)
                {
                    if (originalRightsManagedItem == null)
                    {
                        throw new ArgumentNullException("originalRightsManagedItem");
                    }
                    isReplyAll = this.IsIrmReplyAll(originalRightsManagedItem, clientMessage);
                }, ref item, out rmsTemplate);
                Microsoft.Exchange.Data.Storage.BodyFormat bodyFormat = clientMessage.Body.Format;
                MeetingMessage meetingMessage = item as MeetingMessage;
                string         text;
                if ((base.ReplaceMime || irmAction == SendMailBase.IrmAction.CreateNewPublishingLicenseAttachOriginalMessage) && meetingMessage != null && !meetingMessage.IsDelegated() && (meetingMessage is MeetingCancellation || meetingMessage is MeetingRequest))
                {
                    text = string.Empty;
                }
                else
                {
                    using (TextReader textReader = clientMessage.Body.OpenTextReader(bodyFormat))
                    {
                        text = textReader.ReadToEnd();
                    }
                    Body body = (irmAction == SendMailBase.IrmAction.CreateNewPublishingLicenseInlineOriginalBody || irmAction == SendMailBase.IrmAction.ReusePublishingLicenseInlineOriginalBody) ? ((RightsManagedMessageItem)item).ProtectedBody : item.Body;
                    if (body.Format == Microsoft.Exchange.Data.Storage.BodyFormat.TextHtml)
                    {
                        if (bodyFormat == Microsoft.Exchange.Data.Storage.BodyFormat.TextPlain)
                        {
                            XmlDocument  xmlDocument  = new SafeXmlDocument();
                            XmlNode      xmlNode      = xmlDocument.CreateElement("PRE");
                            XmlAttribute xmlAttribute = xmlDocument.CreateAttribute("STYLE");
                            xmlAttribute.Value = "word-wrap:break-word; font-size:10.0pt; font-family:Tahoma; color:black";
                            xmlNode.Attributes.Append(xmlAttribute);
                            xmlNode.InnerText = text;
                            text = xmlNode.OuterXml;
                        }
                        bodyFormat = Microsoft.Exchange.Data.Storage.BodyFormat.TextHtml;
                    }
                }
                ReplyForwardConfiguration replyForwardConfiguration = new ReplyForwardConfiguration(bodyFormat);
                replyForwardConfiguration.ConversionOptionsForSmime = AirSyncUtility.GetInboundConversionOptions();
                replyForwardConfiguration.AddBodyPrefix(text);
                if (item is MessageItem)
                {
                    MessageItem messageItem2 = (MessageItem)item;
                    if (!messageItem2.IsReplyAllowed)
                    {
                        base.ProtocolLogger.SetValue(ProtocolLoggerData.Error, "ReplyNotAllowed");
                        AirSyncPermanentException ex = new AirSyncPermanentException(HttpStatusCode.InternalServerError, StatusCode.MessageReplyNotAllowed, null, false);
                        throw ex;
                    }
                    if (isReplyAll)
                    {
                        messageItem = messageItem2.CreateReplyAll(defaultFolderId, replyForwardConfiguration);
                    }
                    else
                    {
                        messageItem = messageItem2.CreateReply(defaultFolderId, replyForwardConfiguration);
                    }
                    if (irmAction == SendMailBase.IrmAction.CreateNewPublishingLicense || irmAction == SendMailBase.IrmAction.CreateNewPublishingLicenseInlineOriginalBody || irmAction == SendMailBase.IrmAction.CreateNewPublishingLicenseAttachOriginalMessage)
                    {
                        messageItem = base.GetRightsManagedReplyForward(messageItem, irmAction, rmsTemplate);
                    }
                }
                else if (item is CalendarItem)
                {
                    CalendarItem item2 = (CalendarItem)item;
                    calendarItemBase = base.GetCalendarItemBaseToReplyOrForward(item2);
                    messageItem      = calendarItemBase.CreateReply(defaultFolderId, replyForwardConfiguration);
                }
                if (messageItem == null)
                {
                    base.ProtocolLogger.SetValue(ProtocolLoggerData.Error, "ReplyFailed");
                    throw new AirSyncPermanentException(HttpStatusCode.InternalServerError, StatusCode.MailSubmissionFailed, null, false);
                }
                base.CopyMessageContents(clientMessage, messageItem, true, (irmAction == SendMailBase.IrmAction.CreateNewPublishingLicenseAttachOriginalMessage) ? item : null);
                base.SendMessage(messageItem);
            }
            finally
            {
                if (clientMessage != null)
                {
                    if (versionedId != null)
                    {
                        base.MailboxSession.Delete(DeleteItemFlags.HardDelete, new StoreId[]
                        {
                            versionedId
                        });
                    }
                    clientMessage.Dispose();
                }
                if (item != null)
                {
                    item.Dispose();
                }
                if (messageItem != null)
                {
                    messageItem.Dispose();
                }
                if (calendarItemBase != null)
                {
                    calendarItemBase.Dispose();
                }
            }
            return(Command.ExecutionState.Complete);
        }
コード例 #28
0
 // Token: 0x060008C8 RID: 2248 RVA: 0x00034B7C File Offset: 0x00032D7C
 protected override void ProcessCommand(FolderCommand.FolderRequest folderRequest, XmlDocument doc)
 {
     if (FolderCommand.IsEmptyOrWhiteSpacesOnly(folderRequest.DisplayName))
     {
         base.ProtocolLogger.SetValue(ProtocolLoggerData.Error, "EmptyDisplayName");
         AirSyncPermanentException ex = new AirSyncPermanentException(StatusCode.Sync_NotificationGUID, base.ConstructErrorXml(StatusCode.Sync_NotificationGUID), null, false);
         throw ex;
     }
     using (Folder folder = Folder.Create(base.MailboxSession, folderRequest.ParentId, StoreObjectType.Folder))
     {
         string namespaceURI = doc.DocumentElement.NamespaceURI;
         folder.DisplayName = folderRequest.DisplayName;
         string classNameFromType = AirSyncUtility.GetClassNameFromType(folderRequest.Type);
         if (classNameFromType == null)
         {
             AirSyncPermanentException ex;
             if (!this.IsValidSpecialFolderType(base.Version, folderRequest.Type))
             {
                 base.ProtocolLogger.SetValue(ProtocolLoggerData.Error, "InvalidFolderType");
                 ex = new AirSyncPermanentException(StatusCode.Sync_NotificationGUID, base.ConstructErrorXml(StatusCode.Sync_NotificationGUID), null, false);
                 throw ex;
             }
             base.ProtocolLogger.SetValue(ProtocolLoggerData.Error, "CreateOfSpecialFolder");
             ex = new AirSyncPermanentException(StatusCode.Sync_InvalidSyncKey, base.ConstructErrorXml(StatusCode.Sync_InvalidSyncKey), null, false);
             throw ex;
         }
         else
         {
             folder.ClassName = classNameFromType;
             try
             {
                 folder.Save();
                 folder.Load();
             }
             catch (ObjectExistedException innerException)
             {
                 base.ProtocolLogger.SetValue(ProtocolLoggerData.Error, "FolderExistsOnCreate");
                 AirSyncPermanentException ex = new AirSyncPermanentException(StatusCode.Sync_ProtocolVersionMismatch, base.ConstructErrorXml(StatusCode.Sync_ProtocolVersionMismatch), innerException, false);
                 throw ex;
             }
             catch (InvalidOperationException innerException2)
             {
                 base.ProtocolLogger.SetValue(ProtocolLoggerData.Error, "InvalidOperationOnCreate");
                 AirSyncPermanentException ex = new AirSyncPermanentException(StatusCode.Sync_NotificationGUID, base.ConstructErrorXml(StatusCode.Sync_NotificationGUID), innerException2, false);
                 throw ex;
             }
             catch (ObjectValidationException innerException3)
             {
                 base.ProtocolLogger.SetValue(ProtocolLoggerData.Error, "ObjectValidationOnCreate");
                 AirSyncPermanentException ex = new AirSyncPermanentException(StatusCode.Sync_ProtocolVersionMismatch, base.ConstructErrorXml(StatusCode.Sync_ProtocolVersionMismatch), innerException3, false);
                 throw ex;
             }
             base.FolderHierarchySync.RecordClientOperation(folder.Id.ObjectId, ChangeType.Add, folder);
             folderRequest.RecoverySyncKey = folderRequest.SyncKey;
             folderRequest.SyncKey         = base.GetNextNumber(folderRequest.SyncKey);
             base.SyncStateChanged         = true;
             base.FolderHierarchySyncState[CustomStateDatumType.SyncKey]         = new Int32Data(folderRequest.SyncKey);
             base.FolderHierarchySyncState[CustomStateDatumType.RecoverySyncKey] = new Int32Data(folderRequest.RecoverySyncKey);
             XmlNode xmlNode = doc.CreateElement("Status", namespaceURI);
             xmlNode.InnerText = "1";
             XmlNode xmlNode2 = doc.CreateElement("SyncKey", namespaceURI);
             xmlNode2.InnerText = folderRequest.SyncKey.ToString(CultureInfo.InvariantCulture);
             XmlNode         xmlNode3        = doc.CreateElement("ServerId", namespaceURI);
             FolderIdMapping folderIdMapping = (FolderIdMapping)base.FolderIdMappingSyncState[CustomStateDatumType.IdMapping];
             ISyncItemId     syncItemId      = MailboxSyncItemId.CreateForNewItem(folder.Id.ObjectId);
             xmlNode3.InnerText = folderIdMapping.Add(syncItemId);
             folderIdMapping.CommitChanges();
             doc.DocumentElement.AppendChild(xmlNode);
             doc.DocumentElement.AppendChild(xmlNode2);
             doc.DocumentElement.AppendChild(xmlNode3);
             FolderTree folderTree = (FolderTree)base.FolderIdMappingSyncState[CustomStateDatumType.FullFolderTree];
             folderTree.AddFolder(syncItemId);
             if (!base.MailboxSession.GetDefaultFolderId(DefaultFolderType.Root).Equals(folderRequest.ParentId))
             {
                 ISyncItemId parentId = MailboxSyncItemId.CreateForNewItem(folderRequest.ParentId);
                 folderTree.LinkChildToParent(parentId, syncItemId);
             }
             base.ProtocolLogger.IncrementValue("F", PerFolderProtocolLoggerData.ClientAdds);
         }
     }
 }
コード例 #29
0
        internal static void HandlerCustomDataVersioning(FolderHierarchySyncState syncState)
        {
            if (syncState == null)
            {
                throw new ArgumentNullException("syncState");
            }
            if (syncState.CustomVersion == null)
            {
                return;
            }
            bool flag = true;

            if (syncState.CustomVersion < 2 || syncState.CustomVersion > 5)
            {
                flag = false;
            }
            else if (syncState.CustomVersion.Value != 5)
            {
                int valueOrDefault = syncState.CustomVersion.GetValueOrDefault();
                int?num;
                if (num != null)
                {
                    switch (valueOrDefault)
                    {
                    case 2:
                        syncState["RecoverySyncKey"] = new Int32Data(0);
                        break;

                    case 3:
                        break;

                    case 4:
                        goto IL_DD;

                    default:
                        goto IL_11E;
                    }
                    syncState[CustomStateDatumType.AirSyncProtocolVersion] = new ConstStringData(StaticStringPool.Instance.Intern("2.0"));
IL_DD:
                    object obj = syncState[CustomStateDatumType.AirSyncProtocolVersion];
                    if (obj is ConstStringData)
                    {
                        string data  = syncState.GetData <ConstStringData, string>(CustomStateDatumType.AirSyncProtocolVersion, null);
                        int    data2 = 20;
                        if (data != null)
                        {
                            data2 = AirSyncUtility.ParseVersionString(data);
                        }
                        syncState[CustomStateDatumType.AirSyncProtocolVersion] = new Int32Data(data2);
                        goto IL_120;
                    }
                    goto IL_120;
                }
IL_11E:
                flag = false;
            }
IL_120:
            if (!flag)
            {
                syncState.HandleCorruptSyncState();
            }
        }
コード例 #30
0
        // Token: 0x06000CE5 RID: 3301 RVA: 0x00045540 File Offset: 0x00043740
        private void ValidateRequestNodeData(XmlNode requestNode)
        {
            XmlNode xmlNode  = requestNode["UserResponse", "MeetingResponse:"];
            XmlNode xmlNode2 = requestNode["CollectionId", "MeetingResponse:"];
            XmlNode xmlNode3 = requestNode["RequestId", "MeetingResponse:"];
            XmlNode xmlNode4 = requestNode["LongId", "Search:"];
            XmlNode xmlNode5 = requestNode["InstanceId", "MeetingResponse:"];

            if (xmlNode4 != null)
            {
                if (string.IsNullOrEmpty(xmlNode4.InnerText))
                {
                    throw new RequestParsingException("longIdNode cannot be empty", "NoLongId");
                }
                if (xmlNode3 != null || xmlNode2 != null)
                {
                    throw new RequestParsingException("CollectionId/RequestId cannot be present when LongId supplied!", "TooManyIds");
                }
            }
            else
            {
                if (xmlNode3 == null || string.IsNullOrEmpty(xmlNode3.InnerText))
                {
                    throw new RequestParsingException("RequestIdNode cannot be missing or null", "NoRequestId");
                }
                if (xmlNode2 == null || string.IsNullOrEmpty(xmlNode2.InnerText) || (AirSyncUtility.GetCollectionType(xmlNode2.InnerText) != SyncCollection.CollectionTypes.Mailbox && AirSyncUtility.GetCollectionType(xmlNode2.InnerText) != SyncCollection.CollectionTypes.Unknown))
                {
                    throw new RequestParsingException("CollectionIdNode cannot be missing, null, or the collection type is other than mailbox or unknown.", "NoCollectionId");
                }
            }
            if (xmlNode == null || string.IsNullOrEmpty(xmlNode.InnerText) || (xmlNode.InnerText != "1" && xmlNode.InnerText != "2" && xmlNode.InnerText != "3"))
            {
                throw new RequestParsingException("UserResponseNode cannot be missing or null", "NoUserResponse");
            }
            if (xmlNode5 != null)
            {
                if (string.IsNullOrEmpty(xmlNode5.InnerText))
                {
                    throw new RequestParsingException("InstanceIdNode cannot be empty", "InvalidInstanceId");
                }
                if (base.Version >= 160)
                {
                    throw new RequestParsingException("InstanceIdNode is not supported", "InvalidInstanceId");
                }
            }
            MeetingResponseCommand.RequestNodeData requestNodeData;
            if (xmlNode4 != null)
            {
                requestNodeData = new MeetingResponseCommand.RequestNodeData(xmlNode, xmlNode4, xmlNode5);
                if (base.Version >= 160)
                {
                    requestNodeData.FillRespondToEventParameters(requestNode);
                }
                this.longIdRequests.Add(requestNodeData);
                return;
            }
            if (!this.shortIdRequests.ContainsKey(xmlNode2.InnerText))
            {
                this.shortIdRequests.Add(xmlNode2.InnerText, new List <MeetingResponseCommand.RequestNodeData>());
            }
            requestNodeData = new MeetingResponseCommand.RequestNodeData(xmlNode, xmlNode3, xmlNode5);
            if (base.Version >= 160)
            {
                requestNodeData.FillRespondToEventParameters(requestNode);
            }
            this.shortIdRequests[xmlNode2.InnerText].Add(requestNodeData);
        }