/// <summary> /// Allocate memory for the specific property values. /// </summary> /// <param name="pta_r">PropertyTagArray_r instance.</param> /// <returns>A pointer points to memory allocated.</returns> public static IntPtr AllocPropertyTagArray_r(PropertyTagArray_r pta_r) { int offset = 0; int cb = (int)(sizeof(uint) + (pta_r.Values * sizeof(uint))); IntPtr ptr = Marshal.AllocHGlobal(cb); Marshal.WriteInt32(ptr, offset, (int)pta_r.Values); offset += sizeof(uint); for (int i = 0; i < pta_r.Values; i++) { Marshal.WriteInt32(ptr, offset, (int)pta_r.AulPropTag[i]); offset += sizeof(uint); } return(ptr); }
/// <summary> /// The NspiQueryRows method returns a number of rows from a specified table to the client. /// </summary> /// <param name="flags">A DWORD value that contains a set of bit flags.</param> /// <param name="stat">A STAT block that describes a logical position in a specific address book container.</param> /// <param name="tableCount">A DWORD value that contains the number values in the input parameter table. /// This value is limited to 100,000.</param> /// <param name="table">An array of DWORD values, representing an Explicit Table.</param> /// <param name="count">A DWORD value that contains the number of rows the client is requesting.</param> /// <param name="propTags">The value NULL or a reference to a PropertyTagArray_r value, /// containing a list of the proptags of the properties that the client requires to be returned for each row returned.</param> /// <param name="rows">A nullable PropertyRowSet_r value, it contains the address book container rows that the server returns in response to the request.</param> /// <returns>Status of NSPI method.</returns> public ErrorCodeValue QueryRows(uint flags, ref STAT stat, uint tableCount, uint[] table, uint count, PropertyTagArray_r? propTags, out PropertyRowSet_r? rows) { ErrorCodeValue result; QueryRowsRequestBody queryRowsRequestBody = new QueryRowsRequestBody(); LargePropTagArray propetyTags = new LargePropTagArray(); if (propTags != null) { propetyTags.PropertyTagCount = propTags.Value.Values; propetyTags.PropertyTags = new PropertyTag[propetyTags.PropertyTagCount]; for (int i = 0; i < propTags.Value.Values; i++) { propetyTags.PropertyTags[i].PropertyId = (ushort)((propTags.Value.AulPropTag[i] & 0xFFFF0000) >> 16); propetyTags.PropertyTags[i].PropertyType = (ushort)(propTags.Value.AulPropTag[i] & 0x0000FFFF); } queryRowsRequestBody.HasColumns = true; queryRowsRequestBody.Columns = propetyTags; } queryRowsRequestBody.Flags = flags; queryRowsRequestBody.HasState = true; queryRowsRequestBody.State = stat; queryRowsRequestBody.ExplicitTableCount = tableCount; queryRowsRequestBody.ExplicitTable = table; queryRowsRequestBody.RowCount = count; byte[] auxIn = new byte[] { }; queryRowsRequestBody.AuxiliaryBuffer = auxIn; queryRowsRequestBody.AuxiliaryBufferSize = (uint)auxIn.Length; ChunkedResponse chunkedResponse = this.SendAddressBookRequest(queryRowsRequestBody, RequestType.QueryRows); QueryRowsResponseBody queryRowsResponseBody = QueryRowsResponseBody.Parse(chunkedResponse.ResponseBodyRawData); result = (ErrorCodeValue)queryRowsResponseBody.ErrorCode; if (queryRowsResponseBody.RowCount != null) { PropertyRowSet_r newRows = AdapterHelper.ParsePropertyRowSet_r(queryRowsResponseBody.Columns.Value, queryRowsResponseBody.RowCount.Value, queryRowsResponseBody.RowData); rows = newRows; } else { rows = null; } if (queryRowsResponseBody.HasState) { stat = queryRowsResponseBody.State.Value; } return result; }
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> /// Allocate memory for the specific property values. /// </summary> /// <param name="pta_r">PropertyTagArray_r instance.</param> /// <returns>A pointer points to the allocated memory.</returns> public static IntPtr AllocPropertyTagArray_r(PropertyTagArray_r pta_r) { int offset = 0; int cb = (int)(sizeof(uint) + (pta_r.Values * sizeof(uint))); IntPtr ptr = Marshal.AllocHGlobal(cb); Marshal.WriteInt32(ptr, offset, (int)pta_r.Values); offset += sizeof(uint); for (int i = 0; i < pta_r.Values; i++) { Marshal.WriteInt32(ptr, offset, (int)pta_r.AulPropTag[i]); offset += sizeof(uint); } return ptr; }
/// <summary> /// The NspiQueryRows method returns a number of rows from a specified table to the client. /// </summary> /// <param name="flags">A DWORD value that contains a set of bit flags.</param> /// <param name="stat">A STAT block that describes a logical position in a specific address book container.</param> /// <param name="tableCount">A DWORD value that contains the number values in the input parameter table. /// This value is limited to 100,000.</param> /// <param name="table">An array of DWORD values, representing an Explicit Table.</param> /// <param name="count">A DWORD value that contains the number of rows the client is requesting.</param> /// <param name="propTags">The value NULL or a reference to a PropertyTagArray_r value, /// containing a list of the proptags of the properties that the client requires to be returned for each row returned.</param> /// <param name="rows">A nullable PropertyRowSet_r value, it contains the address book container rows that the server returns in response to the request.</param> /// <param name="needRetry">A bool value indicates if need to retry to get an expected result. This parameter is designed to avoid meaningless retry when an error response is expected.</param> /// <returns>Status of NSPI method.</returns> public ErrorCodeValue NspiQueryRows(uint flags, ref STAT stat, uint tableCount, uint[] table, uint count, PropertyTagArray_r? propTags, out PropertyRowSet_r? rows, bool needRetry = true) { int result; IntPtr ptrRows = IntPtr.Zero; IntPtr ptrPropTags = IntPtr.Zero; IntPtr ptrStat = AdapterHelper.AllocStat(stat); if (propTags != null) { ptrPropTags = AdapterHelper.AllocPropertyTagArray_r(propTags.Value); } int retryCount = 0; do { try { result = OxnspiInterop.NspiQueryRows(this.contextHandle, flags, ref stat, tableCount, table, count, ptrPropTags, out ptrRows); } catch (SEHException e) { result = (int)NativeMethods.RpcExceptionCode(e); this.site.Log.Add(LogEntryKind.Comment, "RPC component throws exception, the error code is {0}, the error message is: {1}", result, new Win32Exception(result).ToString()); } if ((ErrorCodeValue)result == ErrorCodeValue.GeneralFailure && needRetry) { Thread.Sleep(this.waitTime); } else { break; } retryCount++; } while ((ErrorCodeValue)result == ErrorCodeValue.GeneralFailure && retryCount < this.maxRetryCount); if (!Enum.IsDefined(typeof(ErrorCodeValue), (uint)result)) { throw new ArgumentException(string.Format("An unknown error is returned, the error code is: {0} and the error message is: {1}", result, new Win32Exception(result).ToString())); } if (propTags != null) { Marshal.FreeHGlobal(ptrPropTags); } // Parse rows according to ptrRows. if (ptrRows == IntPtr.Zero) { rows = null; } else { rows = AdapterHelper.ParsePropertyRowSet_r(ptrRows); } // Free stat. Marshal.FreeHGlobal(ptrStat); return (ErrorCodeValue)result; }
/// <summary> /// Get properties from NSPI table. /// </summary> /// <param name="server">Server address.</param> /// <param name="userName">The value of user name.</param> /// <param name="domain">The value of Domain.</param> /// <param name="password">Password of the user.</param> /// <param name="columns">PropertyTags to be query.</param> /// <returns>Results in PropertyRowSet format.</returns> public PropertyRowSet_r? GetRecipientInfo(string server, string userName, string domain, string password, PropertyTagArray_r? columns) { #region Call NspiBind method to initiate a session between the client and the server. uint flags = 0; STAT stat = new STAT(); stat.CodePage = 0x4e4; // Set a valid code page. stat.TemplateLocale = 0x409; // Set a valid LCID. stat.SortLocale = 0x409; // Set a valid LCID. // Set value for serverGuid FlatUID_r guid = new FlatUID_r { Ab = new byte[16] }; FlatUID_r? serverGuid = guid; ErrorCodeValue result = this.nspiAdapter.NspiBind(flags, stat, ref serverGuid); Site.Assert.AreEqual<ErrorCodeValue>(ErrorCodeValue.Success, result, "NspiBind should return Success!"); #endregion #region Call NspiQueryRows method to get the recipient information. stat.ContainerID = 0; // Set the container id to the id of default global address book container uint tableCount = 0; uint[] table = null; uint requestCount = 5000; PropertyRowSet_r? propertyRowSet = null; result = this.nspiAdapter.NspiQueryRows(flags, ref stat, tableCount, table, requestCount, columns, out propertyRowSet); Site.Assert.AreEqual<ErrorCodeValue>(ErrorCodeValue.Success, result, "NspiQueryRows should return Success!"); #endregion uint returnValue = this.nspiAdapter.NspiUnbind(0); Site.Assert.AreEqual<uint>(1, returnValue, "NspiUnbind method should return 1 (Success)."); return propertyRowSet; }