Search code failing in MOSS 2007 zone with anonymous access
- From: Jason Weber (Magenic) <Jason Weber (Magenic)@discussions.microsoft.com>
- Date: Sun, 13 Jul 2008 16:51:08 -0700
The following code works fine in a MOSS 2007 publishing site in the default
zone with NTLM authentication.
private void composeAndExecuteQuery2()
{
using (Query qry = new FullTextSqlQuery(ServerContext.Current))
{
qry.ResultTypes = ResultType.RelevantResults;
qry.EnableStemming = true;
qry.TrimDuplicates = true;
qry.QueryText = composeSqlQuery();
// see the following link for the rationale behind the next two lines
//
http://blogs.msdn.com/harsh/archive/2007/01/17/custom-search-and-url-zones.aspx
// NOTE: The following SPSite object should not be disposed!
SPSite site = SPControl.GetContextSite(HttpContext.Current);
qry.SiteContext = new Uri(site.Url);
try
{
ResultTableCollection rtc = qry.Execute();
ResultTable rt = rtc[ResultType.RelevantResults];
if (rt.TotalRows == 0)
{
message = "No Search Results.";
return;
}
DataTable resultTable = new DataTable();
resultTable.TableName = "Relevant Results";
resultDataSet = new DataSet("resultsset");
resultDataSet.Tables.Add(resultTable);
resultDataSet.Load(rt, LoadOption.OverwriteChanges, resultTable);
}
catch (Exception ex)
{
throw new Exception(qry.QueryText + Environment.NewLine + ex.Message,
ex);
}
}
}
However, when the containing web app is extended into the Internet zone, and
anonymous access is enabled, the above code always returns an empty set.
This is true even as the built-in MOSS search returns the results in question
for the anonymous user (same as this code in the authenticated zone). So
this does not appear to be a case where the search results are correctly
being hidden (trimmed) from the anonymous user.
Stranger still, upon the search service going down, we discovered that this
code running anonymously did not throw any errors! When running in the
authenticated zone it throws the search service not found error in this case.
When running in the anonymous Internet zone it simply continues to return
the empty result set. This seems to suggest that the search service is never
being called in the anonymous zone.
Any insights into why we're seeing this behavior and/or how to get this code
working correctly for the anonymous user would be most welcome. Thank you,
-Jason
P.S: Orinally posted at:
http://forums.microsoft.com/forums/ShowPost.aspx?PostID=3603494&SiteID=1
.
- Prev by Date: Re: Export Data into Templates
- Next by Date: Re: Sharepoint designer - Sending notifications to the workflow creato
- Previous by thread: Re: Export Data into Templates
- Next by thread: Import from SQL Server
- Index(es):
Relevant Pages
|