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

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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 ?

share|improve this question
Where is the CheckAccess method ? or if you add code to your question might help identifying the problem/ – Muhammad Raja Feb 12 '13 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 Apr 29 '13 at 16:18
up vote 0 down vote accepted

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.

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

Your Answer


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.