/// <summary> /// Submit a message to the server /// </summary> /// <param name="mailTo">The user name of the recipient</param> /// <param name="mailToUserDN">The userDN of the recipient</param> /// <param name="subject">The subject of the mail</param> /// <param name="addedProperties">The added properties of the mail</param> /// <returns>Return code of the message delivering</returns> public uint DeliverMessageToTriggerRule(string mailTo, string mailToUserDN, string subject, TaggedPropertyValue[] addedProperties) { RopCreateMessageResponse createMsgRes; uint msgHandle = this.OxoruleAdapter.RopCreateMessage(outBoxFolderHandle, outBoxFolderID, 0, out createMsgRes); TaggedPropertyValue[] clientSpecificProperties = new TaggedPropertyValue[1]; clientSpecificProperties[0] = new TaggedPropertyValue(); PropertyTag propertyTag = new PropertyTag { PropertyId = (ushort)PropertyId.PidTagSubject, PropertyType = (ushort)PropertyType.PtypString }; clientSpecificProperties[0].PropertyTag = propertyTag; clientSpecificProperties[0].Value = Encoding.Unicode.GetBytes(subject + "\0"); this.OxoruleAdapter.RopSetProperties(msgHandle, clientSpecificProperties); if (addedProperties != null && addedProperties.Length > 0) { this.OxoruleAdapter.RopSetProperties(msgHandle, addedProperties); } #region recipientColumns, PropertyTag[] sampleRecipientColumns // The following sample data is from MS-OXCMSG 4.7.1 PropertyTag[] sampleRecipientColumns = new PropertyTag[12]; PropertyTag tag = new PropertyTag { PropertyId = (ushort)PropertyId.PidTagObjectType, PropertyType = (ushort)PropertyType.PtypInteger32 }; // PidTagObjectType sampleRecipientColumns[0] = tag; // PidTagDisplayType tag.PropertyId = (ushort)PropertyId.PidTagDisplayType; tag.PropertyType = (ushort)PropertyType.PtypInteger32; sampleRecipientColumns[1] = tag; // PidTagAddressBookDisplayNamePrintable tag.PropertyId = (ushort)PropertyId.PidTagAddressBookDisplayNamePrintable; tag.PropertyType = (ushort)PropertyType.PtypString; sampleRecipientColumns[2] = tag; // PidTagSmtpAddress tag.PropertyId = (ushort)PropertyId.PidTagSmtpAddress; tag.PropertyType = (ushort)PropertyType.PtypString; sampleRecipientColumns[3] = tag; // PidTagSendInternetEncoding tag.PropertyId = (ushort)PropertyId.PidTagSendInternetEncoding; tag.PropertyType = (ushort)PropertyType.PtypInteger32; sampleRecipientColumns[4] = tag; // PidTagDisplayTypeEx tag.PropertyId = (ushort)PropertyId.PidTagDisplayTypeEx; tag.PropertyType = (ushort)PropertyType.PtypInteger32; sampleRecipientColumns[5] = tag; // PidTagRecipientDisplayName tag.PropertyId = (ushort)PropertyId.PidTagRecipientDisplayName; tag.PropertyType = (ushort)PropertyType.PtypString; sampleRecipientColumns[6] = tag; // PidTagRecipientFlags tag.PropertyId = (ushort)PropertyId.PidTagRecipientFlags; tag.PropertyType = (ushort)PropertyType.PtypInteger32; sampleRecipientColumns[7] = tag; // PidTagRecipientTrackStatus tag.PropertyId = (ushort)PropertyId.PidTagRecipientTrackStatus; tag.PropertyType = (ushort)PropertyType.PtypInteger32; sampleRecipientColumns[8] = tag; // PidTagRecipientResourceState tag.PropertyId = (ushort)PropertyId.PidTagRecipientResourceState; tag.PropertyType = (ushort)PropertyType.PtypInteger32; sampleRecipientColumns[9] = tag; // PidTagRecipientOrder tag.PropertyId = (ushort)PropertyId.PidTagRecipientOrder; tag.PropertyType = (ushort)PropertyType.PtypInteger32; sampleRecipientColumns[10] = tag; // PidTagRecipientEntryId tag.PropertyId = (ushort)PropertyId.PidTagRecipientEntryId; tag.PropertyType = (ushort)PropertyType.PtypBinary; sampleRecipientColumns[11] = tag; #endregion #region Configure a StandardPropertyRow: propertyRow PropertyValue[] propertyValueArray = new PropertyValue[12]; for (int i = 0; i < propertyValueArray.Length; i++) { propertyValueArray[i] = new PropertyValue(); } // PidTagObjectType propertyValueArray[0].Value = BitConverter.GetBytes(0x00000006); // PidTagDisplayType propertyValueArray[1].Value = BitConverter.GetBytes(0x00000000); // PidTagAddressBookDisplayNamePrintable propertyValueArray[2].Value = Encoding.Unicode.GetBytes(mailTo + "\0"); // PidTagSmtpAddress propertyValueArray[3].Value = Encoding.Unicode.GetBytes(mailTo + "@" + this.Domain + "\0"); // PidTagSendInternetEncoding propertyValueArray[4].Value = BitConverter.GetBytes(0x00000000); // PidTagDisplayTypeEx propertyValueArray[5].Value = BitConverter.GetBytes(0x40000000); // PidTagRecipientDisplayName propertyValueArray[6].Value = Encoding.Unicode.GetBytes(mailTo + "\0"); // PidTagRecipientFlags propertyValueArray[7].Value = BitConverter.GetBytes(0x00000001); // PidTagRecipientTrackStatus propertyValueArray[8].Value = BitConverter.GetBytes(0x00000000); // PidTagRecipientResourceState propertyValueArray[9].Value = BitConverter.GetBytes(0x00000000); // PidTagRecipientOrder propertyValueArray[10].Value = BitConverter.GetBytes(0x00000000); AddressBookEntryID addressBookEntryID = new AddressBookEntryID(mailToUserDN); propertyValueArray[11].Value = Common.AddInt16LengthBeforeBinaryArray(addressBookEntryID.Serialize()); List <PropertyValue> propertyValues = new List <PropertyValue>(); for (int i = 0; i < propertyValueArray.Length; i++) { propertyValues.Add(propertyValueArray[i]); } PropertyRow propertyRow = new PropertyRow { Flag = 0x01, PropertyValues = propertyValues }; #endregion RecipientRow recipientRow = new RecipientRow { RecipientFlags = 0x065B, DisplayName = Encoding.Unicode.GetBytes(mailTo + "\0"), EmailAddress = Encoding.Unicode.GetBytes(mailTo + "@" + this.Domain + "\0"), SimpleDisplayName = Encoding.Unicode.GetBytes(mailTo + "\0"), RecipientColumnCount = 0x000C, RecipientProperties = propertyRow }; ModifyRecipientRow modifyRecipientRow = new ModifyRecipientRow { RowId = 0x00000000, RecipientType = 0x01, RecipientRowSize = (ushort)recipientRow.Size(), RecptRow = recipientRow.Serialize() }; ModifyRecipientRow[] sampleModifyRecipientRows = new ModifyRecipientRow[1]; sampleModifyRecipientRows[0] = modifyRecipientRow; this.OxoruleAdapter.RopModifyRecipients(msgHandle, sampleRecipientColumns, sampleModifyRecipientRows); this.OxoruleAdapter.RopSaveChangesMessage(msgHandle); RopSubmitMessageResponse submitMsgRes = this.OxoruleAdapter.RopSubmitMessage(msgHandle, 0); return(submitMsgRes.ReturnValue); }
/// <summary> /// Generate property value on recipient. /// </summary> /// <param name="userName">Recipient user name.</param> /// <param name="userDN">Recipient user dn.</param> /// <returns>Property array value.</returns> public static TaggedPropertyValue[] GenerateRecipientPropertiesBlock(string userName, string userDN) { TaggedPropertyValue[] recipientProperties = new TaggedPropertyValue[4]; // Add PidTagDisplayName recipientProperties[0] = new TaggedPropertyValue(); PropertyTag pidTagDisplayNamePropertyTag = new PropertyTag { PropertyId = (ushort)PropertyId.PidTagDisplayName, PropertyType = (ushort)PropertyType.PtypString }; recipientProperties[0].PropertyTag = pidTagDisplayNamePropertyTag; recipientProperties[0].Value = Encoding.Unicode.GetBytes(userName + "\0"); // Add PidTagEmailAddress recipientProperties[1] = new TaggedPropertyValue(); PropertyTag pidTagEmailAddressPropertyTag = new PropertyTag { PropertyId = (ushort)PropertyId.PidTagEmailAddress, PropertyType = (ushort)PropertyType.PtypString }; recipientProperties[1].PropertyTag = pidTagEmailAddressPropertyTag; recipientProperties[1].Value = Encoding.Unicode.GetBytes(userDN + "\0"); // Add PidTagRecipientType recipientProperties[2] = new TaggedPropertyValue(); PropertyTag pidTagRecipientTypePropertyTag = new PropertyTag { PropertyId = (ushort)PropertyId.PidTagRecipientType, PropertyType = (ushort)PropertyType.PtypInteger32 }; recipientProperties[2].PropertyTag = pidTagRecipientTypePropertyTag; recipientProperties[2].Value = BitConverter.GetBytes(0x00000001); AddressBookEntryID addressBookEntryID = new AddressBookEntryID(userDN); // Add PidTagEntryID recipientProperties[3] = new TaggedPropertyValue(); PropertyTag pidTagEntryIDPropertyTag = new PropertyTag { PropertyId = (ushort)PropertyId.PidTagEntryId, PropertyType = (ushort)PropertyType.PtypBinary }; recipientProperties[3].PropertyTag = pidTagEntryIDPropertyTag; recipientProperties[3].Value = Common.AddInt16LengthBeforeBinaryArray(addressBookEntryID.Serialize()); return recipientProperties; }
public void MSOXORULE_S02_TC08_ServerExecuteRule_Action_OP_DELEGATE() { this.CheckMAPIHTTPTransportSupported(); #region Prepare value for ruleProperties variable. RuleProperties ruleProperties = AdapterHelper.GenerateRuleProperties(this.Site, Constants.RuleNameDelegate); #endregion #region TestUser1 adds an OP_DELEGATE rule. ForwardDelegateActionData delegateActionData = new ForwardDelegateActionData { RecipientCount = (ushort)0x01 }; RecipientBlock recipientBlock = new RecipientBlock { Reserved = 0x01, NoOfProperties = (ushort)0x05u }; #region Prepare recipient Block. TaggedPropertyValue[] recipientProperties = new TaggedPropertyValue[5]; TaggedPropertyValue[] temp = AdapterHelper.GenerateRecipientPropertiesBlock(this.User2Name, this.User2ESSDN); Array.Copy(temp, 0, recipientProperties, 0, temp.Length); // Add PidTagSmtpEmailAdderss. recipientProperties[4] = new TaggedPropertyValue(); PropertyTag pidTagSmtpEmailAdderssPropertyTag = new PropertyTag { PropertyId = (ushort)PropertyId.PidTagSmtpAddress, PropertyType = (ushort)PropertyType.PtypString }; recipientProperties[4].PropertyTag = pidTagSmtpEmailAdderssPropertyTag; recipientProperties[4].Value = Encoding.Unicode.GetBytes(this.User2Name + "@" + this.Domain + "\0"); recipientBlock.PropertiesData = recipientProperties; #endregion delegateActionData.RecipientsData = new RecipientBlock[1] { recipientBlock }; RuleData ruleDelegate = AdapterHelper.GenerateValidRuleData(ActionType.OP_DELEGATE, TestRuleDataType.ForAdd, 1, RuleState.ST_ENABLED, delegateActionData, ruleProperties, null); RopModifyRulesResponse ropModifyRulesResponse = this.OxoruleAdapter.RopModifyRules(this.InboxFolderHandle, ModifyRuleFlag.Modify_ReplaceAll, new RuleData[] { ruleDelegate }); Site.Assert.AreEqual<uint>(0, ropModifyRulesResponse.ReturnValue, "Adding delegate rule should succeed."); #endregion #region TestUser1 delivers a message to itself to trigger the rule. Thread.Sleep(this.WaitForTheRuleToTakeEffect); // TestUser1 delivers a message to itself to trigger the rule. string mailSubject = Common.GenerateResourceName(this.Site, ruleProperties.ConditionSubjectName + "Title"); this.SUTAdapter.SendMailToRecipient(this.User1Name, this.User1Password, this.User1Name, mailSubject); Thread.Sleep(this.WaitForTheRuleToTakeEffect); #endregion #region TestUser2 gets the delegate message to verify the rule evaluation. // Let TestUser2 log on to the server. this.LogonMailbox(TestUser.TestUser2); PropertyTag[] propertyTagList = new PropertyTag[7]; propertyTagList[0].PropertyId = (ushort)PropertyId.PidTagSubject; propertyTagList[0].PropertyType = (ushort)PropertyType.PtypString; propertyTagList[1].PropertyId = (ushort)PropertyId.PidTagReceivedRepresentingEntryId; propertyTagList[1].PropertyType = (ushort)PropertyType.PtypBinary; propertyTagList[2].PropertyId = (ushort)PropertyId.PidTagReceivedRepresentingAddressType; propertyTagList[2].PropertyType = (ushort)PropertyType.PtypString; propertyTagList[3].PropertyId = (ushort)PropertyId.PidTagReceivedRepresentingEmailAddress; propertyTagList[3].PropertyType = (ushort)PropertyType.PtypString; propertyTagList[4].PropertyId = (ushort)PropertyId.PidTagReceivedRepresentingName; propertyTagList[4].PropertyType = (ushort)PropertyType.PtypString; propertyTagList[5].PropertyId = (ushort)PropertyId.PidTagReceivedRepresentingSearchKey; propertyTagList[5].PropertyType = (ushort)PropertyType.PtypBinary; propertyTagList[6].PropertyId = (ushort)PropertyId.PidTagDelegatedByRule; propertyTagList[6].PropertyType = (ushort)PropertyType.PtypBoolean; uint contentTableHandler = 0; int expectedMessageIndex = 0; RopQueryRowsResponse getNormalMailMessageContent = this.GetExpectedMessage(this.InboxFolderHandle, ref contentTableHandler, propertyTagList, ref expectedMessageIndex, mailSubject); #endregion #region Get TestUser1's information from address book // Let TestUser1 log on to the server. this.LogonMailbox(TestUser.TestUser1); PropertyTagArray_r ptags = new PropertyTagArray_r { Values = 5, AulPropTag = AdapterHelper.SerializeRecipientProperties() }; // The Windows NSPI will be invoked when the first parameter is domain name instead of server address. PropertyRowSet_r? propertyRows = this.OxoruleAdapter.GetRecipientInfo(this.Domain, this.User1Name, this.Domain, this.User1Password, ptags); Site.Assert.IsNotNull(propertyRows, "The recipient information returned by the NSPI service should not be null"); int user1Index = 0; for (int i = 0; i < propertyRows.Value.Rows; i++) { if (Encoding.Unicode.GetString(propertyRows.Value.PropertyRowSet[i].Props[3].Value.LpszW).ToLower(System.Globalization.CultureInfo.CurrentCulture) == this.User1Name.ToLower(System.Globalization.CultureInfo.CurrentCulture)) { user1Index = i; break; } } // The two EntryId should be the same. AddressBookEntryID addressbookEntryId = new AddressBookEntryID(); addressbookEntryId.Deserialize(propertyRows.Value.PropertyRowSet[user1Index].Props[0].Value.Bin.Lpb); byte[] pidTagReceivedRepresentingEntryIdbytesTemp = getNormalMailMessageContent.RowData.PropertyRows[expectedMessageIndex].PropertyValues[1].Value; byte[] pidTagReceivedRepresentingEntryIdbytes = new byte[pidTagReceivedRepresentingEntryIdbytesTemp.Length - 2]; Array.Copy(pidTagReceivedRepresentingEntryIdbytesTemp, 2, pidTagReceivedRepresentingEntryIdbytes, 0, pidTagReceivedRepresentingEntryIdbytes.Length); AddressBookEntryID mailEntryID = new AddressBookEntryID(); mailEntryID.Deserialize(pidTagReceivedRepresentingEntryIdbytes); string subject = AdapterHelper.PropertyValueConvertToString(getNormalMailMessageContent.RowData.PropertyRows[expectedMessageIndex].PropertyValues[0].Value); #region Capture Code // Add the debug information. Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXORULE_R539"); // Verify MS-OXORULE requirement: MS-OXORULE_R539. Site.CaptureRequirementIfAreEqual<string>( mailSubject, subject, 539, @"[In Processing Incoming Messages to a Folder] [Following is a description of what the server does when it executes each action (2) type, as specified in section 2.2.5.1.1, for an incoming message] ""OP_DELEGATE"": the server MUST resend the message to the recipients (2) specified in the action buffer structure."); string pidTagEntryIdOfMailboxUser = addressbookEntryId.ValueOfX500DN.ToLower(System.Globalization.CultureInfo.CurrentCulture); string pidTagReceivedRepresentingEntryId = mailEntryID.ValueOfX500DN.ToLower(System.Globalization.CultureInfo.CurrentCulture); // Add the debug information. Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXORULE_R540"); // Verify MS-OXORULE requirement: MS-OXORULE_R540. Site.CaptureRequirementIfAreEqual<string>( pidTagReceivedRepresentingEntryId, pidTagEntryIdOfMailboxUser, 540, @"[In Processing Incoming Messages to a Folder] [Following is a description of what the server does when it executes each action (2) type, as specified in section 2.2.5.1.1, for an incoming message] ""OP_DELEGATE"": The server also MUST set the values of the following properties to match the current user's properties in the address book: The PidTagReceivedRepresentingEntryId property ([MS-OXOMSG] section 2.2.1.25) MUST be set to the same value as the mailbox user's PidTagEntryId property ([MS-OXOABK] section 2.2.3.3)."); string pidTagReceivedRepresentingAddressType = Encoding.Unicode.GetString(getNormalMailMessageContent.RowData.PropertyRows[expectedMessageIndex].PropertyValues[2].Value); // The actual value of pidTagReceivedRepresentingAddressType should not contain the last '\0' character. pidTagReceivedRepresentingAddressType = pidTagReceivedRepresentingAddressType.Substring(0, pidTagReceivedRepresentingAddressType.Length - 1); // In this test case, the mailbox user's PidTagAddressType is "EX". string pidTagAddressTypeOfMailboxUser = System.Text.UTF8Encoding.Unicode.GetString(propertyRows.Value.PropertyRowSet[user1Index].Props[1].Value.LpszW); // Add the debug information. Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXORULE_R541"); // Verify MS-OXORULE requirement: MS-OXORULE_R541. Site.CaptureRequirementIfAreEqual<string>( pidTagReceivedRepresentingAddressType, pidTagAddressTypeOfMailboxUser, 541, @"[In Processing Incoming Messages to a Folder] [Following is a description of what the server does when it executes each action (2) type, as specified in section 2.2.5.1.1, for an incoming message] ""OP_DELEGATE"": The PidTagReceivedRepresentingAddressType property ([MS-OXOMSG] section 2.2.1.23) MUST be set to the same value as the mailbox user's PidTagAddressType property ([MS-OXOABK] section 2.2.3.13)."); string pidTagReceivedRepresentingEmailAddress = Encoding.Unicode.GetString(getNormalMailMessageContent.RowData.PropertyRows[expectedMessageIndex].PropertyValues[3].Value); // The actual value of PidTagReceivedRepresentingEmailAddress should not contain the last '\0' character. pidTagReceivedRepresentingEmailAddress = pidTagReceivedRepresentingEmailAddress.Substring(0, pidTagReceivedRepresentingEmailAddress.Length - 1).ToUpperInvariant(); // In this test case, the mailbox user's PidTagEmailAddress is the adminUserDN. string pidTagEmailAddressOfMailboxUser = Encoding.Unicode.GetString(propertyRows.Value.PropertyRowSet[user1Index].Props[2].Value.LpszW).ToUpperInvariant(); // Add the debug information. Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXORULE_R542"); // Verify MS-OXORULE requirement: MS-OXORULE_R542. Site.CaptureRequirementIfAreEqual<string>( pidTagReceivedRepresentingEmailAddress, pidTagEmailAddressOfMailboxUser, 542, @"[In Processing Incoming Messages to a Folder] [Following is a description of what the server does when it executes each action (2) type, as specified in section 2.2.5.1.1, for an incoming message] ""OP_DELEGATE"": The PidTagReceivedRepresentingEmailAddress property ([MS-OXOMSG] section 2.2.1.24) MUST be set to the same value as the mailbox user's PidTagEmailAddress property ([MS-OXOABK] section 2.2.3.14)."); string pidTagReceivedRepresentingName = AdapterHelper.PropertyValueConvertToString(getNormalMailMessageContent.RowData.PropertyRows[expectedMessageIndex].PropertyValues[4].Value).ToLower(System.Globalization.CultureInfo.CurrentCulture); // In this test case, the mailbox user's PidTagDisplayName is "administrator". string pidTagDisplayNameOfMailboxUser = Encoding.Unicode.GetString(propertyRows.Value.PropertyRowSet[user1Index].Props[3].Value.LpszW).ToLower(System.Globalization.CultureInfo.CurrentCulture); // Add the debug information. Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXORULE_R543"); // Verify MS-OXORULE requirement: MS-OXORULE_R543. Site.CaptureRequirementIfAreEqual<string>( pidTagReceivedRepresentingName, pidTagDisplayNameOfMailboxUser, 543, @"[In Processing Incoming Messages to a Folder] [Following is a description of what the server does when it executes each action (2) type, as specified in section 2.2.5.1.1, for an incoming message] ""OP_DELEGATE"": The PidTagReceivedRepresentingName property ([MS-OXOMSG] section 2.2.1.26) MUST be set to the same value as the mailbox user's PidTagDisplayName property ([MS-OXCFOLD] section 2.2.2.2.2.5)."); byte[] pidTagReceivedRepresentingSearchKeyOfbytes = getNormalMailMessageContent.RowData.PropertyRows[expectedMessageIndex].PropertyValues[5].Value; byte[] pidTagReceivedRepresentingSearchKey = AdapterHelper.PropertyValueConvertToBinary(pidTagReceivedRepresentingSearchKeyOfbytes); byte[] pidTagSearchKeyOfMailboxUser = propertyRows.Value.PropertyRowSet[user1Index].Props[4].Value.Bin.Lpb; // Add the debug information. Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXORULE_R544: the value of PidTagReceivedRepresentingSearchKey is {0}", pidTagSearchKeyOfMailboxUser); // Verify MS-OXORULE requirement: MS-OXORULE_R544. bool isVerifyR544 = Common.CompareByteArray(pidTagSearchKeyOfMailboxUser, pidTagReceivedRepresentingSearchKey); Site.CaptureRequirementIfIsTrue( isVerifyR544, 544, @"[In Processing Incoming Messages to a Folder] [Following is a description of what the server does when it executes each action (2) type, as specified in section 2.2.5.1.1, for an incoming message] ""OP_DELEGATE"": The PidTagReceivedRepresentingSearchKey property ([MS-OXOMSG] section 2.2.1.27) MUST be set to the same value as the mailbox user's PidTagSearchKey property ([MS-OXCPRPT] section 2.2.1.9)."); // BitConverter.ToBoolean() is used to convert a byte array to a bool value from the byte array index of 0. bool pidTagDelegatedByRule = BitConverter.ToBoolean(getNormalMailMessageContent.RowData.PropertyRows[expectedMessageIndex].PropertyValues[6].Value, 0); // Add the debug information. Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXORULE_R545"); // Verify MS-OXORULE requirement: MS-OXORULE_R545. Site.CaptureRequirementIfIsTrue( pidTagDelegatedByRule, 545, @"[In Processing Incoming Messages to a Folder] [Following is a description of what the server does when it executes each action (2) type, as specified in section 2.2.5.1.1, for an incoming message] ""OP_DELEGATE"": The PidTagDelegatedByRule property ([MS-OXOMSG] section 2.2.1.84) MUST be set to ""TRUE""."); #endregion #endregion #region TestUser1 calls RopGetRulesTable with valid TableFlags. RopGetRulesTableResponse ropGetRulesTableResponse; uint ruleTableHandle = this.OxoruleAdapter.RopGetRulesTable(this.InboxFolderHandle, TableFlags.Normal, out ropGetRulesTableResponse); Site.Assert.AreEqual<uint>(0, ropGetRulesTableResponse.ReturnValue, "Getting rule table should succeed."); #endregion #region TestUser1 calls RopQueryRows to retrieve rows from the rule table PropertyTag[] propertyTags = new PropertyTag[2]; propertyTags[0].PropertyId = (ushort)PropertyId.PidTagRuleName; propertyTags[0].PropertyType = (ushort)PropertyType.PtypString; propertyTags[1].PropertyId = (ushort)PropertyId.PidTagRuleActions; propertyTags[1].PropertyType = (ushort)PropertyType.PtypRuleAction; // Retrieves rows from the rule table. RopQueryRowsResponse queryRowResponse = this.OxoruleAdapter.QueryPropertiesInTable(ruleTableHandle, propertyTags); Site.Assert.AreEqual<uint>(0, queryRowResponse.ReturnValue, "Retrieving rows from the rule table should succeed."); ForwardDelegateActionData forwardDelegateActionDataOfQueryRowResponse = new ForwardDelegateActionData(); RuleAction ruleAction = new RuleAction(); for (int i = 0; i < queryRowResponse.RowCount; i++) { System.Text.UnicodeEncoding converter = new UnicodeEncoding(); string ruleName = converter.GetString(queryRowResponse.RowData.PropertyRows.ToArray()[i].PropertyValues[0].Value); if (ruleName == ruleProperties.Name + "\0") { // Verify structure RuleAction ruleAction.Deserialize(queryRowResponse.RowData.PropertyRows[i].PropertyValues[1].Value); forwardDelegateActionDataOfQueryRowResponse.Deserialize(ruleAction.Actions[0].ActionDataValue.Serialize()); break; } } #region Capture Code // Add the debug information this.Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXORULE_R1003"); // Verify MS-OXORULE requirement: MS-OXORULE_R1003 this.Site.CaptureRequirementIfIsInstanceOfType( forwardDelegateActionDataOfQueryRowResponse.RecipientsData, typeof(RecipientBlock[]), 1003, @"[In OP_FORWARD and OP_DELEGATE ActionData Structure] RecipientBlocks (variable): An array of RecipientBlockData structures, each of which specifies information about one recipient (2)."); for (int i = 0; i < forwardDelegateActionDataOfQueryRowResponse.RecipientsData.Length; i++) { // Add the debug information this.Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXORULE_R1006"); // Verify MS-OXORULE requirement: MS-OXORULE_R1006 this.Site.CaptureRequirementIfIsInstanceOfType( forwardDelegateActionDataOfQueryRowResponse.RecipientsData[i].PropertiesData, typeof(TaggedPropertyValue[]), 1006, @"[In RecipientBlockData Structure] PropertyValues (variable): An array of TaggedPropertyValue structures, each of which contains a property that provides some information about the recipient (2)."); } #endregion #endregion }
/// <summary> /// Submit a message to the server /// </summary> /// <param name="mailTo">The user name of the recipient</param> /// <param name="mailToUserDN">The userDN of the recipient</param> /// <param name="subject">The subject of the mail</param> /// <param name="addedProperties">The added properties of the mail</param> /// <returns>Return code of the message delivering</returns> public uint DeliverMessageToTriggerRule(string mailTo, string mailToUserDN, string subject, TaggedPropertyValue[] addedProperties) { RopCreateMessageResponse createMsgRes; uint msgHandle = this.OxoruleAdapter.RopCreateMessage(outBoxFolderHandle, outBoxFolderID, 0, out createMsgRes); TaggedPropertyValue[] clientSpecificProperties = new TaggedPropertyValue[1]; clientSpecificProperties[0] = new TaggedPropertyValue(); PropertyTag propertyTag = new PropertyTag { PropertyId = (ushort)PropertyId.PidTagSubject, PropertyType = (ushort)PropertyType.PtypString }; clientSpecificProperties[0].PropertyTag = propertyTag; clientSpecificProperties[0].Value = Encoding.Unicode.GetBytes(subject + "\0"); this.OxoruleAdapter.RopSetProperties(msgHandle, clientSpecificProperties); if (addedProperties != null && addedProperties.Length > 0) { this.OxoruleAdapter.RopSetProperties(msgHandle, addedProperties); } #region recipientColumns, PropertyTag[] sampleRecipientColumns // The following sample data is from MS-OXCMSG 4.7.1 PropertyTag[] sampleRecipientColumns = new PropertyTag[12]; PropertyTag tag = new PropertyTag { PropertyId = (ushort)PropertyId.PidTagObjectType, PropertyType = (ushort)PropertyType.PtypInteger32 }; // PidTagObjectType sampleRecipientColumns[0] = tag; // PidTagDisplayType tag.PropertyId = (ushort)PropertyId.PidTagDisplayType; tag.PropertyType = (ushort)PropertyType.PtypInteger32; sampleRecipientColumns[1] = tag; // PidTagAddressBookDisplayNamePrintable tag.PropertyId = (ushort)PropertyId.PidTagAddressBookDisplayNamePrintable; tag.PropertyType = (ushort)PropertyType.PtypString; sampleRecipientColumns[2] = tag; // PidTagSmtpAddress tag.PropertyId = (ushort)PropertyId.PidTagSmtpAddress; tag.PropertyType = (ushort)PropertyType.PtypString; sampleRecipientColumns[3] = tag; // PidTagSendInternetEncoding tag.PropertyId = (ushort)PropertyId.PidTagSendInternetEncoding; tag.PropertyType = (ushort)PropertyType.PtypInteger32; sampleRecipientColumns[4] = tag; // PidTagDisplayTypeEx tag.PropertyId = (ushort)PropertyId.PidTagDisplayTypeEx; tag.PropertyType = (ushort)PropertyType.PtypInteger32; sampleRecipientColumns[5] = tag; // PidTagRecipientDisplayName tag.PropertyId = (ushort)PropertyId.PidTagRecipientDisplayName; tag.PropertyType = (ushort)PropertyType.PtypString; sampleRecipientColumns[6] = tag; // PidTagRecipientFlags tag.PropertyId = (ushort)PropertyId.PidTagRecipientFlags; tag.PropertyType = (ushort)PropertyType.PtypInteger32; sampleRecipientColumns[7] = tag; // PidTagRecipientTrackStatus tag.PropertyId = (ushort)PropertyId.PidTagRecipientTrackStatus; tag.PropertyType = (ushort)PropertyType.PtypInteger32; sampleRecipientColumns[8] = tag; // PidTagRecipientResourceState tag.PropertyId = (ushort)PropertyId.PidTagRecipientResourceState; tag.PropertyType = (ushort)PropertyType.PtypInteger32; sampleRecipientColumns[9] = tag; // PidTagRecipientOrder tag.PropertyId = (ushort)PropertyId.PidTagRecipientOrder; tag.PropertyType = (ushort)PropertyType.PtypInteger32; sampleRecipientColumns[10] = tag; // PidTagRecipientEntryId tag.PropertyId = (ushort)PropertyId.PidTagRecipientEntryId; tag.PropertyType = (ushort)PropertyType.PtypBinary; sampleRecipientColumns[11] = tag; #endregion #region Configure a StandardPropertyRow: propertyRow PropertyValue[] propertyValueArray = new PropertyValue[12]; for (int i = 0; i < propertyValueArray.Length; i++) { propertyValueArray[i] = new PropertyValue(); } // PidTagObjectType propertyValueArray[0].Value = BitConverter.GetBytes(0x00000006); // PidTagDisplayType propertyValueArray[1].Value = BitConverter.GetBytes(0x00000000); // PidTagAddressBookDisplayNamePrintable propertyValueArray[2].Value = Encoding.Unicode.GetBytes(mailTo + "\0"); // PidTagSmtpAddress propertyValueArray[3].Value = Encoding.Unicode.GetBytes(mailTo + "@" + this.Domain + "\0"); // PidTagSendInternetEncoding propertyValueArray[4].Value = BitConverter.GetBytes(0x00000000); // PidTagDisplayTypeEx propertyValueArray[5].Value = BitConverter.GetBytes(0x40000000); // PidTagRecipientDisplayName propertyValueArray[6].Value = Encoding.Unicode.GetBytes(mailTo + "\0"); // PidTagRecipientFlags propertyValueArray[7].Value = BitConverter.GetBytes(0x00000001); // PidTagRecipientTrackStatus propertyValueArray[8].Value = BitConverter.GetBytes(0x00000000); // PidTagRecipientResourceState propertyValueArray[9].Value = BitConverter.GetBytes(0x00000000); // PidTagRecipientOrder propertyValueArray[10].Value = BitConverter.GetBytes(0x00000000); AddressBookEntryID addressBookEntryID = new AddressBookEntryID(mailToUserDN); propertyValueArray[11].Value = Common.AddInt16LengthBeforeBinaryArray(addressBookEntryID.Serialize()); List<PropertyValue> propertyValues = new List<PropertyValue>(); for (int i = 0; i < propertyValueArray.Length; i++) { propertyValues.Add(propertyValueArray[i]); } PropertyRow propertyRow = new PropertyRow { Flag = 0x01, PropertyValues = propertyValues }; #endregion RecipientRow recipientRow = new RecipientRow { RecipientFlags = 0x065B, DisplayName = Encoding.Unicode.GetBytes(mailTo + "\0"), EmailAddress = Encoding.Unicode.GetBytes(mailTo + "@" + this.Domain + "\0"), SimpleDisplayName = Encoding.Unicode.GetBytes(mailTo + "\0"), RecipientColumnCount = 0x000C, RecipientProperties = propertyRow }; ModifyRecipientRow modifyRecipientRow = new ModifyRecipientRow { RowId = 0x00000000, RecipientType = 0x01, RecipientRowSize = (ushort)recipientRow.Size(), RecptRow = recipientRow.Serialize() }; ModifyRecipientRow[] sampleModifyRecipientRows = new ModifyRecipientRow[1]; sampleModifyRecipientRows[0] = modifyRecipientRow; this.OxoruleAdapter.RopModifyRecipients(msgHandle, sampleRecipientColumns, sampleModifyRecipientRows); this.OxoruleAdapter.RopSaveChangesMessage(msgHandle); RopSubmitMessageResponse submitMsgRes = this.OxoruleAdapter.RopSubmitMessage(msgHandle, 0); return submitMsgRes.ReturnValue; }