RopModifyPermissionsRequest request buffer structure.
 /// <summary>
 /// Create buffer to get ModifyPermissions
 /// </summary>
 /// <param name="permissionsDataArray">Permission data array is used to set permission</param>
 /// <param name="requestBufferFlags">requestBufferFlags is used to set flag</param>
 /// <returns>A request is used to modify permissions</returns>
 private RopModifyPermissionsRequest CreateModifyPermissionsRequestBuffer(PermissionData[] permissionsDataArray, RequestBufferFlags requestBufferFlags)
 {
     RopModifyPermissionsRequest modifyPermissionsRequest = new RopModifyPermissionsRequest
     {
         RopId = 0x40,
         LogonId = 0x0,
         InputHandleIndex = 0x00, // Attention InputHandleIndex must be set to 0x00 else 0x02 value will get 1206 error
         ModifyFlags = requestBufferFlags.BufferFlags,
         ModifyCount = (ushort)permissionsDataArray.Length,
         PermissionsData = permissionsDataArray
     };
     return modifyPermissionsRequest;
 }
        /// <summary>
        /// Modifies the permissions associated with a folder.
        /// </summary>
        /// <param name="serverId">The server id</param>
        /// <param name="folderHandleIndex">index of folder handle in container</param>
        /// <param name="permissionLevel">The permission level</param>
        /// <returns>Indicate the result of this ROP operation.</returns>
        public RopResult ModifyPermissions(int serverId, int folderHandleIndex, PermissionLevels permissionLevel)
        {
            // Initialize ROP data.
            RopResult result = RopResult.InvalidParameter;
            uint folderHandle = this.handleContainer[folderHandleIndex];

            // Add Administrator user into permission list of the specific folder.
            TaggedPropertyValue[] taggedProperties = new TaggedPropertyValue[2];

            // EntryId
            TaggedPropertyValue propertyValueEntryId = new TaggedPropertyValue
            {
                PropertyTag = new PropertyTag(0x0FFF, 0x0102)
            };
            string userDN = Common.GetConfigurationPropertyValue("AdminUserESSDN", this.Site);
            AddressBookEntryId addressEntryId = new AddressBookEntryId(userDN);
            propertyValueEntryId.Value = Common.AddInt16LengthBeforeBinaryArray(addressEntryId.Serialize());
            taggedProperties[0] = propertyValueEntryId;

            // PidTagMemberRights
            TaggedPropertyValue propertyValueMemberRight = new TaggedPropertyValue
            {
                PropertyTag = new PropertyTag(0x6673, 0x0003),
                Value = BitConverter.GetBytes((uint)permissionLevel)
            };

            // Set permission.
            taggedProperties[1] = propertyValueMemberRight;
            PermissionData[] permissionsDataArray = new PermissionData[1];

            // Add row
            permissionsDataArray[0].PermissionDataFlags = (byte)0x01;
            permissionsDataArray[0].PropertyValueCount = (ushort)taggedProperties.Length;
            permissionsDataArray[0].PropertyValues = taggedProperties;

            // Construct ROP request.
            RopModifyPermissionsRequest modifyPermission = new RopModifyPermissionsRequest
            {
                RopId = 0x40,
                LogonId = 0x00,
                InputHandleIndex = 0x00,
                ModifyFlags = (byte)ModifyFlags.IncludeFreeBusy,
                ModifyCount = 0x01,
                PermissionsData = permissionsDataArray
            };

            // Send request and get response.
            RopModifyPermissionsResponse modifyPermissionresponse = (RopModifyPermissionsResponse)this.Process(serverId, modifyPermission, folderHandle);
            result = (RopResult)modifyPermissionresponse.ReturnValue;
            if (result == RopResult.Success)
            {
                this.currentPermission = permissionLevel;
                if (permissionLevel == PermissionLevels.None)
                {
                    // If the specific folder's permission is None, set existNoPermissionFolder as true to make client has no permission to access this folder now
                    this.existNoPermissionFolder = true;
                }
            }

            return result;
        }
        /// <summary>
        /// Create buffer to get ModifyPermissions
        /// </summary>
        /// <param name="permissionsDataArray">Permission data array is used to set permission</param>
        /// <param name="modifyFlags">Set the ModifyFlags, specified in [MS-OXCPERM] section 2.2.2</param>
        /// <returns>A request used to modify permissions</returns>
        private RopModifyPermissionsRequest CreateModifyPermissionsRequestBuffer(PermissionData[] permissionsDataArray, ModifyFlags modifyFlags)
        {
            RopModifyPermissionsRequest modifyPermissionsRequest = new RopModifyPermissionsRequest
            {
                RopId = (byte)RopId.RopModifyPermissions,
                LogonId = Constants.CommonLogonId,
                InputHandleIndex = Constants.CommonInputHandleIndex,
                ModifyFlags = (byte)modifyFlags,
                ModifyCount = (ushort)permissionsDataArray.Length,
                PermissionsData = permissionsDataArray
            };

            return modifyPermissionsRequest;
        }