Bugfix for What's New Web Part & RSS Feed for SharePoint
Several people reported some problems with the What’s New RSS Feed for SharePoint and the What’s New WebPart. When a user doesn’t has access to a SharePoint list, both components will try to obtain the necessary rights: the webpart will prompt for a new login and the RSS Feed will produce some “unexpected behaviour”. Before I jump into the technical details, here are the links to download the latest versions:
-
Leadit.SharePoint.Essentials 1.1.2.0 (contains the webpart)
MSI Installer
Source code -
Leadit.SharePoint.Services 1.0.1.0 (contains the RSS feed)
Binaries
Source code
For each SharePoint list on a SharePoint site, the
components need to check if the currently logged on user
has rights to view the list. I did this using following
line:
list.Permissions.DoesUserHavePermissions(SPRights.ViewListItems)
It
seems that there are some problems using the
DoesUserHavePermissions method,
Philip Wheat goes into detail.
Patrick Tisseghem recently posted
his solution, and
Philip responded. Anyway, I’ve used following code snippet to solve the
issue:
private bool UserCanViewListItems(SPWeb web, SPList
list)
{
try
{
list.Permissions.CheckPermissions(Microsoft.SharePoint.SPRights.ViewListItems);
return true;
}
catch
{
return false;
}
}
To use the function make sure you set the
CatchAccessDeniedException property of the current site to
false, eg:
web.Site.CatchAccessDeniedException = false;
Kudos to the SharePoint community: thanks guys!