Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6945971
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T13:30:17+00:00 2026-05-27T13:30:17+00:00

I have 2 Site Collections, lets just call them A and B. In A

  • 0

I have 2 Site Collections, lets just call them A and B. In A I have a list of some content that I want to syncdicate across multiple site collections. I have created a custom content query web part that queries the data but I am running into a road block.

Because the user level accounts don’t have access to Site A at all, and I don’t want them to have access to this site at any level, I get an access denied error when my web part runs on site B. Is there a way to change the context through which RunWithElevatedPrivileges works?

My current code which runs from site collection B looks like

ClientContext clientContext = new ClientContext(siteAUrl);
SP.List oList = clientContext.Web.Lists.GetByTitle(listName);

CamlQuery query = new CamlQuery();
//Add View, Execute Query, etc.

return results;

If I wrap this in SPSecurity.RunWithElevatedPrivileges it runs with elevated within the site collection B context where I would rather it run within the Site collection A context.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T13:30:18+00:00Added an answer on May 27, 2026 at 1:30 pm

    The SharePoint 2010 client object model does not support SPSecurity.RunWithElevatedPrivileges. As @Nat states this call reverts the thread identity to the application pool account (SystemAccount). Since you’re code runs on the client, the identity can not be reverted to the application pool account.
    Running code as system account via the client object model would open a security hole. Everybody could write and execute code as an administrator.

    If your code runs on the server, you can use the SPUserToken.SystemAccount to open a SPSite with the system account credentials:

    using (SPSite site = new SPSite("http://someurl", SPUserToken.SystemAccount))
    {
      // admin action here
    }
    

    Check out my blog post How to Open a SPSite with System Account Credentials for more information.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to create a content type, lets call it MyDocument with some properties
I have to create a web part that displays all site collections under the
We have hundreds of document libraries, spread all throughout various site collections in a
I have a site collection and I want to set the search center value
I have a site in rails and want to have site-wide settings. One part
Situation: One WebApplication, two site collections. Both site collections have the same type and
I have created a console application which goes through all site collections and thier
I have a development site on my machine at localhost/~Jason/hfh/admin/?admin=collections My .htaccess file is
I have a site that I'm using Mongo on. So far everything is going
I have a task to show to the site admin a list of user

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.