SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. Join them; it only takes a minute:

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

Is there a way to get items from a list even if the current user does not actually have acces to them? SPSecurity.RunWithElevatedPrivileges does not seem to work!

I have a special case in which I need to access some items from a list, items that respect a certain filter. The filter can return items that belong to other users and these are not returned.

But I need them to collect some information and display it to the user! The user won't see the items to which he does not have access to, but the information I'm displaying needs to take them into account.

Is it possible to do this without setting/removing permissions programmatically?

share|improve this question
up vote 4 down vote accepted

Well, SPSecurity.RunWithElevatedPrivileges should do the trick. Make sure, you create a new SPSite/SPWeb within the elevated code block:

var siteId = SPContext.Current.Site.ID;
  using (SPSite site = new SPSite(siteId))
    //do things on the new site object
share|improve this answer
+1 for reminding me that the objects retrieved outside the delegate code run with the outside context and not under privileged context. My brain stepped out for a moment there... – JohnDoDo May 14 '12 at 12:52
Your code snippet isn't disposing of the SPSite you create, you need to have both the site and web creating in a using block. – Servy May 14 '12 at 16:33
@Servy - I can't see a problem in that code - the using will dispose of the SPSite he's created and he hasn't created SPWeb. – Ryan May 15 '12 at 8:07

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.