1

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!

  • maybe by setting a policy for a specific user on the web application ? – Steve B Jun 18 '12 at 15:30
1

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.

0

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 :)

  • 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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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