I am trying to perform a search for documents within a SharePoint site, but I need to apply audience targeting to the results before they are displayed to the user.
I am however struggling to either (a) retrieve the target audience settings within the original query...
using (SPSite site = new SPSite(SPContext.Current.Site.ID)) {
using (FullTextSqlQuery fullText = new FullTextSqlQuery(site)) {
fullText.QueryText = @"select Title, Path, Description, TargetAudience from scope() where ((""scope"" = 'All Sites'))"
+ @" and IsDocument = 1 and freetext(*, '{0}')";
fullText.QueryText = string.Format(fullText.QueryText, this.documentFilter.AllOfTheseWords);
fullText.ResultTypes = ResultType.RelevantResults;
ResultTableCollection resultTableCollection = fullText.Execute();
allofTheseWords = new DataTable();
if (resultTableCollection.Exists(ResultType.RelevantResults)) {
allofTheseWords.Load(resultTableCollection[ResultType.RelevantResults], LoadOption.OverwriteChanges);
}
}
}
or (b) retrieve the list item id (guid) from within the original query so that I can then tie up each result to the original list item (and therefore apply the audience targeting using the list item.
Any suggestions?