コード例 #1
0
        /// <summary>
        /// Revert the permissions list.
        /// </summary>
        public override void Reset()
        {
            this.Logon(this.User2);

            uint folderHandle = this.GetFolderObjectHandle(FolderTypeEnum.CommonFolderType);
            
            // Clean up the folder
            RopHardDeleteMessagesAndSubfoldersRequest deleteSubfoldersOfInboxRequest = new RopHardDeleteMessagesAndSubfoldersRequest
            {
                RopId = 0x92,
                InputHandleIndex = 0x00,
                WantAsynchronous = 0x00,
                WantDeleteAssociated = 0xff
            };
            this.DoRopCall(deleteSubfoldersOfInboxRequest, folderHandle, ref this.response, ref this.rawData);

            RopHardDeleteMessagesAndSubfoldersResponse deleteSubfoldersOfInboxResponse = (RopHardDeleteMessagesAndSubfoldersResponse)this.response;
            Site.Assert.AreEqual<uint>(0, deleteSubfoldersOfInboxResponse.ReturnValue, "0 indicates the ROP succeeds, other value indicates error occurs.");

            this.messageIdsCreatedByOther.Clear();
            this.ownedMessageIds.Clear();

            // Restore the permissions for the user configured by the "User1Name"
            for (int i = 0; i < this.originalPermissionsList.Count; i++)
            {
                if (this.originalPermissionsList[i].PidTagMemberName == this.User1)
                {
                    PermissionData[] revertPermissionData = new PermissionData[1];
                    PermissionData permission = new PermissionData
                    {
                        PermissionDataFlags = 0x01
                    };

                    PropertyValue[] propertyValues = new PropertyValue[2];
                    propertyValues[0] = this.CreateEntryIdProperty(this.originalPermissionsList[i].PidTagMemberName);
                    propertyValues[1] = this.CreateRightsProperty(this.originalPermissionsList[i].PidTagMemberRights);
                    permission.PropertyValueCount = (ushort)propertyValues.Length;
                    permission.PropertyValues = propertyValues;

                    revertPermissionData[0] = permission;
                    RequestBufferFlags requestBufferFlags = new RequestBufferFlags
                    {
                        IsReplaceRowsFlagSet = false
                    };

                    // Call RopModifyPermissions to revert the permissions list.
                    this.responseSOHs = this.DoRopCall(
                        this.CreateModifyPermissionsRequestBuffer(revertPermissionData, requestBufferFlags),
                        folderHandle,
                        ref this.response,
                        ref this.rawData);

                    RopModifyPermissionsResponse modifyPermissionsResponse = (RopModifyPermissionsResponse)this.response;
                    Site.Log.Add(LogEntryKind.Comment, "The return value for restore the permissions in Reset(): {0:X}", modifyPermissionsResponse.ReturnValue);
                    break;
                }
                else
                {
                    this.RemovePermission(FolderTypeEnum.CommonFolderType, this.User1, new RequestBufferFlags());
                }
            }

            this.ReleaseObject(folderHandle);
            base.Reset();
        }
コード例 #2
0
        /// <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;
        }
コード例 #3
0
        /// <summary>
        /// Set the permissionData array for modifying by the PidTagMemberId and PidTagMemberRights.
        /// </summary>
        /// <param name="pidTagMemberId">The pidTagMemberId that specifies the unique identifier that the server generates for each user. </param>
        /// <param name="memberRights">The permission data</param>
        /// <returns>The permissionData array</returns>
        private PermissionData[] SetPermissionDataArrayForModify(ulong pidTagMemberId, uint memberRights)
        {
            PropertyValue[] propertyValues = new PropertyValue[2];

            propertyValues[0] = this.CreateMemberIdProperty(pidTagMemberId);

            propertyValues[1] = this.CreateRightsProperty(memberRights);

            PermissionData[] permissionsDataArray = new PermissionData[1];
            permissionsDataArray[0].PermissionDataFlags = 0x02; // ModifyRow flags 
            permissionsDataArray[0].PropertyValueCount = (ushort)propertyValues.Length;
            permissionsDataArray[0].PropertyValues = propertyValues;

            return permissionsDataArray;
        }
コード例 #4
0
        /// <summary>
        /// Set the permissionData array for removing by the PidTagMemberId
        /// </summary>
        /// <param name="pidTagMemberId">The PidTagMemberId</param>
        /// <returns>Return the permissionData Array</returns>
        private PermissionData[] SetPermissionDataArrayForRemove(ulong pidTagMemberId)
        {
            PropertyValue[] propertyValues = new PropertyValue[1];

            propertyValues[0] = this.CreateMemberIdProperty(pidTagMemberId);

            PermissionData[] permissionsDataArray = new PermissionData[1];
            permissionsDataArray[0].PermissionDataFlags = 0x04; // RemoveRow flags 
            permissionsDataArray[0].PropertyValueCount = (ushort)propertyValues.Length;
            permissionsDataArray[0].PropertyValues = propertyValues;

            return permissionsDataArray;
        }
コード例 #5
0
        /// <summary>
        /// Set the permissionData array for adding by the permissionUserName and permissionRight
        /// </summary>
        /// <param name="permissionUserName">The user whose permission is for adding</param>
        /// <param name="memberRights">The rights will be assigned to user</param>
        /// <returns>Return the permissionData array for adding user</returns>
        private PermissionData[] SetPermissionDataArrayForAdd(string permissionUserName, uint memberRights)
        {
            PropertyValue[] propertyValues = new PropertyValue[2];
            propertyValues[0] = this.CreateRightsProperty(memberRights);
            propertyValues[1] = this.CreateEntryIdProperty(permissionUserName);

            PermissionData[] permissionsDataArray = new PermissionData[1];
            permissionsDataArray[0].PermissionDataFlags = 0x01; // AddRow flags 
            permissionsDataArray[0].PropertyValueCount = (ushort)propertyValues.Length;
            permissionsDataArray[0].PropertyValues = propertyValues;

            return permissionsDataArray;
        }
コード例 #6
0
 /// <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;
 }
コード例 #7
0
        /// <summary>
        /// Set the permission data array for the specified user.
        /// </summary>
        /// <param name="userEssdn">The ESSDN of the specified user.</param>
        /// <param name="rights">The rights which will be assigned to the specified user.</param>
        /// <returns>The permission data array for the specified user.</returns>
        private PermissionData[] GetPermissionDataArrayForAdd(string userEssdn, uint rights)
        {
            PropertyValue[] propertyValues = new PropertyValue[2];
            propertyValues[0] = this.CreateRightsProperty(rights);
            propertyValues[1] = this.CreateEntryIdProperty(userEssdn);

            PermissionData[] permissionsDataArray = new PermissionData[1];
            permissionsDataArray[0].PermissionDataFlags = (byte)PermissionDataFlags.AddRow;
            permissionsDataArray[0].PropertyValueCount = (ushort)propertyValues.Length;
            permissionsDataArray[0].PropertyValues = propertyValues;

            return permissionsDataArray;
        }
コード例 #8
0
        /// <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;
        }
コード例 #9
0
        /// <summary>
        /// Get GetPermissionData Array for modify permissions
        /// </summary>
        /// <returns>Return GetPermissionData array</returns>
        private PermissionData[] GetPermissionDataArray()
        {
            // Get PropertyValues
            TaggedPropertyValue taggedPropertyValue = new TaggedPropertyValue();
            TaggedPropertyValue[] propertyValues = new TaggedPropertyValue[2];

            // PidTagMemberId
            taggedPropertyValue.PropertyTag.PropertyId = this.propertyDictionary[PropertyNames.PidTagMemberId].PropertyId;
            taggedPropertyValue.PropertyTag.PropertyType = this.propertyDictionary[PropertyNames.PidTagMemberId].PropertyType;

            // Anonymous Client: The server MUST use the permissions specified in PidTagMemberRights for 
            // any anonymous users that have not been authenticated with user credentials.
            taggedPropertyValue.Value = BitConverter.GetBytes(TestSuiteBase.TaggedPropertyValueForPidTagMemberId);
            propertyValues[0] = taggedPropertyValue;

            // PidTagMemberRights
            taggedPropertyValue = new TaggedPropertyValue
            {
                PropertyTag =
                {
                    PropertyId = this.propertyDictionary[PropertyNames.PidTagMemberRights].PropertyId,
                    PropertyType = this.propertyDictionary[PropertyNames.PidTagMemberRights].PropertyType
                },
                Value = BitConverter.GetBytes(TestSuiteBase.TaggedPropertyValueForPidTagMemberRights)
            };

            // CreateSubFolder 
            propertyValues[1] = taggedPropertyValue;

            PermissionData[] permissionsDataArray = new PermissionData[1];
            permissionsDataArray[0].PermissionDataFlags = (byte)PermissionDataFlags.ModifyRow;
            permissionsDataArray[0].PropertyValueCount = (ushort)propertyValues.Length;
            permissionsDataArray[0].PropertyValues = propertyValues;
            return permissionsDataArray;
        }