/// <summary> /// Composes the RopSynchronizationImportDeletes Request Buffer. /// This ROP synchronizes deleted messages or folders. More detailed information about this operation can be found in [MS-OXCFXICS]. /// </summary> /// <param name="inputServerObjectHandle">The handle for the input Server Object.</param> /// <param name="propertyValue">Array of TaggedPropertyValue structures which are used to specify the folders or messages to delete.</param> /// <returns>The rgbIn buffer generated by this method.</returns> public byte[] ComposeRopSynchronizationImportDeletes(uint inputServerObjectHandle, TaggedPropertyValue propertyValue) { RopSynchronizationImportDeletesRequest ropSynchronizationImportDeletesRequest = new RopSynchronizationImportDeletesRequest(); TaggedPropertyValue[] propertyValues = new TaggedPropertyValue[1]; propertyValues[0] = propertyValue; ropSynchronizationImportDeletesRequest.RopId = (byte)RopId.RopSynchronizationImportDeletes; ropSynchronizationImportDeletesRequest.LogonId = Convert.ToByte(0); ropSynchronizationImportDeletesRequest.InputHandleIndex = Convert.ToByte(0); // The 0x02 indicates HardDelete. ropSynchronizationImportDeletesRequest.IsHierarchy = (byte)0x02; ropSynchronizationImportDeletesRequest.PropertyValueCount = (ushort)propertyValues.Length; ropSynchronizationImportDeletesRequest.PropertyValues = propertyValues; List <ISerializable> requestRops = new List <ISerializable> { ropSynchronizationImportDeletesRequest }; List <uint> requestSOH = new List <uint> { inputServerObjectHandle }; return(this.BuildRequestBuffer(requestRops, requestSOH)); }
/// <summary> /// Deserialize the AndRestriction data. /// </summary> /// <param name="restrictionData">The restriction data.</param> public override void Deserialize(byte[] restrictionData) { int index = 0; this.RestrictType = (RestrictType)restrictionData[index]; if (this.RestrictType != RestrictType.ContentRestriction) { throw new ArgumentException("The restrict type is not ContentRestriction type."); } index++; this.FuzzyLevelLow = (FuzzyLevelLowValues)BitConverter.ToInt16(restrictionData, index); index += 2; this.FuzzyLevelHigh = (FuzzyLevelHighValues)BitConverter.ToInt16(restrictionData, index); index += 2; index += this.PropertyTag.Deserialize(restrictionData, index); Context.Instance.PropertyBytes = restrictionData; Context.Instance.CurIndex = index; Context.Instance.CurProperty = new Property((PropertyType)this.PropertyTag.PropertyType); this.TaggedValue = new TaggedPropertyValue(); this.TaggedValue.Parse(Context.Instance); }
/// <summary> /// Build a RestrictionData as single ContentRestriction /// </summary> /// <param name="taggedPValue">A TaggedPropertyValue of this restriction</param> /// <returns>Byte array of Restriction Data</returns> public static byte[] GenerateContentRestriction(TaggedPropertyValue taggedPValue) { ContentRestrictions result = new ContentRestrictions { FuzzyLevelLow = ContentRestrictions.FuzzyLevelLowValue.FL_SUBSTRING, FuzzyLevelHigh = ContentRestrictions.FuzzyLevelHighValue.FL_IGNORECASE, PropertyTag = taggedPValue.PropertyTag, TaggedValue = taggedPValue }; return(result.Serialize()); }
/// <summary> /// Parse the PermissionData structure. /// </summary> /// <param name="s">An stream containing PermissionData structure.</param> public override void Parse(Stream s) { base.Parse(s); this.PermissionDataFlags = (PermissionDataFlags)ReadByte(); this.PropertyValueCount = ReadUshort(); List <TaggedPropertyValue> listPropertyValues = new List <TaggedPropertyValue>(); for (int i = 0; i < PropertyValueCount; i++) { TaggedPropertyValue tempPropertyValue = new TaggedPropertyValue(); tempPropertyValue.Parse(s); listPropertyValues.Add(tempPropertyValue); } this.PropertyValues = listPropertyValues.ToArray(); }
/// <summary> /// Parse the RecipientBlockData structure. /// </summary> /// <param name="s">A stream containing the RecipientBlockData structure</param> public override void Parse(Stream s) { base.Parse(s); this.Reserved = ReadByte(); this.NoOfProperties = ReadUshort(); List <TaggedPropertyValue> propertyValues = new List <TaggedPropertyValue>(); for (int i = 0; i < NoOfProperties; i++) { TaggedPropertyValue propertyValue = new TaggedPropertyValue(); propertyValue.Parse(s); propertyValues.Add(propertyValue); } this.PropertyValues = propertyValues.ToArray(); }
/// <summary> /// Parse the RuleData structure. /// </summary> /// <param name="s">A stream containing the RuleData structure</param> public override void Parse(System.IO.Stream s) { base.Parse(s); this.RuleDataFlags = (RuleDataFlags)ReadByte(); this.PropertyValueCount = ReadUshort(); List <TaggedPropertyValue> tempPropertyValues = new List <TaggedPropertyValue>(); for (int i = 0; i < this.PropertyValueCount; i++) { TaggedPropertyValue temptaggedPropertyValue = new TaggedPropertyValue(CountWideEnum.twoBytes); temptaggedPropertyValue.Parse(s); tempPropertyValues.Add(temptaggedPropertyValue); } this.PropertyValues = tempPropertyValues.ToArray(); }
/// <summary> /// Read a TaggedPropertyValue structure from buffer. /// </summary> /// <param name="buffer">Buffer contain TaggedPropertyValue instance</param> /// <returns>A TaggedPropertyvalue structure</returns> public static TaggedPropertyValue ReadTaggedProperty(byte[] buffer) { TaggedPropertyValue tagValue = new TaggedPropertyValue(); BufferReader bufferReader = new BufferReader(buffer); PropertyTag newPropertyTag = new PropertyTag { PropertyType = bufferReader.ReadUInt16(), PropertyId = bufferReader.ReadUInt16() }; tagValue.PropertyTag = newPropertyTag; tagValue.Value = ReadValueByType(tagValue.PropertyTag.PropertyType, bufferReader.ReadToEnd()); return(tagValue); }
/// <summary> /// Deserialized byte array to a Restriction instance /// </summary> /// <param name="buffer">Byte array contain data of a Restriction instance.</param> /// <returns>Bytes count that deserialized in buffer.</returns> public override uint Deserialize(byte[] buffer) { BufferReader reader = new BufferReader(buffer); this.RestrictType = (RestrictionType)reader.ReadByte(); this.RelOp = (RelationalOperator)reader.ReadByte(); this.propTag.PropertyType = reader.ReadUInt16(); this.propTag.PropertyId = reader.ReadUInt16(); uint size = reader.Position; byte[] tmpArray = reader.ReadToEnd(); this.TaggedValue = AdapterHelper.ReadTaggedProperty(tmpArray); size += (uint)this.TaggedValue.Size(); return(size); }
/// <summary> /// Deserialized byte array to an Restriction instance /// </summary> /// <param name="buffer">Byte array contain data of an Restriction instance</param> /// <returns>Bytes count that deserialized in buffer</returns> public uint Deserialize(byte[] buffer) { BufferReader reader = new BufferReader(buffer); this.RestrictType = (RestrictionType)reader.ReadByte(); this.FuzzyLevelLow = (FuzzyLevelLowValue)reader.ReadUInt16(); this.FuzzyLevelHigh = (FuzzyLevelHighValue)reader.ReadUInt16(); this.propertyTag.PropertyId = reader.ReadUInt16(); this.propertyTag.PropertyType = reader.ReadUInt16(); uint size = reader.Position; byte[] tmpArray = reader.ReadToEnd(); this.TaggedValue = AdapterHelper.ReadTaggedProperty(tmpArray); size += (uint)this.TaggedValue.Size(); return(size); }
/// <summary> /// Deserialize the OrRestriction data. /// </summary> /// <param name="restrictionData">The restriction data.</param> public override void Deserialize(byte[] restrictionData) { int index = 0; this.RestrictType = (Restrictions)restrictionData[index]; if (this.RestrictType != Restrictions.ContentRestriction) { throw new ArgumentException("The restrict type is not ContentRestriction type."); } index++; this.FuzzyLevel = BitConverter.ToUInt32(restrictionData, index); index += 4; index += this.PropTag.Deserialize(restrictionData, index); Context.Instance.PropertyBytes = restrictionData; Context.Instance.CurIndex = index; Context.Instance.CurProperty = new Property(PropertyType.PtypUnspecified); TaggedPropertyValue taggedPropertyValue = new TaggedPropertyValue(); taggedPropertyValue.Parse(Context.Instance); this.TaggedValue = taggedPropertyValue; }
/// <summary> /// Parse the AddressBookPropValueList structure. /// </summary> /// <param name="rawData">The raw data of response buffer.</param> /// <param name="index">The start index.</param> /// <returns>Instance of the AddressBookPropValueList.</returns> public static AddressBookPropValueList Parse(byte[] rawData, ref int index) { AddressBookPropValueList addressBookPropValueList = new AddressBookPropValueList(); addressBookPropValueList.PropertyValueCount = BitConverter.ToUInt32(rawData, index); index += sizeof(uint); Context.Instance.PropertyBytes = rawData; Context.Instance.CurIndex = index; Context.Instance.CurProperty = new Property(PropertyType.PtypUnspecified); addressBookPropValueList.PropertyValues = new TaggedPropertyValue[addressBookPropValueList.PropertyValueCount]; for (int i = 0; i < addressBookPropValueList.PropertyValueCount; i++) { // Parse the TaggedPropertyValue from the response buffer. TaggedPropertyValue taggedPropertyValue = new TaggedPropertyValue(); taggedPropertyValue.Parse(Context.Instance); addressBookPropValueList.PropertyValues[i] = taggedPropertyValue; } index = Context.Instance.CurIndex; return addressBookPropValueList; }
/// <summary> /// Deserialized byte array to a ForwardActionData instance /// </summary> /// <param name="buffer">Byte array contains data of an ActionData instance.</param> /// <returns>Bytes count that deserialized in buffer.</returns> public uint Deserialize(byte[] buffer) { BufferReader bufferReader = new BufferReader(buffer); this.Reserved = bufferReader.ReadByte(); uint count = 0; if (this.CountType == CountByte.TwoBytesCount) { this.NoOfProperties = bufferReader.ReadUInt16(); this.PropertiesData = new TaggedPropertyValue[(ushort)this.NoOfProperties]; count = (uint)(ushort)this.NoOfProperties; } else if (this.CountType == CountByte.FourBytesCount) { this.NoOfProperties = bufferReader.ReadUInt32(); this.PropertiesData = new TaggedPropertyValue[(uint)this.NoOfProperties]; count = (uint)this.NoOfProperties; } uint size = bufferReader.Position; byte[] tmpArray = bufferReader.ReadToEnd(); for (uint i = 0; i < count; i++) { TaggedPropertyValue tagValue = AdapterHelper.ReadTaggedProperty(tmpArray); this.PropertiesData[i] = tagValue; uint tagSize = (uint)tagValue.Size(); size += tagSize; bufferReader = new BufferReader(tmpArray); tmpArray = bufferReader.ReadBytes(tagSize, (uint)(tmpArray.Length - tagSize)); } return(size); }
/// <summary> /// Composes the RopSynchronizationImportMessageChange Request Buffer. /// This ROP imports new messages or full changes to existing messages into the server replica. More detailed information about this operation can be found in [MS-OXCFXICS]. /// </summary> /// <param name="inputServerObjectHandle">The handle for the input Server Object.</param> /// <param name="importFlag">Value for ImportFlags field.</param> /// <returns>The rgbIn buffer generated by this method.</returns> public byte[] ComposeRopSynchronizationImportMessageChange(uint inputServerObjectHandle, byte importFlag) { RopSynchronizationImportMessageChangeRequest ropSynchronizationImportMessageChangeRequest = new RopSynchronizationImportMessageChangeRequest(); TaggedPropertyValue[] propertyValues = new TaggedPropertyValue[1]; TaggedPropertyValue proValue = new TaggedPropertyValue(); PropertyTag propertyTag = new PropertyTag { PropertyId = (ushort)PropertyID.PidTagLastModificationTime, PropertyType = (ushort)PropertyType.PtypTime }; proValue.PropertyTag = propertyTag; proValue.Value = new byte[ConstValues.PtypTimeByteSize]; propertyValues[0] = proValue; ropSynchronizationImportMessageChangeRequest.RopId = (byte)RopId.RopSynchronizationImportMessageChange; ropSynchronizationImportMessageChangeRequest.LogonId = Convert.ToByte(0); ropSynchronizationImportMessageChangeRequest.InputHandleIndex = Convert.ToByte(0); ropSynchronizationImportMessageChangeRequest.OutputHandleIndex = Convert.ToByte(ConstValues.OutputHandleIndexForOneRop); ropSynchronizationImportMessageChangeRequest.ImportFlag = importFlag; ropSynchronizationImportMessageChangeRequest.PropertyValueCount = (ushort)propertyValues.Length; ropSynchronizationImportMessageChangeRequest.PropertyValues = propertyValues; List <ISerializable> requestRops = new List <ISerializable> { ropSynchronizationImportMessageChangeRequest }; List <uint> requestSOH = new List <uint> { // 0xFFFFFFFF is the default value for server output object handle. inputServerObjectHandle, ConstValues.DefaultOutputHandle }; return(this.BuildRequestBuffer(requestRops, requestSOH)); }
/// <summary> /// Add rule action to the properties list /// </summary> /// <param name="list">The properties list for a rule action</param> /// <param name="actionType">The action Type</param> /// <param name="actionData">The actionData</param> /// <param name="actionFlavor">The actionFlavor of the action</param> /// <param name="actionFlag">The action flag value.</param> private static void AddRuleAction(IList <TaggedPropertyValue> list, ActionTypes actionType, IActionData actionData, uint actionFlavor, uint actionFlag) { TaggedPropertyValue pidTagRuleActions = new TaggedPropertyValue(); PropertyTag pidTagRuleActionsPropertyTag = new PropertyTag { PropertyId = (ushort)TestPropertyName.PidTagRuleActions, PropertyType = (ushort)PropertyTypeName.PtypRuleAction }; pidTagRuleActions.PropertyTag = pidTagRuleActionsPropertyTag; switch (actionType) { case ActionTypes.OP_MARK_AS_READ: case ActionTypes.OP_DELETE: pidTagRuleActions.Value = GenerateRuleAction(actionType, Count.TwoBytesCount, new DeleteMarkReadActionData(), actionFlavor, actionFlag).Serialize(); break; case ActionTypes.OP_MOVE: case ActionTypes.OP_COPY: case ActionTypes.OP_FORWARD: case ActionTypes.OP_DEFER_ACTION: case ActionTypes.OP_TAG: case ActionTypes.OP_DELEGATE: case ActionTypes.OP_BOUNCE: case ActionTypes.OP_OOF_REPLY: case ActionTypes.OP_REPLY: pidTagRuleActions.Value = GenerateRuleAction(actionType, Count.TwoBytesCount, actionData, actionFlavor, actionFlag).Serialize(); break; default: Site.Assert.Fail("The actionType is {0}, this is not a valid action type", actionType); break; } list.Add(pidTagRuleActions); }
/// <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); }
/// <summary> /// Add ruleCondition to the properties list /// </summary> /// <param name="list">The properties list of a rule</param> /// <param name="mailSubjectContent">The mail subject of the content restriction</param> private static void AddRuleCondition(IList <TaggedPropertyValue> list, string mailSubjectContent) { TaggedPropertyValue pidTagRuleCondition = new TaggedPropertyValue(); PropertyTag pidTagRuleConditionPropertyTag = new PropertyTag { PropertyId = (ushort)TestPropertyName.PidTagRuleCondition, PropertyType = (ushort)PropertyTypeName.PtypRestriction }; pidTagRuleCondition.PropertyTag = pidTagRuleConditionPropertyTag; TaggedPropertyValue taggedProperty = new TaggedPropertyValue(); PropertyTag taggedPropertyPropertyTag = new PropertyTag { PropertyId = (ushort)TestPropertyName.PidTagSubject, PropertyType = (ushort)PropertyTypeName.PtypString }; taggedProperty.PropertyTag = taggedPropertyPropertyTag; taggedProperty.Value = Encoding.Unicode.GetBytes(mailSubjectContent + "\0"); pidTagRuleCondition.Value = GenerateContentRestriction(taggedProperty); list.Add(pidTagRuleCondition); }
public void MSOXORULE_S04_TC03_ServerExecuteRule_Action_OP_TAG_OnPublicFolder() { this.CheckMAPIHTTPTransportSupported(); #region TestUser1 logs on to the public folder. RopOpenFolderResponse openFolderResponse; RopLogonResponse logonResponse; bool ret = this.OxoruleAdapter.Connect(ConnectionType.PublicFolderServer, this.User1Name, this.User1ESSDN, this.User1Password); Site.Assert.IsTrue(ret, "connect to public folder server should be successful"); uint publicFolderLogonHandler = this.OxoruleAdapter.RopLogon(LogonType.PublicFolder, this.User1ESSDN, out logonResponse); // Assert the client to log on to the public folder successfully. Site.Assert.AreEqual <uint>(0, logonResponse.ReturnValue, "Logon the public folder should be successful."); // Folder index 1 is the Interpersonal Messages subtree, and this is defined in MS-OXCSTOR. uint publicfolderHandler = this.OxoruleAdapter.RopOpenFolder(publicFolderLogonHandler, logonResponse.FolderIds[1], out openFolderResponse); // Get the store object's entry ID. this.GetStoreObjectEntryID(StoreObjectType.PublicFolder, this.Server, this.User1ESSDN); RopCreateFolderResponse createFolderResponse; string newFolderName = Common.GenerateResourceName(this.Site, Constants.FolderDisplayName); uint newFolderHandle = this.OxoruleAdapter.RopCreateFolder(publicfolderHandler, newFolderName, Constants.FolderComment, out createFolderResponse); ulong newFolderID = createFolderResponse.FolderId; Site.Assert.AreEqual <uint>(0, createFolderResponse.ReturnValue, "Creating folder operation should succeed."); #endregion #region TestUser1 prepares value for ruleProperties variable. RuleProperties ruleProperties = AdapterHelper.GenerateRuleProperties(this.Site, Constants.RuleNameTag); #endregion #region TestUser1 adds an OP_TAG rule to the new created folder. TagActionData tagActionData = new TagActionData(); PropertyTag tagActionDataPropertyTag = new PropertyTag { PropertyId = (ushort)PropertyId.PidTagImportance, PropertyType = (ushort)PropertyType.PtypInteger32 }; tagActionData.PropertyTag = tagActionDataPropertyTag; tagActionData.PropertyValue = BitConverter.GetBytes(1); RuleData ruleOpTag = AdapterHelper.GenerateValidRuleData(ActionType.OP_TAG, TestRuleDataType.ForAdd, 1, RuleState.ST_ENABLED, tagActionData, ruleProperties, null); RopModifyRulesResponse modifyRulesResponse = this.OxoruleAdapter.RopModifyRules(newFolderHandle, ModifyRuleFlag.Modify_ReplaceAll, new RuleData[] { ruleOpTag }); Site.Assert.AreEqual <uint>(0, modifyRulesResponse.ReturnValue, "Adding OP_TAG rule should succeed."); #endregion #region TestUser1 creates a message. RopCreateMessageResponse ropCreateMessageResponse; uint messageHandle = this.OxoruleAdapter.RopCreateMessage(newFolderHandle, newFolderID, Convert.ToByte(false), out ropCreateMessageResponse); Site.Assert.AreEqual <uint>(0, ropCreateMessageResponse.ReturnValue, "Creating message should succeed."); #endregion #region TestUser1 saves the subject property of the message to trigger the rule. string subjectName = Common.GenerateResourceName(this.Site, ruleProperties.ConditionSubjectName + "Title"); TaggedPropertyValue subjectProperty = new TaggedPropertyValue(); PropertyTag pidTagSubjectPropertyTag = new PropertyTag { PropertyId = (ushort)PropertyId.PidTagSubject, PropertyType = (ushort)PropertyType.PtypString }; subjectProperty.PropertyTag = pidTagSubjectPropertyTag; subjectProperty.Value = Encoding.Unicode.GetBytes(subjectName + "\0"); // Set properties for the created message to trigger the rule. RopSetPropertiesResponse ropSetPropertiesResponse = this.OxoruleAdapter.RopSetProperties(messageHandle, new TaggedPropertyValue[] { subjectProperty }); Site.Assert.AreEqual <uint>(0, ropSetPropertiesResponse.ReturnValue, "Setting property for the created message should succeed."); // Save changes of message. RopSaveChangesMessageResponse ropSaveChangesMessagResponse = this.OxoruleAdapter.RopSaveChangesMessage(messageHandle); Site.Assert.AreEqual <uint>(0, ropSaveChangesMessagResponse.ReturnValue, "Saving the created message should succeed."); // Wait for the message to be saved and the rule to take effect. Thread.Sleep(this.WaitForTheRuleToTakeEffect); #endregion #region TestUser1 gets the message and its properties to verify the rule evaluation. PropertyTag[] propertyTagList = new PropertyTag[2]; propertyTagList[0].PropertyId = (ushort)PropertyId.PidTagImportance; propertyTagList[0].PropertyType = (ushort)PropertyType.PtypInteger32; propertyTagList[1].PropertyId = (ushort)PropertyId.PidTagSubject; propertyTagList[1].PropertyType = (ushort)PropertyType.PtypString; uint contentTableHandle = 0; uint rowCount = 0; RopQueryRowsResponse getMailMessageContent = this.GetExpectedMessage(newFolderHandle, ref contentTableHandle, propertyTagList, ref rowCount, 1, subjectName); Site.Assert.AreEqual <uint>(1, rowCount, @"The message number in the specific folder should be 1."); Site.Assert.AreEqual <int>(1, BitConverter.ToInt32(getMailMessageContent.RowData.PropertyRows[(int)rowCount - 1].PropertyValues[0].Value, 0), "If the rule is executed, the PidTagImportance property of the message should be the value set by the rule."); RopDeleteFolderResponse deleteFolder = this.OxoruleAdapter.RopDeleteFolder(publicfolderHandler, newFolderID); Site.Assert.AreEqual <uint>(0, deleteFolder.ReturnValue, "Deleting folder should succeed."); #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); }
/// <summary> /// A method used to compose ROP command to execute ROP call. /// </summary> /// <param name="ropType">A parameter represents the ROP Type refers to a specific ROP call.</param> /// <param name="inputServerObjectHandle">A parameter represents an input Server object handle.</param> /// <param name="propertyValue">A parameter represents a TaggedPropertyValue structure.</param> /// <returns>A return value represents a byte array of serialized ROP command.</returns> public static byte[] ComposeRgbIn(ROPCommandType ropType, uint inputServerObjectHandle, TaggedPropertyValue propertyValue) { ComposeROPCommand composeROPCommand = new ComposeROPCommand(); switch (ropType) { case ROPCommandType.RopSynchronizationImportDeletes: return(composeROPCommand.ComposeRopSynchronizationImportDeletes(inputServerObjectHandle, propertyValue)); default: throw new InvalidCastException("Invalid ROP command type"); } }
/// <summary> /// Create sample RuleData array to modify the rules associated with a folder. /// </summary> /// <returns>Return RuleData array to be used in RopModifyRules request.</returns> protected RuleData[] CreateSampleRuleDataArrayForAdd() { int propertyValuesCount = 4; PropertyValue[] propertyValues = new PropertyValue[propertyValuesCount]; for (int i = 0; i < propertyValuesCount; i++) { propertyValues[i] = new PropertyValue(); } // As specified in section 2.2.1.3.2 in [MS-OXORULE], // when adding a PRULE, the client MUST NOT // pass in PidTagRuleId, it MUST pass in PidTagRuleCondition, // PidTagRuleActions and PidTagRuleProvider. TaggedPropertyValue taggedPropertyValue = new TaggedPropertyValue(); PropertyTag tempPropertyTag = new PropertyTag { PropertyId = 0x6676, PropertyType = 0003 }; taggedPropertyValue.PropertyTag = tempPropertyTag; byte[] value3 = { 0x00, 0x00, 0x00, 0x0a }; taggedPropertyValue.Value = value3; propertyValues[3].Value = taggedPropertyValue.Serialize(); // PidTagRuleCondition taggedPropertyValue = new TaggedPropertyValue(); tempPropertyTag.PropertyId = 0x6679; tempPropertyTag.PropertyType = 0x00fd; taggedPropertyValue.PropertyTag = tempPropertyTag; byte[] value = { 0x03, 0x01, 0x00, 0x01, 0x00, 0x1f, 0x00, 0x37, 0x00, 0x1f, 0x00, 0x37, 0x00, 0x50, 0x00, 0x72, 0x00, 0x6f, 0x00, 0x6a, 0x00, 0x65, 0x00, 0x63, 0x00, 0x74, 0x00, 0x20, 0x00, 0x58, 0x00, 0x00, 0x00 }; taggedPropertyValue.Value = value; propertyValues[1].Value = taggedPropertyValue.Serialize(); // PidTagRuleAction taggedPropertyValue = new TaggedPropertyValue(); tempPropertyTag.PropertyId = 0x6680; tempPropertyTag.PropertyType = 0x00fe; taggedPropertyValue.PropertyTag = tempPropertyTag; byte[] value1 = { 0x01, 0x00, 0x09, 0x00, 0x0B, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; taggedPropertyValue.Value = value1; propertyValues[2].Value = taggedPropertyValue.Serialize(); // PidTagRuleProvider taggedPropertyValue = new TaggedPropertyValue(); tempPropertyTag.PropertyId = 0x6681; tempPropertyTag.PropertyType = 0x001f; taggedPropertyValue.PropertyTag = tempPropertyTag; byte[] value2 = Encoding.Unicode.GetBytes("RuleOrganizer\0"); taggedPropertyValue.Value = value2; propertyValues[0].Value = taggedPropertyValue.Serialize(); RuleData sampleRuleData = new RuleData { RuleDataFlags = 0x01, PropertyValueCount = (ushort)propertyValues.Length, PropertyValues = propertyValues }; RuleData[] sampleRuleDataArray = new RuleData[1]; sampleRuleDataArray[0] = sampleRuleData; return(sampleRuleDataArray); }
/// <summary> /// Create Sample RuleData Array For Add. /// </summary> /// <returns>Return RuleData array</returns> private RuleData[] CreateSampleRuleDataArrayForAdd() { // Count of PropertyValues. int length = 4; TaggedPropertyValue[] propertyValues = new TaggedPropertyValue[length]; for (int i = 0; i < length; i++) { propertyValues[i] = new TaggedPropertyValue(); } TaggedPropertyValue taggedPropertyValue; // MS-OXORULE 2.2.1.3.2 // When adding a rule, the client MUST NOT pass in PidTagRuleId, it MUST pass in PidTagRuleCondition, // PidTagRuleActions and PidTagRuleProvider. // PidTagRuleSequence taggedPropertyValue = new TaggedPropertyValue { PropertyTag = { PropertyId = this.propertyDictionary[PropertyNames.PidTagRuleSequence].PropertyId, PropertyType = this.propertyDictionary[PropertyNames.PidTagRuleSequence].PropertyType } }; byte[] value3 = { 0x00, 0x00, 0x00, 0x0a }; taggedPropertyValue.Value = value3; propertyValues[3] = taggedPropertyValue; // PidTagRuleCondition taggedPropertyValue = new TaggedPropertyValue { PropertyTag = { PropertyId = this.propertyDictionary[PropertyNames.PidTagRuleCondition].PropertyId, PropertyType = this.propertyDictionary[PropertyNames.PidTagRuleCondition].PropertyType } }; byte[] value = { 0x03, 0x01, 0x00, 0x01, 0x00, 0x1f, 0x00, 0x37, 0x00, 0x1f, 0x00, 0x37, 0x00, 0x50, 0x00, 0x72, 0x00, 0x6f, 0x00, 0x6a, 0x00, 0x65, 0x00, 0x63, 0x00, 0x74, 0x00, 0x20, 0x00, 0x58, 0x00, 0x00, 0x00 }; taggedPropertyValue.Value = value; propertyValues[1] = taggedPropertyValue; // PidTagRuleActions taggedPropertyValue = new TaggedPropertyValue { PropertyTag = { PropertyId = this.propertyDictionary[PropertyNames.PidTagRuleActions].PropertyId, PropertyType = this.propertyDictionary[PropertyNames.PidTagRuleActions].PropertyType } }; byte[] value1 = { 0x01, 0x00, 0x09, 0x00, 0x0B, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; taggedPropertyValue.Value = value1; propertyValues[2] = taggedPropertyValue; // PidTagRuleProvider taggedPropertyValue = new TaggedPropertyValue { PropertyTag = { PropertyId = this.propertyDictionary[PropertyNames.PidTagRuleProvider].PropertyId, PropertyType = this.propertyDictionary[PropertyNames.PidTagRuleProvider].PropertyType } }; byte[] value2 = Encoding.Unicode.GetBytes("RuleOrganizerContoso\0"); taggedPropertyValue.Value = value2; propertyValues[0] = taggedPropertyValue; RuleData sampleRuleData = new RuleData { RuleDataFlags = (byte)RuleDataFlags.RowAdd, PropertyValueCount = (ushort)propertyValues.Length, PropertyValues = propertyValues }; RuleData[] sampleRuleDataArray = new RuleData[1]; sampleRuleDataArray[0] = sampleRuleData; return(sampleRuleDataArray); }
/// <summary> /// Generate a sample valid RuleData structure. /// </summary> /// <param name="actionType">ActionType in a rule</param> /// <param name="ruleDataType">Rule data value.</param> /// <param name="ruleSequence">Rule sequence in PidTagRuleSequence of the RuleData</param> /// <param name="ruleState">Specifies value of PidTagRuleState of the RuleData</param> /// <param name="actionData">The actionData needed to construct the RuleData</param> /// <param name="ruleProperties">Rule properties structure.</param> /// <returns>A valid RuleData structure</returns> public static RuleData GenerateValidRuleData(ActionTypes actionType, TestRuleDataType ruleDataType, int ruleSequence, RuleState ruleState, IActionData actionData, RuleProperties ruleProperties) { RuleData ruleData = new RuleData { RuleDataFlags = (byte)ruleDataType }; List <TaggedPropertyValue> propertyList = new List <TaggedPropertyValue>(); TaggedPropertyValue pidTagRuleSequence = new TaggedPropertyValue(); PropertyTag pidTagRuleSequencePropertyTag = new PropertyTag { PropertyId = (ushort)TestPropertyName.PidTagRuleSequence, PropertyType = (ushort)PropertyTypeName.PtypInteger32 }; pidTagRuleSequence.PropertyTag = pidTagRuleSequencePropertyTag; pidTagRuleSequence.Value = BitConverter.GetBytes(ruleSequence); propertyList.Add(pidTagRuleSequence); TaggedPropertyValue pidTagRuleLevel = new TaggedPropertyValue(); PropertyTag pidTagRuleLevelPropertyTag = new PropertyTag { PropertyId = (ushort)TestPropertyName.PidTagRuleLevel, PropertyType = (ushort)PropertyTypeName.PtypInteger32 }; pidTagRuleLevel.PropertyTag = pidTagRuleLevelPropertyTag; pidTagRuleLevel.Value = BitConverter.GetBytes(0); propertyList.Add(pidTagRuleLevel); TaggedPropertyValue pidTagRuleState = new TaggedPropertyValue(); PropertyTag pidTagRuleStatePropertyTag = new PropertyTag { PropertyId = (ushort)TestPropertyName.PidTagRuleState, PropertyType = (ushort)PropertyTypeName.PtypInteger32 }; pidTagRuleState.PropertyTag = pidTagRuleStatePropertyTag; pidTagRuleState.Value = BitConverter.GetBytes((uint)ruleState); propertyList.Add(pidTagRuleState); if (ruleProperties.Name.Length > 0) { TaggedPropertyValue pidTagRuleName = new TaggedPropertyValue(); PropertyTag pidTagRuleNamePropertyTag = new PropertyTag { PropertyId = (ushort)TestPropertyName.PidTagRuleName, PropertyType = (ushort)PropertyTypeName.PtypString }; pidTagRuleName.PropertyTag = pidTagRuleNamePropertyTag; pidTagRuleName.Value = Encoding.Unicode.GetBytes((string)ruleProperties.Name + "\0"); propertyList.Add(pidTagRuleName); } if (ruleProperties.Provider.Length > 0) { TaggedPropertyValue pidTagRuleProvider = new TaggedPropertyValue(); PropertyTag pidTagRuleProviderPropertyTag = new PropertyTag { PropertyId = (ushort)TestPropertyName.PidTagRuleProvider, PropertyType = (ushort)PropertyTypeName.PtypString }; pidTagRuleProvider.PropertyTag = pidTagRuleProviderPropertyTag; pidTagRuleProvider.Value = Encoding.Unicode.GetBytes((string)ruleProperties.Provider + "\0"); propertyList.Add(pidTagRuleProvider); } if (ruleProperties.UserFlag.Length > 0) { TaggedPropertyValue pidTagRuleUserFlags = new TaggedPropertyValue(); PropertyTag pidTagRuleUserFlagsPropertyTag = new PropertyTag { PropertyId = (ushort)TestPropertyName.PidTagRuleUserFlags, PropertyType = (ushort)PropertyTypeName.PtypInteger32 }; pidTagRuleUserFlags.PropertyTag = pidTagRuleUserFlagsPropertyTag; pidTagRuleUserFlags.Value = BitConverter.GetBytes(int.Parse(ruleProperties.UserFlag)); propertyList.Add(pidTagRuleUserFlags); } if (ruleProperties.ProviderData.Length > 0) { TaggedPropertyValue pidTagRuleProviderData = new TaggedPropertyValue(); PropertyTag pidTagRuleProviderDataPropertyTag = new PropertyTag { PropertyId = (ushort)TestPropertyName.PidTagRuleProviderData, PropertyType = (ushort)PropertyTypeName.PtypBinary }; pidTagRuleProviderData.PropertyTag = pidTagRuleProviderDataPropertyTag; pidTagRuleProviderData.Value = Common.GetBytesFromBinaryHexString(ruleProperties.ProviderData); pidTagRuleProviderData.Value = Common.AddInt16LengthBeforeBinaryArray(pidTagRuleProviderData.Value); propertyList.Add(pidTagRuleProviderData); } if (ruleProperties.ConditionSubjectName.Length > 0) { AddRuleCondition(propertyList, ruleProperties.ConditionSubjectName); AddRuleAction(propertyList, actionType, actionData, Constants.CommonActionFlavor, Constants.RuleActionFlags); } ruleData.PropertyValues = propertyList.ToArray(); ruleData.PropertyValueCount = (ushort)propertyList.Count; return(ruleData); }
/// <summary> /// The NspiSeekEntries method searches for and sets the logical position in a specific table /// to the first entry greater than or equal to a specified value. /// </summary> /// <param name="reserved">A DWORD value that is reserved for future use. Ignored by the server.</param> /// <param name="stat">A STAT block that describes a logical position in a specific address book container.</param> /// <param name="target">A PropertyValue_r value holding the value that is being sought.</param> /// <param name="table">The value NULL or a PropertyTagArray_r value. /// It holds a list of Minimal Entry IDs that comprise a restricted address book container.</param> /// <param name="propTags">It contains a list of the proptags of the columns /// that client wants to be returned for each row returned.</param> /// <param name="rows">It contains the address book container rows the server returns in response to the request.</param> /// <returns>Status of NSPI method.</returns> public ErrorCodeValue SeekEntries(uint reserved, ref STAT stat, PropertyValue_r target, PropertyTagArray_r? table, PropertyTagArray_r? propTags, out PropertyRowSet_r? rows) { ErrorCodeValue result; SeekEntriesRequestBody seekEntriesRequestBody = new SeekEntriesRequestBody(); TaggedPropertyValue targetValue = new TaggedPropertyValue(); targetValue.PropertyTag = new PropertyTag((ushort)((target.PropTag & 0xFFFF0000) >> 16), (ushort)(target.PropTag & 0x0000FFFF)); targetValue.Value = new byte[target.Serialize().Length - 8]; Array.Copy(target.Serialize(), 8, targetValue.Value, 0, target.Serialize().Length - 8); // Reserved. The client MUST set this field to 0x00000000 and the server MUST ignore this field. seekEntriesRequestBody.Reserved = reserved; seekEntriesRequestBody.HasState = true; seekEntriesRequestBody.State = stat; seekEntriesRequestBody.HasTarget = true; seekEntriesRequestBody.Target = targetValue; if (table != null) { seekEntriesRequestBody.HasExplicitTable = true; seekEntriesRequestBody.ExplicitTable = table.Value.AulPropTag; } LargePropTagArray propetyTags = new LargePropTagArray(); if (propTags != null) { propetyTags.PropertyTagCount = propTags.Value.CValues; propetyTags.PropertyTags = new PropertyTag[propetyTags.PropertyTagCount]; for (int i = 0; i < propTags.Value.CValues; i++) { propetyTags.PropertyTags[i].PropertyId = (ushort)((propTags.Value.AulPropTag[i] & 0xFFFF0000) >> 16); propetyTags.PropertyTags[i].PropertyType = (ushort)(propTags.Value.AulPropTag[i] & 0x0000FFFF); } seekEntriesRequestBody.HasColumns = true; seekEntriesRequestBody.Columns = propetyTags; } seekEntriesRequestBody.AuxiliaryBufferSize = 0; seekEntriesRequestBody.AuxiliaryBuffer = new byte[] { }; ChunkedResponse chunkedResponse = this.SendAddressBookRequest(seekEntriesRequestBody, RequestType.SeekEntries); SeekEntriesResponseBody seekEntriesResponseBody = SeekEntriesResponseBody.Parse(chunkedResponse.ResponseBodyRawData); result = (ErrorCodeValue)seekEntriesResponseBody.ErrorCode; if (seekEntriesResponseBody.HasColumnsAndRows) { PropertyRowSet_r newRows = AdapterHelper.ParsePropertyRowSet_r(seekEntriesResponseBody.Columns.Value, seekEntriesResponseBody.RowCount.Value, seekEntriesResponseBody.RowData); rows = newRows; } else { rows = null; } if (seekEntriesResponseBody.HasState) { stat = seekEntriesResponseBody.State.Value; } return result; }