Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

I'm currently working with a client, one of the requirements is that users have complete access to the search results, regardless user permissions, including anonymous users, Is there a way to disable security trimming?, I have tried running the core results web part with elevated privileges but it doesn’t seem to work for anonymous users.

Thanks!

share|improve this question
    
maybe by setting a policy for a specific user on the web application ? –  Steve B Jun 18 '12 at 15:30
add comment

2 Answers

up vote 1 down vote accepted

I finally found how to run the core results webpart with elevated privileges, here is the code in case someone else needs it:

    protected override XPathNavigator GetXPathNavigator(string viewPath)
    {
        XmlDocument CustomXml = null;
        string UserQuery = "";
        QueryManager QM = SharedQueryManager.GetInstance(Page, QueryNumber).QueryManager;
        UserQuery = QM.UserQuery;
        QueryManager SourceManager = SharedQueryManager.GetInstance(Page, QueryNumber).QueryManager;   
        SPSecurity.RunWithElevatedPrivileges(delegate()
        {
            SearchQueryAndSiteSettingsServiceProxy settingsProxy = SPFarm.Local.ServiceProxies.GetValue<SearchQueryAndSiteSettingsServiceProxy>();
            SearchServiceApplicationProxy searchProxy = settingsProxy.ApplicationProxies.GetValue<SearchServiceApplicationProxy>("Search Service Application");
            QueryManager queryManager = new QueryManager();
            LocationList LocalList = new LocationList();
            Location localSearchLocation = new Location("LocalSearchIndex", searchProxy);
            LocalList.Add(localSearchLocation);
            queryManager.UserQuery = UserQuery;
            queryManager.Add(LocalList);
            queryManager.IsTriggered(LocalList);
            CustomXml = queryManager.GetResults(LocalList);
        });
        XPathNavigator xPathNavigator = CustomXml.CreateNavigator(); 
        return xPathNavigator;
    }

Edit: Although this works to get all the search results, the refinement panel, and paging web part stopped working, I’m currently looking for a way to fix this.

share|improve this answer
    
I have tried your solution it is working fine thanks for shearing this code. Now i am facing same problem "refinement panel, and paging web part stopped working" for that i have created new thread so could you please answer the following link if you have any solution for that sharepoint.stackexchange.com/questions/66993/… –  Pankaj Apr 29 '13 at 6:45
    
sharepoint.stackexchange.com/questions/66993/… solves your issue –  ali Sharepoint Apr 29 '13 at 9:37
    
I added an answer to the above referenced question about refinement panels: sharepoint.stackexchange.com/a/78028/9842 –  lgaud Sep 24 '13 at 17:16
add comment

You could try calling the Search web service from elevated code. Just a thought, never tried it before. FWIW this seems like a really odd requirement :)

share|improve this answer
    
Thanks! I will give it a try, and yes it’s a really an odd requirement the reason they gave us for wanting this is that they want to expose all of their content in the search results page, and if the user clicks the element and he/she doesn’t have the necessary permissions, the user will have to e-mail a specific person or a group of people and ask for permissions, and they will check if the user really needs to see that content. –  Hugo Molina Jun 14 '12 at 16:31
add comment

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.