Example #1
0
        internal static XmlNode GenerateQueryCAML(QueryFilter query)
        {
            XmlDocument xmlDocument = new SafeXmlDocument();
            XmlNode     xmlNode     = xmlDocument.CreateElement("Query");

            if (query != null)
            {
                xmlNode.AppendChild(xmlDocument.CreateElement("Where"));
                xmlNode.ChildNodes[0].AppendChild(SharepointHelpers.GenerateQueryCAMLHelper(query, xmlDocument, 0));
            }
            return(xmlNode);
        }
Example #2
0
        // Token: 0x06000493 RID: 1171 RVA: 0x0001C3D8 File Offset: 0x0001A5D8
        internal static XmlDocument ConstructErrorXml(StatusCode statusCode)
        {
            XmlDocument xmlDocument = new SafeXmlDocument();
            XmlNode     xmlNode     = xmlDocument.CreateElement("Response", "FolderHierarchy:");
            XmlNode     xmlNode2    = xmlDocument.CreateElement("Status", "FolderHierarchy:");
            XmlNode     xmlNode3    = xmlNode2;
            int         num         = (int)statusCode;

            xmlNode3.InnerText = num.ToString(CultureInfo.InvariantCulture);
            xmlDocument.AppendChild(xmlNode);
            xmlNode.AppendChild(xmlNode2);
            return(xmlDocument);
        }
        // Token: 0x06000885 RID: 2181 RVA: 0x00032498 File Offset: 0x00030698
        internal XmlDocument ConstructErrorXml(StatusCode statusCode)
        {
            base.ProtocolLogger.SetValue(ProtocolLoggerData.StatusCode, (int)statusCode);
            XmlDocument xmlDocument = new SafeXmlDocument();
            XmlNode     xmlNode     = xmlDocument.CreateElement(this.CommandXmlTag, "FolderHierarchy:");
            XmlNode     xmlNode2    = xmlDocument.CreateElement("Status", "FolderHierarchy:");
            XmlNode     xmlNode3    = xmlNode2;
            int         num         = (int)statusCode;

            xmlNode3.InnerText = num.ToString(CultureInfo.InvariantCulture);
            xmlDocument.AppendChild(xmlNode);
            xmlNode.AppendChild(xmlNode2);
            return(xmlDocument);
        }
Example #4
0
        // Token: 0x06000261 RID: 609 RVA: 0x0000837C File Offset: 0x0000657C
        internal XmlDocument ReadXmlDocument()
        {
            this.ReadHeader();
            XmlDocument result;

            try
            {
                bool   flag;
                bool   flag2;
                int    tag       = this.ReadTag(out flag, out flag2);
                string name      = WBXmlBase.Schema.GetName(tag);
                string nameSpace = WBXmlBase.Schema.GetNameSpace(tag);
                if (name == null || nameSpace == null)
                {
                    result = WBXmlReader.ErrorDocument;
                }
                else
                {
                    XmlDocument xmlDocument = new SafeXmlDocument();
                    bool        flag3       = WBXmlBase.Schema.IsTagSecure(tag);
                    bool        flag4       = WBXmlBase.Schema.IsTagAnOpaqueBlob(tag);
                    XmlElement  xmlElement;
                    if (flag3)
                    {
                        xmlElement = new WBXmlSecureStringNode(null, name, nameSpace, xmlDocument);
                    }
                    else if (flag4)
                    {
                        xmlElement = new WBxmlBlobNode(null, name, nameSpace, xmlDocument);
                    }
                    else
                    {
                        xmlElement = xmlDocument.CreateElement(name, nameSpace);
                    }
                    xmlDocument.AppendChild(xmlElement);
                    if (flag)
                    {
                        this.SkipAttributes();
                    }
                    if (flag2 && !this.FillXmlElement(xmlElement, 0, flag3, flag4))
                    {
                        result = WBXmlReader.ErrorDocument;
                    }
                    else
                    {
                        result = xmlDocument;
                    }
                }
            }
            catch (IndexOutOfRangeException innerException)
            {
                throw new EasWBXmlTransientException("Invalid WBXML code/codepage from client", innerException);
            }
            catch (ArgumentOutOfRangeException innerException2)
            {
                throw new EasWBXmlTransientException("Invalid WBXML code from client", innerException2);
            }
            return(result);
        }
Example #5
0
        // Token: 0x06000CE1 RID: 3297 RVA: 0x00044C34 File Offset: 0x00042E34
        internal XmlDocument InitializeXmlResponse()
        {
            XmlDocument xmlDocument = new SafeXmlDocument();

            this.meetingResponseNode = xmlDocument.CreateElement("MeetingResponse", "MeetingResponse:");
            xmlDocument.AppendChild(this.meetingResponseNode);
            return(xmlDocument);
        }
Example #6
0
        // Token: 0x06000C2E RID: 3118 RVA: 0x0003FCD4 File Offset: 0x0003DED4
        private XmlDocument BuildXmlResponse(string statusCode)
        {
            XmlDocument xmlDocument = new SafeXmlDocument();
            XmlNode     xmlNode     = xmlDocument.CreateElement("ItemOperations", "ItemOperations:");

            xmlDocument.AppendChild(xmlNode);
            XmlNode xmlNode2 = xmlDocument.CreateElement("Status", "ItemOperations:");

            xmlNode2.InnerText = statusCode;
            xmlNode.AppendChild(xmlNode2);
            this.responseNode = xmlDocument.CreateElement("Response", "ItemOperations:");
            if (statusCode == 1.ToString(CultureInfo.InvariantCulture))
            {
                xmlNode.AppendChild(this.responseNode);
            }
            return(xmlDocument);
        }
        // Token: 0x06000D07 RID: 3335 RVA: 0x00046F88 File Offset: 0x00045188
        private XmlDocument InitializeXmlResponse()
        {
            XmlDocument xmlDocument = new SafeXmlDocument();

            this.moveitemsNode = xmlDocument.CreateElement("MoveItems", "Move:");
            xmlDocument.AppendChild(this.moveitemsNode);
            return(xmlDocument);
        }
Example #8
0
        internal static XmlNode GenerateViewFieldCAML(Schema schema, ICollection <PropertyDefinition> propertyDefinitions)
        {
            XmlDocument xmlDocument = new SafeXmlDocument();
            XmlNode     xmlNode     = xmlDocument.CreateElement("ViewFields");

            foreach (SharepointPropertyDefinition sharepointPropertyDefinition in SharepointPropertyDefinition.PropertyDefinitionsToSharepointPropertyDefinitions(schema, propertyDefinitions))
            {
                if (sharepointPropertyDefinition != null)
                {
                    XmlNode xmlNode2 = xmlDocument.CreateElement("FieldRef");
                    xmlNode2.Attributes.Append(xmlDocument.CreateAttribute("Name"));
                    xmlNode2.Attributes["Name"].Value = sharepointPropertyDefinition.SharepointName;
                    xmlNode.AppendChild(xmlNode2);
                }
            }
            return(xmlNode);
        }
Example #9
0
        static SharepointHelpers()
        {
            SharepointHelpers.SharepointNamespaceManager = new XmlNamespaceManager(new NameTable());
            SharepointHelpers.SharepointNamespaceManager.AddNamespace("sp", "http://schemas.microsoft.com/sharepoint/soap/");
            SharepointHelpers.SharepointNamespaceManager.AddNamespace("rs", "urn:schemas-microsoft-com:rowset");
            SharepointHelpers.SharepointNamespaceManager.AddNamespace("z", "#RowsetSchema");
            XmlDocument xmlDocument = new SafeXmlDocument();

            SharepointHelpers.DefaultQueryOptions = xmlDocument.CreateElement("QueryOptions");
            XmlNode xmlNode = xmlDocument.CreateElement("DateInUtc");

            xmlNode.InnerText = "TRUE";
            SharepointHelpers.DefaultQueryOptions.AppendChild(xmlNode);
            xmlNode           = xmlDocument.CreateElement("IncludeMandatoryColumns");
            xmlNode.InnerText = "TRUE";
            SharepointHelpers.DefaultQueryOptions.AppendChild(xmlNode);
        }
Example #10
0
        private XmlDocument BuildXmlResponse()
        {
            XmlDocument xmlDocument = new SafeXmlDocument();
            XmlNode     xmlNode     = xmlDocument.CreateElement("Search", "Search:");

            xmlDocument.AppendChild(xmlNode);
            XmlNode xmlNode2 = xmlDocument.CreateElement("Status", "Search:");

            xmlNode2.InnerText = 1.ToString(CultureInfo.InvariantCulture);
            xmlNode.AppendChild(xmlNode2);
            XmlNode xmlNode3 = xmlDocument.CreateElement("Response", "Search:");

            xmlNode.AppendChild(xmlNode3);
            this.respStoreNode = xmlDocument.CreateElement("Store", "Search:");
            xmlNode3.AppendChild(this.respStoreNode);
            return(xmlDocument);
        }
Example #11
0
        protected override void InternalProcessRecord()
        {
            TaskLogger.LogEnter();
            string text = null;

            try
            {
                string text2 = "Exchange-" + this.ShortNameForRole + ".xml";
                string text3 = Path.Combine(ConfigurationContext.Setup.BinPath, text2);
                string text4 = Path.Combine(ConfigurationContext.Setup.SetupLoggingPath, this.ShortNameForRole + "Prereqs.log");
                string text5 = text3;
                if (this.ADToolsNeeded)
                {
                    SafeXmlDocument safeXmlDocument = new SafeXmlDocument();
                    safeXmlDocument.Load(text3);
                    XmlNode    documentElement = safeXmlDocument.DocumentElement;
                    XmlElement xmlElement      = safeXmlDocument.CreateElement("Feature", documentElement.NamespaceURI);
                    xmlElement.SetAttribute("Id", "RSAT-ADDS");
                    documentElement.AppendChild(xmlElement);
                    string text6 = Path.Combine(ConfigurationContext.Setup.SetupLoggingPath, "temp" + text2);
                    safeXmlDocument.Save(text6);
                    text5 = text6;
                    text  = text6;
                }
                base.Args = string.Concat(new string[]
                {
                    "-inputPath \"",
                    text5,
                    "\" -logPath \"",
                    text4,
                    "\""
                });
                base.InternalProcessRecord();
            }
            catch (IOException exception)
            {
                base.WriteError(exception, ErrorCategory.InvalidOperation, null);
            }
            catch (UnauthorizedAccessException exception2)
            {
                base.WriteError(exception2, ErrorCategory.SecurityError, null);
            }
            finally
            {
                if (text != null)
                {
                    try
                    {
                        File.Delete(text);
                    }
                    catch
                    {
                    }
                }
            }
            TaskLogger.LogExit();
        }
Example #12
0
        private XmlDocument CreateXmlDocument()
        {
            XmlDocument xmlDocument = new SafeXmlDocument();

            xmlDocument.InsertBefore(xmlDocument.CreateXmlDeclaration("1.0", "utf-8", null), xmlDocument.DocumentElement);
            xmlDocument.AppendChild(xmlDocument.CreateElement("configuration"));
            XmlElement xmlElement = xmlDocument.CreateElement("mexRuntime");

            xmlDocument.DocumentElement.PrependChild(xmlElement);
            XmlElement xmlElement2 = xmlDocument.CreateElement("monitoring");

            xmlElement.AppendChild(xmlElement2);
            XmlElement xmlElement3 = xmlDocument.CreateElement("agentExecution");

            xmlElement3.SetAttribute("timeLimitInMilliseconds", this.monitoringOptions.AgentExecutionLimitInMilliseconds.ToString(CultureInfo.InvariantCulture));
            xmlElement2.AppendChild(xmlElement3);
            if (!this.monitoringOptions.MessageSnapshotEnabled)
            {
                XmlElement xmlElement4 = xmlDocument.CreateElement("messageSnapshot");
                xmlElement4.SetAttribute("enabled", "false");
                xmlElement2.AppendChild(xmlElement4);
            }
            XmlElement xmlElement5 = xmlDocument.CreateElement("agentList");

            xmlElement.AppendChild(xmlElement5);
            foreach (AgentInfo agentInfo in this.agentList)
            {
                if (!agentInfo.IsInternal)
                {
                    XmlElement xmlElement6 = xmlDocument.CreateElement("agent");
                    xmlElement6.SetAttribute("name", agentInfo.AgentName);
                    xmlElement6.SetAttribute("baseType", agentInfo.BaseTypeName);
                    xmlElement6.SetAttribute("classFactory", agentInfo.FactoryTypeName);
                    xmlElement6.SetAttribute("assemblyPath", agentInfo.FactoryAssemblyPath);
                    xmlElement6.SetAttribute("enabled", agentInfo.Enabled.ToString().ToLower(CultureInfo.InvariantCulture));
                    xmlElement5.AppendChild(xmlElement6);
                }
            }
            XmlElement xmlElement7 = xmlDocument.CreateElement("settings");

            if (!this.disposeAgents)
            {
                XmlElement xmlElement8 = xmlDocument.CreateElement("disposeAgents");
                xmlElement8.InnerText = "false";
                xmlElement7.AppendChild(xmlElement8);
            }
            xmlElement.AppendChild(xmlElement7);
            return(xmlDocument);
        }
        private void SetTimeZoneDefinitionHeader(Service service)
        {
            XmlDocument        xmlDocument        = new SafeXmlDocument();
            XmlElement         xmlElement         = xmlDocument.CreateElement("TimeZoneDefinitionType", "http://schemas.microsoft.com/exchange/services/2006/types");
            TimeZoneDefinition timeZoneDefinition = new TimeZoneDefinition(this.clientContext.TimeZone);

            timeZoneDefinition.Render(xmlElement, "ext", "http://schemas.microsoft.com/exchange/services/2006/types", "TimeZoneDefinition", true, this.clientContext.ClientCulture ?? CultureInfo.InvariantCulture);
            service.TimeZoneDefinitionContextValue = new TimeZoneContext();
            service.TimeZoneDefinitionContextValue.TimeZoneDefinitionValue = (xmlElement.FirstChild as XmlElement);
        }
        // Token: 0x060009C0 RID: 2496 RVA: 0x00039620 File Offset: 0x00037820
        private XmlDocument CreateXmlResponse(object[][] folders)
        {
            XmlDocument xmlDocument = new SafeXmlDocument();
            XmlElement  xmlElement  = xmlDocument.CreateElement("Folders", "FolderHierarchy:");

            xmlDocument.AppendChild(xmlElement);
            for (int i = 0; i < folders.Length; i++)
            {
                this.WriteFolderXml(xmlDocument, xmlElement, folders[i]);
            }
            return(xmlDocument);
        }
        public static XmlElement Encrypt(SmtpAddress externalId, SymmetricSecurityKey symmetricSecurityKey)
        {
            XmlDocument xmlDocument = new SafeXmlDocument();
            XmlElement  xmlElement  = xmlDocument.CreateElement("SharingKey");

            xmlElement.InnerText = externalId.ToString();
            EncryptedXml encryptedXml = new EncryptedXml();

            encryptedXml.AddKeyNameMapping("key", symmetricSecurityKey.GetSymmetricAlgorithm("http://www.w3.org/2001/04/xmlenc#tripledes-cbc"));
            EncryptedData encryptedData = encryptedXml.Encrypt(xmlElement, "key");

            return(encryptedData.GetXml());
        }
Example #16
0
        private XmlNode CreateChild(SafeXmlDocument xmlDoc, XmlNode parentNode, string childName)
        {
            string name = childName;
            int    num  = childName.IndexOf("[");

            if (num >= 0)
            {
                name = childName.Substring(0, num);
            }
            XmlNode xmlNode    = xmlDoc.CreateElement(name);
            XmlNode firstChild = parentNode.FirstChild;

            if (this.InsertAsFirst && firstChild != null)
            {
                parentNode.InsertBefore(xmlNode, firstChild);
            }
            else
            {
                parentNode.AppendChild(xmlNode);
            }
            return(xmlNode);
        }
Example #17
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);
        }
 protected override void InternalProcessRecord()
 {
     base.InternalProcessRecord();
     try
     {
         ResultCode?result = null;
         using (OnboardingService onboardingService = new MsoOnboardingService())
         {
             ServiceInstanceInfoValue serviceInstanceInfoValue = onboardingService.GetServiceInstanceInfo(this.Identity.ToString());
             if (serviceInstanceInfoValue == null)
             {
                 serviceInstanceInfoValue = new ServiceInstanceInfoValue();
             }
             bool flag = false;
             if (serviceInstanceInfoValue.Endpoint != null)
             {
                 foreach (ServiceEndpointValue serviceEndpointValue in serviceInstanceInfoValue.Endpoint)
                 {
                     if (string.Compare(serviceEndpointValue.Name, "BackSyncPSConnectionURI", true) == 0)
                     {
                         flag = true;
                         serviceEndpointValue.Address = this.BackSyncUrl.ToString();
                         break;
                     }
                 }
             }
             else
             {
                 serviceInstanceInfoValue.Endpoint = new ServiceEndpointValue[0];
             }
             if (!flag)
             {
                 ServiceEndpointValue serviceEndpointValue2 = new ServiceEndpointValue();
                 serviceEndpointValue2.Name    = "BackSyncPSConnectionURI";
                 serviceEndpointValue2.Address = this.BackSyncUrl.ToString();
                 int num = serviceInstanceInfoValue.Endpoint.Length + 1;
                 ServiceEndpointValue[] array = new ServiceEndpointValue[num];
                 serviceInstanceInfoValue.Endpoint.CopyTo(array, 0);
                 array[num - 1] = serviceEndpointValue2;
                 serviceInstanceInfoValue.Endpoint = array;
             }
             if (this.SupportsAuthorityTransfer)
             {
                 bool flag2 = false;
                 if (serviceInstanceInfoValue.Any != null)
                 {
                     foreach (XmlElement xmlElement in serviceInstanceInfoValue.Any)
                     {
                         if (string.Compare(xmlElement.Name, "SupportsAuthorityTransfer", true) == 0)
                         {
                             flag2 = true;
                             break;
                         }
                     }
                 }
                 else
                 {
                     serviceInstanceInfoValue.Any = new XmlElement[0];
                 }
                 if (!flag2)
                 {
                     XmlDocument  xmlDocument = new SafeXmlDocument();
                     XmlElement   xmlElement2 = xmlDocument.CreateElement("SupportsAuthorityTransfer", "http://schemas.microsoft.com/online/directoryservices/exchange/2011/01");
                     int          num2        = serviceInstanceInfoValue.Any.Length + 1;
                     XmlElement[] array2      = new XmlElement[num2];
                     serviceInstanceInfoValue.Any.CopyTo(array2, 0);
                     array2[num2 - 1]             = xmlElement2;
                     serviceInstanceInfoValue.Any = array2;
                 }
             }
             else if (serviceInstanceInfoValue.Any != null)
             {
                 XmlElement[] array3 = new XmlElement[0];
                 foreach (XmlElement xmlElement3 in serviceInstanceInfoValue.Any)
                 {
                     if (string.Compare(xmlElement3.Name, "SupportsAuthorityTransfer", true) != 0)
                     {
                         Array.Resize <XmlElement>(ref array3, array3.Length + 1);
                         array3[array3.Length - 1] = xmlElement3;
                     }
                 }
                 serviceInstanceInfoValue.Any = array3;
             }
             result = new ResultCode?(onboardingService.SetServiceInstanceInfo(this.Identity.ToString(), serviceInstanceInfoValue));
             if (result == null || result.Value != ResultCode.Success)
             {
                 string errorStringForResultcode = MsoOnboardingService.GetErrorStringForResultcode(result);
                 this.WriteError(new CouldNotUpdateServiceInstanceMapException(errorStringForResultcode), ErrorCategory.InvalidData, null, true);
             }
         }
     }
     catch (CouldNotCreateMsoOnboardingServiceException exception)
     {
         this.WriteError(exception, ErrorCategory.ObjectNotFound, null, true);
     }
     catch (InvalidServiceInstanceMapXmlFormatException exception2)
     {
         this.WriteError(exception2, ErrorCategory.InvalidData, null, true);
     }
     catch (Exception exception3)
     {
         this.WriteError(exception3, ErrorCategory.InvalidOperation, null, true);
     }
 }
        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);
        }
 // Token: 0x06000886 RID: 2182 RVA: 0x00032504 File Offset: 0x00030704
 internal override Command.ExecutionState ExecuteCommand()
 {
     try
     {
         FolderCommand.FolderRequest folderRequest = this.ParseRequest();
         XmlDocument xmlDocument = new SafeXmlDocument();
         XmlNode     newChild    = xmlDocument.CreateElement(base.XmlRequest.LocalName, base.XmlRequest.NamespaceURI);
         xmlDocument.AppendChild(newChild);
         try
         {
             base.ProtocolLogger.SetValue("F", PerFolderProtocolLoggerData.ClientSyncKey, folderRequest.SyncKey);
             this.LoadSyncState(folderRequest.SyncKey);
             this.ConvertSyncIdsToXsoIds(folderRequest);
             this.folderHierarchySync = this.folderHierarchySyncState.GetFolderHierarchySync(new ChangeTrackingDelegate(FolderCommand.ComputeChangeTrackingHash));
             if (folderRequest.SyncKey != 0)
             {
                 if (!this.folderHierarchySyncState.Contains(CustomStateDatumType.SyncKey))
                 {
                     base.ProtocolLogger.SetValue("F", PerFolderProtocolLoggerData.SyncType, "I");
                     base.ProtocolLogger.SetValue(ProtocolLoggerData.Error, "RecoveryNotAllowed");
                     throw new AirSyncPermanentException(StatusCode.Sync_OutOfDisk, this.ConstructErrorXml(StatusCode.Sync_OutOfDisk), null, false);
                 }
                 int data  = this.folderHierarchySyncState.GetData <Int32Data, int>(CustomStateDatumType.SyncKey, -1);
                 int data2 = this.folderHierarchySyncState.GetData <Int32Data, int>(CustomStateDatumType.RecoverySyncKey, -1);
                 if (folderRequest.SyncKey != data && (!this.allowRecovery || folderRequest.SyncKey != data2))
                 {
                     base.ProtocolLogger.SetValue("F", PerFolderProtocolLoggerData.SyncType, "I");
                     base.ProtocolLogger.SetValue(ProtocolLoggerData.Error, "InvalidSyncKey");
                     throw new AirSyncPermanentException(StatusCode.Sync_OutOfDisk, this.ConstructErrorXml(StatusCode.Sync_OutOfDisk), null, false);
                 }
                 FolderIdMapping folderIdMapping = (FolderIdMapping)this.folderIdMappingSyncState[CustomStateDatumType.IdMapping];
                 if (folderRequest.SyncKey == data)
                 {
                     AirSyncDiagnostics.TraceDebug(ExTraceGlobals.RequestsTracer, this, "Committing folderIdMapping.");
                     base.ProtocolLogger.SetValue("F", PerFolderProtocolLoggerData.SyncType, "S");
                     folderIdMapping.CommitChanges();
                     this.folderHierarchySync.AcknowledgeServerOperations();
                 }
                 else
                 {
                     AirSyncDiagnostics.TraceDebug(ExTraceGlobals.RequestsTracer, this, "Clearing changes on folderIdMapping.");
                     base.ProtocolLogger.SetValue("F", PerFolderProtocolLoggerData.SyncType, "R");
                     folderIdMapping.ClearChanges();
                     this.folderIdMappingSyncState[CustomStateDatumType.FullFolderTree] = this.folderIdMappingSyncState[CustomStateDatumType.RecoveryFullFolderTree];
                 }
             }
             else
             {
                 base.ProtocolLogger.SetValue("F", PerFolderProtocolLoggerData.SyncType, "F");
                 base.SendServerUpgradeHeader = true;
             }
             this.ProcessCommand(folderRequest, xmlDocument);
             if (this.folderHierarchySyncState != null)
             {
                 int data3 = this.folderHierarchySyncState.GetData <Int32Data, int>(CustomStateDatumType.AirSyncProtocolVersion, -1);
                 if (base.Version > data3)
                 {
                     AirSyncDiagnostics.TraceDebug <int, int>(ExTraceGlobals.RequestsTracer, this, "Changing sync state protocol version from {0} to {1}.", data3, base.Version);
                     this.folderHierarchySyncState[CustomStateDatumType.AirSyncProtocolVersion] = new Int32Data(base.Version);
                     this.syncStateChanged = true;
                 }
             }
             if (this.syncStateChanged)
             {
                 if (this.folderHierarchySyncState != null)
                 {
                     this.folderHierarchySyncState.CustomVersion = new int?(5);
                     this.folderHierarchySyncState.Commit();
                 }
                 if (this.folderIdMappingSyncState != null)
                 {
                     FolderIdMapping folderIdMapping2 = this.folderIdMappingSyncState[CustomStateDatumType.IdMapping] as FolderIdMapping;
                     FolderTree      folderTree       = this.folderIdMappingSyncState[CustomStateDatumType.FullFolderTree] as FolderTree;
                     if (folderIdMapping2.IsDirty || folderTree.IsDirty)
                     {
                         this.folderIdMappingSyncState.Commit();
                     }
                 }
             }
         }
         finally
         {
             if (this.folderIdMappingSyncState != null)
             {
                 this.folderIdMappingSyncState.Dispose();
             }
             if (this.folderHierarchySyncState != null)
             {
                 this.folderHierarchySyncState.Dispose();
             }
         }
         base.XmlResponse = xmlDocument;
     }
     catch (ObjectNotFoundException innerException)
     {
         base.ProtocolLogger.SetValue(ProtocolLoggerData.Error, "FolderNotFound");
         throw new AirSyncPermanentException(StatusCode.Sync_ProtocolError, this.ConstructErrorXml(StatusCode.Sync_ProtocolError), innerException, false);
     }
     catch (CorruptDataException ex)
     {
         AirSyncUtility.ExceptionToStringHelper arg = new AirSyncUtility.ExceptionToStringHelper(ex);
         base.ProtocolLogger.SetValue(ProtocolLoggerData.Error, "CorruptData");
         AirSyncDiagnostics.TraceDebug <AirSyncUtility.ExceptionToStringHelper>(ExTraceGlobals.RequestsTracer, this, "Corrupted data found, replacing error with wrongsynckey error to force client to refresh.\r\n{0}", arg);
         throw new AirSyncPermanentException(StatusCode.Sync_OutOfDisk, this.ConstructErrorXml(StatusCode.Sync_OutOfDisk), ex, false);
     }
     catch (QuotaExceededException)
     {
         throw;
     }
     catch (StoragePermanentException ex2)
     {
         base.ProtocolLogger.SetValue(ProtocolLoggerData.Error, ex2.GetType().ToString());
         throw new AirSyncPermanentException(StatusCode.Sync_ClientServerConversion, this.ConstructErrorXml(StatusCode.Sync_ClientServerConversion), ex2, false);
     }
     catch (ArgumentException innerException2)
     {
         base.ProtocolLogger.SetValue(ProtocolLoggerData.Error, "ArgumentException");
         throw new AirSyncPermanentException(StatusCode.Sync_NotificationGUID, this.ConstructErrorXml(StatusCode.Sync_NotificationGUID), innerException2, false);
     }
     catch (FormatException innerException3)
     {
         base.ProtocolLogger.SetValue(ProtocolLoggerData.Error, "FormatException");
         throw new AirSyncPermanentException(StatusCode.Sync_NotificationGUID, this.ConstructErrorXml(StatusCode.Sync_NotificationGUID), innerException3, false);
     }
     return(Command.ExecutionState.Complete);
 }