I'm facing a problem with Search Server Express and Impersonation. I have an application which impersonate with user token and then launch a query by a KeywordQuery.
Suppose I have to impersonate the user USERX. I open site with the USERX Token so that I'm sure I'm impersonating it. If I do any operation this is logged as "USERX" (as write a new Item in a List) but if I search I get no results even if I have accessible items.
If I access from web interface and use the same query string search server returns me 30 results, so the problem is in the code or in the config...
Here is the simple code I'm trying to use:
var user = //...GettingMySPUser with web.EnsureUser("i05...)
var token = user.Token;
using (SPSite scSite = new SPSite(fullsite, token))
{
using (SPWeb webGroup = scSite.OpenWeb())
{
KeywordQuery keywordQuery = new KeywordQuery(scSite);
keywordQuery.ResultTypes = ResultType.RelevantResults;
keywordQuery.QueryText = "Cancellato:false";
ResultTableCollection searchResultTables = keywordQuery.Execute();
var searchResult = searchResultTables[ResultType.RelevantResults];
while (searchResult.Read())
{
string url = searchResult["Path"].ToString().Trim().ToLower();
}
}
}