I was trying to create a Custom Search Security Trimmer using ISecurityTrimmer2 of SharePoint . While I was able to get it working, I am struck as I am not able to get the reference of the Current SPSite inside the CheckAccess method. SPContext and HTTPContext is null. Any idea how do I get it ?

  • Where is the CheckAccess method ? or if you add code to your question might help identifying the problem/ Commented Feb 12, 2013 at 21:15
  • CheckAccess is part of ISecurityTrimmer2 . It was not about the code but concept. Example is present in the link I posted with question.
    – Kusek
    Commented Apr 29, 2013 at 16:18

1 Answer 1


There was a elevated code present in master page that caused this context to be always. It was not normal SPSecurity.RunWith... Stuff but old school method so that context was always there , it took a while to figure out and I had opened a MS Ticket as well. Finally I figured it out as code was working fine in a simple sample.

  • Are you saying that running with elevated in your masterpage caused the security trimmer to not set a HTTPContext?
    – James Love
    Commented Jun 27, 2013 at 14:30
  • Our Code for somereason had WindowsIdentity.Impersonate(System.IntPtr.Zero); so context was always elevated.
    – Kusek
    Commented Jun 28, 2013 at 21:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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