A class that implements ROP parsing and supports ROP buffer transmission between client and server.
 /// <summary>
 /// Overrides IAdapter's Initialize method, to set testSite.DefaultProtocolDocShortName.
 /// </summary>
 /// <param name="testSite">Transfer ITestSite into adapter, make adapter can use ITestSite's function.</param>
 public override void Initialize(ITestSite testSite)
 {
     base.Initialize(testSite);
     Site.DefaultProtocolDocShortName = "MS-OXCFOLD";
     Common.MergeConfiguration(testSite);
     this.oxcropsClient = new OxcropsClient(MapiContext.GetDefaultRpcContext(this.Site));
 }
        /// <summary>
        /// Initialize the adapter.
        /// </summary>
        /// <param name="testSite">Test site.</param>
        public override void Initialize(ITestSite testSite)
        {
            base.Initialize(testSite);
            Site.DefaultProtocolDocShortName = "MS-OXCPERM";
            Common.MergeConfiguration(testSite);

            // Initialize OxcropsClient instance for logon user.
            this.oxcropsClient = new OxcropsClient(MapiContext.GetDefaultRpcContext(this.Site));
        }
        /// <summary>
        /// Initialize the adapter.
        /// </summary>
        /// <param name="testSite">Test site.</param>
        public override void Initialize(ITestSite testSite)
        {
            base.Initialize(testSite);
            testSite.DefaultProtocolDocShortName = "MS-OXCPRPT";
            if (!commonConfigImported)
            {
                Common.MergeConfiguration(testSite);

                commonConfigImported = true;
            }

            this.oxcropsClient = new OxcropsClient(MapiContext.GetDefaultRpcContext(this.Site));
            this.oxcropsClientSession2 = new OxcropsClient(MapiContext.GetDefaultRpcContext(this.Site));
        }
        /// <summary>
        /// Session get property value via RopReadStream.
        /// </summary>
        /// <param name="objKey">String key to Indicates which object to be acted on.</param>
        /// <param name="propertyTag">Property Tag.</param>
        /// <param name="isPropertyFound">Indicates whether the property exists.</param>
        /// <returns>Property value in a stream.</returns>
        private byte[] Session2ReadStream(string objKey, PropertyTag propertyTag, out bool isPropertyFound)
        {
            Dictionary<string, uint> objHandles = new Dictionary<string, uint>();
            uint logonHandle;
            uint folderHandle1;
            uint folderHandle2;
            uint msgHandle1;
            uint msgHandle2;
            uint attachmentHandle1;
            uint attachmentHandle2;

            OxcropsClient tempClient = this.oxcropsClient;
            this.oxcropsClient = this.oxcropsClientSession2;

            try
            {
                #region Preparation for getting object handles
                RopLogonResponse logonRes;
                RopOpenFolderResponse openFolderRes;
                RopOpenMessageResponse openMsgRes;
                RopOpenAttachmentResponse openAttRes;

                // Logon to mailbox.
                logonHandle = this.RopLogon(LogonType.Mailbox, out logonRes, Common.GetConfigurationPropertyValue("UserEssdn", this.Site), true);
                objHandles.Add("Logon", logonHandle);

                // Open inbox folder.
                uint inboxHandle = this.RopOpenFolder(logonHandle, out openFolderRes, logonRes.FolderIds[4], true);

                // Open testRoot folder.
                uint testRootHandle = this.RopOpenFolder(inboxHandle, out openFolderRes, rootFolderId, true);

                // Open testFolder1.
                folderHandle1 = this.RopOpenFolder(testRootHandle, out openFolderRes, cprptFolderId[0], true);
                objHandles.Add("Folder1", folderHandle1);

                // Open testFolder2.
                folderHandle2 = this.RopOpenFolder(testRootHandle, out openFolderRes, cprptFolderId[1], true);
                objHandles.Add("Folder2", folderHandle2);

                // For first folder open message1.
                msgHandle1 = this.RopOpenMessage(folderHandle1, cprptFolderId[0], cprptMessageId[0], out openMsgRes, true);
                objHandles.Add("Message1", msgHandle1);

                // For first folder open message2.
                msgHandle2 = this.RopOpenMessage(folderHandle1, cprptFolderId[0], cprptMessageId[1], out openMsgRes, true);
                objHandles.Add("Message2", msgHandle2);

                // For first message open attachment1.
                attachmentHandle1 = this.RopOpenAttachment(msgHandle1, cprptAttachmentId[0], out openAttRes, true);
                objHandles.Add("Attachment1", attachmentHandle1);

                // For first message open attachment2.
                attachmentHandle2 = this.RopOpenAttachment(msgHandle1, cprptAttachmentId[1], out openAttRes, true);
                objHandles.Add("Attachment2", attachmentHandle2);
                #endregion

                if (!objHandles.ContainsKey(objKey))
                {
                    this.oxcropsClient = tempClient;
                    Site.Assert.Fail("Invalid Object key for getting its Property value");
                }

                uint objHandle = objHandles[objKey];

                RopGetPropertiesAllResponse getAllRes;
                getAllRes = this.RopGetPropertiesAll(objHandle, 0, 0);
                foreach (TaggedPropertyValue taggedValue in getAllRes.PropertyValues)
                {
                    if (taggedValue.PropertyTag.PropertyId == propertyTag.PropertyId)
                    {
                        isPropertyFound = true;

                        // Open stream.
                        RopOpenStreamResponse openStreamRes;
                        uint streamHandle = this.RopOpenStream(objHandle, out openStreamRes, propertyTag, ConstValues.OpenModeFlagsReadWrite, true);

                        // Read stream.
                        RopReadStreamResponse readStreamRes;
                        readStreamRes = this.RopReadStream(streamHandle, ConstValues.StreamLengthByteCountIndicator, 0x70000000, true);
                        return readStreamRes.Data;
                    }
                }

                isPropertyFound = false;
                return new byte[0];
            }
            catch (System.IO.IOException exception)
            {
                this.Site.Log.Add(LogEntryKind.Comment, exception.Message);
                isPropertyFound = false;
                return null;
            }
            finally
            {
                this.oxcropsClient = tempClient;
            }
        }
        /// <summary>
        /// Obtain Property value via session2.
        /// </summary>
        /// <param name="objKey">String key to Indicates which object to be acted on.</param>
        /// <param name="propertyTag">Property Tag.</param>
        /// <param name="isPropertyFound">Indicates whether the property exists.</param>
        /// <returns>Property value.</returns>
        private byte[] Session2GetPropertyData(string objKey, PropertyTag propertyTag, out bool isPropertyFound)
        {
            Dictionary<string, uint> objHandles = new Dictionary<string, uint>();
            uint logonHandle;
            uint folderHandle1;
            uint folderHandle2;
            uint msgHandle1;
            uint msgHandle2;
            uint attachmentHandle1;
            uint attachmentHandle2;

            OxcropsClient tempClient = this.oxcropsClient;
            this.oxcropsClient = this.oxcropsClientSession2;

            #region Preparation for getting object handles
            RopLogonResponse logonRes;
            RopOpenFolderResponse openFolderRes;
            RopOpenMessageResponse openMsgRes;
            RopOpenAttachmentResponse openAttRes;

            // Logon to mailbox.
            logonHandle = this.RopLogon(LogonType.Mailbox, out logonRes, Common.GetConfigurationPropertyValue("UserEssdn", this.Site), true);
            objHandles.Add("Logon", logonHandle);

            // Open inbox folder.
            uint inboxHandle = this.RopOpenFolder(logonHandle, out openFolderRes, logonRes.FolderIds[4], true);

            // Open test root folder.
            uint testRootHandle = this.RopOpenFolder(inboxHandle, out openFolderRes, rootFolderId, true);

            // Open testFolder1.
            folderHandle1 = this.RopOpenFolder(testRootHandle, out openFolderRes, cprptFolderId[0], true);
            objHandles.Add("Folder1", folderHandle1);

            // Open testFolder2.
            folderHandle2 = this.RopOpenFolder(testRootHandle, out openFolderRes, cprptFolderId[1], true);
            objHandles.Add("Folder2", folderHandle2);

            // For first folder open message1.
            msgHandle1 = this.RopOpenMessage(folderHandle1, cprptFolderId[0], cprptMessageId[0], out openMsgRes, true);
            objHandles.Add("Message1", msgHandle1);

            // For first folder open message2.
            msgHandle2 = this.RopOpenMessage(folderHandle1, cprptFolderId[0], cprptMessageId[1], out openMsgRes, true);
            objHandles.Add("Message2", msgHandle2);

            // For first message open attachment1.
            attachmentHandle1 = this.RopOpenAttachment(msgHandle1, cprptAttachmentId[0], out openAttRes, true);
            objHandles.Add("Attachment1", attachmentHandle1);

            // For first message open attachment2.
            attachmentHandle2 = this.RopOpenAttachment(msgHandle1, cprptAttachmentId[1], out openAttRes, true);
            objHandles.Add("Attachment2", attachmentHandle2);
            #endregion

            if (!objHandles.ContainsKey(objKey))
            {
                this.oxcropsClient = tempClient;
                this.Site.Assert.Fail("Invalid Object key for getting its Property value");
            }

            uint objHandle = objHandles[objKey];

            // The RopGetPropertiesAll is used to obtain all properties.
            RopGetPropertiesSpecificResponse getPropSpecRes = this.RopGetPropertiesSpecific(objHandle, ConstValues.PropertySizeLimitNone, ConstValues.WantUnicodeNo, new PropertyTag[] { propertyTag });

            byte[] expectedNotFoundError = BitConverter.GetBytes((uint)CPRPTErrorCode.NotFound);
            if (Common.CompareByteArray(getPropSpecRes.RowData.PropertyValues[0].Value, expectedNotFoundError))
            {
                isPropertyFound = false;
            }
            else
            {
                isPropertyFound = true;
            }

            this.oxcropsClient = tempClient;

            return getPropSpecRes.RowData.PropertyValues[0].Value;
        }
 /// <summary>
 /// Registers ROPs' deserializer.
 /// </summary>
 private void RegisterROPDeserializer()
 {
     OxcropsClient ropsClient = new OxcropsClient();
     ropsClient.RegisterROPDeserializer();
 }
 /// <summary>
 /// Switch the instance of OxcropsClient.
 /// </summary>
 public void SwitchSessionContext()
 {
     if (this.oxcRopsClient == this.oxcRopsTrigger)
     {
         this.oxcRopsClient = this.oxcRopsRegister;
     }
     else
     {
         this.oxcRopsClient = this.oxcRopsTrigger;
     }
 }
        /// <summary>
        /// Initialize the adapter.
        /// </summary>
        /// <param name="testSite">Test site.</param>
        public override void Initialize(ITestSite testSite)
        {
            base.Initialize(testSite);
            AdapterHelper.Site = testSite;
            testSite.DefaultProtocolDocShortName = "MS-OXCTABL";
            Common.MergeConfiguration(this.Site);
            this.maxRowCountInExpandRowRequest = 0x32;

            // Implementation following Exchange 2013 does not support a value greater than 0 for the MaxRowCount field.
            if (Common.IsRequirementEnabled(748, this.Site))
            {
                this.maxRowCountInExpandRowRequest = 0x00;
            }

            this.oxcropsClient = new OxcropsClient(MapiContext.GetDefaultRpcContext(this.Site));

            this.waitTime = int.Parse(Common.GetConfigurationPropertyValue("WaitTime", this.Site));
        }
 /// <summary>
 /// Initialize test environment
 /// </summary>
 /// <param name="testSite">Test Site.</param>
 public override void Initialize(ITestSite testSite)
 {
     base.Initialize(testSite);
     testSite.DefaultProtocolDocShortName = "MS-OXORULE";
     Common.MergeConfiguration(this.Site);
     this.server = Common.GetConfigurationPropertyValue(Constants.Server, this.Site);
     this.user1ESSDN = Common.GetConfigurationPropertyValue(Constants.User1ESSDN, this.Site) + "\0";
     this.domain = Common.GetConfigurationPropertyValue(Constants.Domain, this.Site);
     this.user2ESSDN = Common.GetConfigurationPropertyValue(Constants.User2ESSDN, this.Site) + "\0";
     this.oxcropsClient = new OxcropsClient(MapiContext.GetDefaultRpcContext(this.Site));
     this.nspiAdapter = new NSPIAdapter(this.Site);
 }