Working Around Restricted SharePoint Method for Reading List Items as an Anonymous User

When an anonymous user is trying to access your SharePoint site application data through one of the Infragistics SharePoint web parts, she or he might receive the following message:

image

This is caused since the method GetItems, listed in the message, is defined as a restricted type thus preventing anonymous users for accessing it. This method is used by the client object model for retrieving data in sandbox solutions, including the Infragistics SharePoint web parts.

The solution

Unfortunately, Microsoft did not provide a GUI for removing methods from the restricted types list – you will have to do this through the SharePoint Management Shell console. That means you will need administrative access to the SharePoint server.

1. Get a reference to your web application using the code:

$wa = Get-SPWebApplication -Identity http://mysharepointwebapplication/

The $wa variable would be further used in the scripts

Now you can optionally check if the GetItems method is restricted for your web application. You can do by calling the following script:

$wa.ClientCallableSettings.AnonymousRestrictedTypes

 

This will give you the following:

image

In the MethodNames you can see that GetItems is listed as a restricted type.

2. Remove the GetItems method from the restricted list

Using the following command, removes the GetItems method from the restricted types:

$wa.ClientCallableSettings.AnonymousRestrictedTypes.Remove(
[Microsoft.SharePoint.SPList],"GetItems")

 

If you would like to restrict the GetItems method again, just use Add instead of Remove in above script.

3. Update your web application

The last thing you need to do is to update your web application using the update method as follows:

$wa.Update()

Finally you can check if the GetItems method has been properly removed from the restricted types list, running again the following script:

$wa.ClientCallableSettings.AnonymousRestrictedTypes

 

image

As you can see from the screenshot above, the GetItems method has been successfully unlisted from the restricted methods list.

Now anonymous users will be able to see data inside the web parts without error.

SNAGHTML42d58d6f

Official NetAdvantage for SharePoint Web Site: http://www.infragistics.com/dotnet/netadvantage/sharepoint.aspx#Overview

Official NetAdvantage for SharePoint Samples: http://sharepoint.infragistics.com/


Tags /

Add a Comment

Be the first one to add a comment. Please Login or Register to add comment.