Tom Clarkson
Tom Clarkson

Reputation: 16174

AccessDenied.aspx / List does not exist on list that user has access to

I am getting this error:

List does not exist The page you selected contains a list that does not exist. It may have been deleted by another user. at Microsoft.SharePoint.Library.SPRequestInternalClass.GetListsWithCallback...

Unfortunately it's not the unpublished masterpage manifestation of the error - the list GUID in the query string leads to one of several lists in the root web that are used to display user settings in controls on the master page.

The list is being accessed using the following code:

_RootWeb = SPContext.Current.Site.RootWeb;
storageList = _RootWeb.GetList(_RootWeb.Url + "/Lists/" + 
                              LocalStrings.TimeZoneStorageList.ListName);
SPListItemCollection result = list.GetItems(query);
SPListItem StorageItem = result[0];

xmlDoc.LoadXml(StorageItem[LocalStrings.TimeZoneStorageList.Fields.UserXML]
                                                                   .ToString());

Is there anything that could cause that code to throw an AccessDeniedException while the user is able to access the list through the UI?

Alternatively, is it possible for SharePoint to report a list as the source of the error when the permissions issue is actually somewhere else entirely?

Upvotes: 0

Views: 2051

Answers (4)

JDandChips
JDandChips

Reputation: 10100

The issue for me was quite simple. I had a user who had permissions to the current site, which was fine. However, there was a list web part on the page I got the error that accessed items from a sub site in which the current user didn't have access.

In my case the error should have read "access denied for list".

Upvotes: 0

Tom Clarkson
Tom Clarkson

Reputation: 16174

The List ID in the query string on AccessDenied.aspx can in fact be unrelated to the actual error. The relevant code was something like

try {
    throw new AccessDeniedException();
    } 
catch (Exception ex) {}

storageList = _RootWeb.GetList(ListUrl);  

If CatchAccessDeniedException is not disabled, SharePoint will see the exception despite the catch and abort the thread. Since this is controlled on another thread, it's not synchronous and the code continues to run long enough that the thread aborts in the middle of accessing the list.

Both parts of the error message are technically correct - There was an AccessDeniedException, and the last operation was trying to open the list - but there is no actual connection between the two.

The actual problem turned out to be service account permissions on mysites, which naturally never appeared in any logs or error messages.

Upvotes: 0

Rich Bennema
Rich Bennema

Reputation: 10335

Is there anything that could cause that code to throw an AccessDeniedException while the user is able to access the list through the UI?

This might not apply in your case, but yes, I have had this happen with:

  1. Lookup fields where the user did not have permissions to the lookup list
  2. People fields filtered to a chosen SharePoint Group where the user did not have permissions to view the membership of the group.

In both cases, these fields were not included in the views or forms normally used by the user so the problem was not immediately discovered.

Upvotes: 1

Madhur Ahuja
Madhur Ahuja

Reputation: 22661

Can you try getting your list as

_RootWeb.Lists[strListName]

where strListName is the Title of the list.

Upvotes: 0

Related Questions