Ejemplo n.º 1
0
        /// <summary>
        /// Find a folder ID in the specified folder and with specified display name.
        /// </summary>
        /// <param name="parentFolderId">ID of the parent Folder.</param>
        /// <param name="logonHandle">The logon object handle.</param>
        /// <param name="folderName">The folder display name.</param>
        /// <returns>The folder ID.</returns>
        protected ulong GetSubfolderIDByName(ulong parentFolderId, uint logonHandle, string folderName)
        {
            ulong folderId           = 0;
            uint  parentFolderHandle = 0;

            this.OpenFolder(logonHandle, parentFolderId, ref parentFolderHandle);

            RopGetHierarchyTableRequest getHierarchyTableRequest = new RopGetHierarchyTableRequest
            {
                RopId             = (byte)RopId.RopGetHierarchyTable,
                LogonId           = Constants.CommonLogonId,
                InputHandleIndex  = Constants.CommonInputHandleIndex,
                OutputHandleIndex = Constants.CommonOutputHandleIndex,
                TableFlags        = (byte)FolderTableFlags.Depth
            };
            RopGetHierarchyTableResponse getHierarchyTableResponse = this.Adapter.GetHierarchyTable(getHierarchyTableRequest, parentFolderHandle, ref this.responseHandles);
            uint tableHandle = this.responseHandles[0][getHierarchyTableResponse.OutputHandleIndex];

            PropertyTag[] properties = new PropertyTag[]
            {
                new PropertyTag()
                {
                    PropertyId   = (ushort)FolderPropertyId.PidTagDisplayName,
                    PropertyType = (ushort)PropertyType.PtypString
                },
                new PropertyTag()
                {
                    PropertyId   = (ushort)FolderPropertyId.PidTagFolderId,
                    PropertyType = (ushort)PropertyType.PtypInteger64
                }
            };
            List <PropertyRow> propertyRows = this.GetTableRowValue(tableHandle, (ushort)getHierarchyTableResponse.RowCount, properties);

            if (propertyRows != null)
            {
                foreach (PropertyRow propertyRow in propertyRows)
                {
                    byte[] displayNameInBytes = propertyRow.PropertyValues[0].Value;
                    string displayName        = Encoding.Unicode.GetString(displayNameInBytes, 0, displayNameInBytes.Length);
                    if (displayName.Equals(folderName, StringComparison.CurrentCultureIgnoreCase))
                    {
                        byte[] folderIdInBytes = propertyRow.PropertyValues[1].Value;
                        folderId = (ulong)BitConverter.ToInt64(folderIdInBytes, 0);
                        break;
                    }
                }
            }

            return(folderId);
        }
        /// <summary>
        /// Retrieves the hierarchy table for a folder.
        /// </summary>
        /// <param name="ropGetHierarchyTableRequest">RopGetHierarchyTableRequest object.</param>
        /// <param name="insideObjHandle">Server object handle RopGetHierarchyTable.</param>
        /// <param name="responseSOHTable">Server objects handles in RopGetHierarchyTableResponse.</param>
        /// <returns>RopGetHierarchyTableResponse object.</returns>
        public RopGetHierarchyTableResponse GetHierarchyTable(RopGetHierarchyTableRequest ropGetHierarchyTableRequest, uint insideObjHandle, ref List <List <uint> > responseSOHTable)
        {
            object temp = new object();

            this.ExcuteRopCall((ISerializable)ropGetHierarchyTableRequest, insideObjHandle, ref temp, ref responseSOHTable, ref this.rawData);
            RopGetHierarchyTableResponse ropGetHierarchyTableResponse = (RopGetHierarchyTableResponse)temp;

            #region Capture Code
            // The ReturnValue equal to 0x00000000 indicate ROP operation success
            if (0x00000000 == ropGetHierarchyTableResponse.ReturnValue)
            {
                this.VerifyRopGetHierarchyTable(ropGetHierarchyTableResponse);
            }
            #endregion

            return(ropGetHierarchyTableResponse);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Verify the response of RopGetHierarchyTable ROP operation. 
        /// </summary>
        /// <param name="getHierarchyTableResponse">The response of RopGetHierarchyTable operation </param>
        private void VerifyRopGetHierarchyTable(RopGetHierarchyTableResponse getHierarchyTableResponse)
        {
            // Add the debug information
            Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXCFOLD_R317");

            // Verify MS-OXCFOLD requirement: MS-OXCFOLD_R317
            Site.CaptureRequirementIfAreEqual<uint>(
                Constants.SuccessCode,
                getHierarchyTableResponse.ReturnValue,
                317,
                @"[In RopGetHierarchyTable ROP Response Buffer] ReturnValue (4 bytes): The server returns 0x00000000 to indicate success.");

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

            // Verify MS-OXCFOLD requirement: MS-OXCFOLD_R305
            Site.CaptureRequirementIfAreEqual<uint>(
                Constants.SuccessCode,
                getHierarchyTableResponse.ReturnValue,
                305,
                @"[In RopGetHierarchyTable ROP] The RopGetHierarchyTable ROP ([MS-OXCROPS] section 2.2.4.13) is used to retrieve the hierarchy table for a folder.");

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

            // Verify MS-OXCFOLD requirement: MS-OXCFOLD_R306
            Site.CaptureRequirementIfAreEqual<uint>(
                Constants.SuccessCode,
                getHierarchyTableResponse.ReturnValue,
                306,
                @"[In RopGetHierarchyTable ROP] This ROP [RopGetHierarchyTable] returns a Table object on which table operations can be performed.");
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Find a folder ID in the specified folder and with specified display name.
        /// </summary>
        /// <param name="openedFolderHandle">Handle of the parent folder.</param>
        /// <param name="folderName">The folder display name.</param>
        /// <returns>The folder ID.</returns>
        protected ulong GetSubfolderIDByName(uint openedFolderHandle, string folderName)
        {
            RopGetHierarchyTableRequest getHierarchyTableRequest = new RopGetHierarchyTableRequest();
            RopGetHierarchyTableResponse getHierarchyTableResponse = new RopGetHierarchyTableResponse();
            getHierarchyTableRequest.RopId = (byte)RopId.RopGetHierarchyTable;
            getHierarchyTableRequest.LogonId = TestSuiteBase.LogonId;
            getHierarchyTableRequest.InputHandleIndex = TestSuiteBase.InputHandleIndex0;
            getHierarchyTableRequest.OutputHandleIndex = TestSuiteBase.OutputHandleIndex1;
            getHierarchyTableRequest.TableFlags = (byte)FolderTableFlags.Depth;
            this.responseSOHs = this.cropsAdapter.ProcessSingleRop(
                getHierarchyTableRequest,
                openedFolderHandle,
                ref this.response,
                ref this.rawData,
                RopResponseType.SuccessResponse);
            getHierarchyTableResponse = (RopGetHierarchyTableResponse)this.response;
            uint tableHandle = this.responseSOHs[0][getHierarchyTableResponse.OutputHandleIndex];

            PropertyTag[] properties = new PropertyTag[]
            {
                new PropertyTag()
                {
                    PropertyId = this.propertyDictionary[PropertyNames.PidTagDisplayName].PropertyId,
                    PropertyType = (ushort)PropertyType.PtypString
                },
                new PropertyTag()
                {
                    PropertyId = (ushort)this.propertyDictionary[PropertyNames.PidTagFolderId].PropertyId,
                    PropertyType = (ushort)PropertyType.PtypInteger64
                }
            };
            List<PropertyRow> propertyRows = this.GetTableRowValue(tableHandle, (ushort)getHierarchyTableResponse.RowCount, properties);

            ulong folderId = 0;
            foreach (PropertyRow propertyRow in propertyRows)
            {
                byte[] displayNameInBytes = propertyRow.PropertyValues[0].Value;
                string displayName = Encoding.Unicode.GetString(displayNameInBytes, 0, displayNameInBytes.Length);
                if (displayName.ToLower() == folderName.ToLower())
                {
                    byte[] folderIdInBytes = propertyRow.PropertyValues[1].Value;
                    folderId = (ulong)BitConverter.ToInt64(folderIdInBytes, 0);
                    break;
                }
            }

            return folderId;
        }
        /// <summary>
        /// Retrieve the hierarchy table for a folder. 
        /// </summary>
        /// <param name="serverId">A 32-bit signed integer represent the Identity of server.</param>
        /// <param name="folderHandleIndex">The folder handle index</param>
        /// <param name="deleteFlags">The delete flag indicates whether checking delete.</param>
        /// <param name="rowCount">The row count.</param>
        /// <returns>Indicate the result of this ROP operation.</returns>
        public RopResult GetHierarchyTable(int serverId, int folderHandleIndex, DeleteFlags deleteFlags, out int rowCount)
        {
            RopResult result = RopResult.InvalidParameter;
            rowCount = -1;
            uint objHandle = this.handleContainer[folderHandleIndex];

            RopGetHierarchyTableRequest getHierarchyTableRequest = new RopGetHierarchyTableRequest();
            RopGetHierarchyTableResponse getHierarchyTableResponse = new RopGetHierarchyTableResponse();

            getHierarchyTableRequest.RopId = 0x04;
            getHierarchyTableRequest.LogonId = 0x00;
            getHierarchyTableRequest.InputHandleIndex = 0x00;
            getHierarchyTableRequest.OutputHandleIndex = 0x01;

            // If this bit is set, the contents table lists only the soft-deleted messages. 
            getHierarchyTableRequest.TableFlags = 0x20;

            getHierarchyTableResponse = (RopGetHierarchyTableResponse)this.Process(serverId, getHierarchyTableRequest, objHandle);
            result = (RopResult)getHierarchyTableResponse.ReturnValue;
            int expectedRowCount = (int)getHierarchyTableResponse.RowCount;

            // Add this condition to match the model logical for return result, it's better to compare.
            if (deleteFlags == DeleteFlags.SoftDeleteCheck && this.currentSoftDeleteRowCount + 1 == expectedRowCount)
            {
                rowCount = 1;
            }
            else if (deleteFlags == DeleteFlags.HardDeleteCheck && this.currentSoftDeleteRowCount == expectedRowCount && Common.IsRequirementEnabled(90205002, this.Site))
            {
                rowCount = 0;
            }
            else if (deleteFlags == DeleteFlags.Initial)
            {
                rowCount = 0;
            }

            this.currentSoftDeleteRowCount = expectedRowCount;
            return result;
        }
        /// <summary>
        /// Verify RopGetHierarchyTable Failure Response
        /// </summary>
        /// <param name="ropGetHierarchyTableResponse">The failure response of RopGetHierarchyTable request</param>
        /// <param name="outputHandleIndex">The field of OutputHandleIndex in RopGetHierarchyTable request</param>
        private void VerifyRopGetHierarchyTableFailureResponse(RopGetHierarchyTableResponse ropGetHierarchyTableResponse, byte outputHandleIndex)
        {
            // Add the debug information
            Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXCROPS_R1003");

            // Verify MS-OXCROPS requirement: MS-OXCROPS_R1003
            Site.CaptureRequirementIfAreEqual<Type>(
                typeof(byte),
                ropGetHierarchyTableResponse.RopId.GetType(),
                1003,
                @"[In RopGetHierarchyTable ROP Failure Response Buffer] RopId (1 byte): An unsigned integer.");

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

            // Verify MS-OXCROPS requirement: MS-OXCROPS_R1005
            Site.CaptureRequirementIfAreEqual<byte>(
                (byte)RopId.RopGetHierarchyTable,
                ropGetHierarchyTableResponse.RopId,
                1005,
                @"[In RopGetHierarchyTable ROP Failure Response Buffer] RopId (1 byte): For this operation[RopGetHierarchyTable], this field[RopId (1 byte)] is set to 0x04.");

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

            // Verify MS-OXCROPS requirement: MS-OXCROPS_R1006
            Site.CaptureRequirementIfAreEqual<Type>(
                typeof(byte),
                ropGetHierarchyTableResponse.OutputHandleIndex.GetType(),
                1006,
                @"[In RopGetHierarchyTable ROP Failure Response Buffer] OutputHandleIndex (1 byte): An unsigned integer.");

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

            // Verify MS-OXCROPS requirement: MS-OXCROPS_R1007
            Site.CaptureRequirementIfAreEqual<byte>(
                outputHandleIndex,
                ropGetHierarchyTableResponse.OutputHandleIndex,
                1007,
                @"[In RopGetHierarchyTable ROP Failure Response Buffer] OutputHandleIndex (1 byte): This index MUST be set to the value specified in the OutputHandleIndex field in the request.");

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

            // Verify MS-OXCROPS requirement: MS-OXCROPS_R1008
            Site.CaptureRequirementIfAreEqual<Type>(
                typeof(uint),
                ropGetHierarchyTableResponse.ReturnValue.GetType(),
                1008,
                @"[In RopGetHierarchyTable ROP Failure Response Buffer] ReturnValue (4 bytes): An unsigned integer.");

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

            // Verify MS-OXCROPS requirement: MS-OXCROPS_R1010
            Site.CaptureRequirementIfAreNotEqual<uint>(
                SuccessReturnValue,
                ropGetHierarchyTableResponse.ReturnValue,
                1010,
                @"[In RopGetHierarchyTable ROP Failure Response Buffer] ReturnValue (4 bytes): For this response[Failure Response], this field is set to a value other than 0x00000000.");
        }