Tell me more ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

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();
     }
                    }
                }
share|improve this question

1 Answer

up vote 0 down vote accepted

Reading Technet and other sources it appears to be a well know issue.

The suggestion I can give to who is in my same problem is to implement a Custom Security trimmer: use the token to access file is working, only pass it to the claim is not.

So if you do a thing like:

  • Loop with SPRunWithElevatedPrivileges
  • Collect all results
  • Open a Site with User Token
  • Try to access every single result
  • If Can access => return it
  • If Cannot => do not
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.