Search code failing in MOSS 2007 zone with anonymous access

Tech-Archive recommends: Speed Up your PC by fixing your registry



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

.



Relevant Pages

  • RE: IE automatic logon does not work after XP SP2
    ... IIS security on the web servers involved. ... > users that try to access company web sites that require authentication. ... > intranet zone and zone specific settings tell IE to try automatic logon. ...
    (microsoft.public.windowsxp.general)
  • MOSS 2007 Extranet Authentication problem
    ... I have a web application in Sharepoint 2007. ... zone Extranet ... For the default zone I have set the authentication to Windows - ... and for the extranet zone I have set it to Forms (the ...
    (microsoft.public.sharepoint.portalserver)
  • Re: Sharepoint authentication
    ... Under Internet Options> Security ... Settings for the zone the site is in make sure that User Authentication is ...
    (microsoft.public.sharepoint.portalserver)
  • Re: Getting 401.1 when using DNS, okay using NETBIOS and Localhost
    ... Internet address, hence why you recieve a prompt for login box. ... make sure your DNS name is included within your Intranet ... zone in IE. ... Integrated Windows Authentication may not work over the Internet - ...
    (microsoft.public.inetserver.iis.security)
  • Re: Getting prompted on IIS web
    ... Add the FQDN to the intranet or trusted zone and the problem ought to go ... > We have run a .NET app on a test and prod server for months. ... > Authentication method has not changed, only the URL now uses the entire> domain name. ...
    (microsoft.public.inetserver.iis.security)