SharePoint 2010 – Access a list in Central Admin

My Problem

I tried many different option to access a list in Central Administation from a web part in my application. Of course the problem is that the application pool acccount cannot access the list and there are many variations of access denied that I found on my way….

Your solution

// Get the Url for Central admin

SPAdministrationWebApplication caWebApp = Microsoft.SharePoint.Administration.SPAdministrationWebApplication.Local;
// open the list Service
Lists listService = new Lists();
listService.Url = caWebApp.Sites[0].RootWeb.Url + “/_vti_bin/Lists.asmx”;

// Set the credentials to use

listService.UseDefaultCredentials = true;
listService.PreAuthenticate = true;

Hopefully this will help someone else one day.

Advertisements

Please leave a comment or feedback

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.