Enabling Anonymous Access to a BCS External List

I co-presented a webinar this week for ShareSquared on using the Business Connectivity Service (BCS) to integrate application data into SharePoint.  A recording of the webinar is available here.  One of the questions that came up in the Q&A was from someone who was having a problem exposing a Business Connectivity Service (BCS) External List for anonymous access on an Internet facing site.  They had already configured the BCS content type to authenticate using the BDC Identity (RevertToSelf authentication) and had setup AllowAnonymousExecute on all the method instances, but still were being required to authenticate in order to see the list.  According to them this worked in SharePoint 2007 BDC, but something was preventing it from working in BCS.  There wasn’t really enough room in the Q&A document we published after the webinar to go into detail so this post will explain why it didn’t work and a step by step solution to the problem.

For the purpose of this post I will assume that you have already successfully configured an External Content type to use BDC Identity as its security setting.  Using any of the other three settings (User’s Identity, Impersonate Windows Identity, or Impersonate Custom Identity) won’t work with anonymous access because they are all dependent on the logged on User’s Identity and anonymous users have no identity.  You can read more about how to configure an External Content type to use the BDC Identity setting in this post on the BCS Team Blog:  http://blogs.msdn.com/b/bcs/archive/2010/03/12/authenticating-to-your-external-system.aspx.

The BDC Identity setting uses the Application Pool Identity of the Web Application as the security context for retrieving the data from database for an external content type.  But even if you use the BDC Identity setting an anonymous user will get an Access denied by Business Data Connectivity error like the one in the screenshot below.

BCSAccessDenied

The problem is that BCS requires that a user have access to the external content type in the BCS service application to access BCS data.  BDC Identity handles how the BCS service app gets the data from the backend data source, but does nothing to give an anonymous user access to the data in the service app itself.  This is one of the most frequently overlooked steps when configuring an external content type using SharePoint Designer (SPD) 2010.  After configuring an external content type in SPD you must set user permissions for the content type in Central administration.  These permissions are displayed in SPD, but can’t be set in SPD.

But anonymous users by definition aren’t logged in so how can we set permissions for them in central admin?  There is a built-in group called NT Authority\anonymous Logon that represents all anonymous users. But when we try to add that group to the BCS permissions in Central Admin it fails, as you can see from the screenshot below.  So how can we give anonymous users permission to access a BCS external content type?

bcs1a

The answer is that although you can’t set these permissions in the user interface you can set them by editing the XML of the underlying BDC model directly.  The XML of the BDC model for the external content type includes <AccessControlEntry> elements that specify what rights an individual user or group has to the BCS external content type.  Adding users to the BCS permissions in the UI creates additional entries in the XML of the model.  To give anonymous users access to the BCS model we need to add the following entry to several <AccessControlList> elements in the BDC model’s XML.

<AccessControlEntry Principal="NT Authority\Anonymous Logon">
  <Right BdcRight="Execute" />
</AccessControlEntry>

 

Here is the step by step procedure to add AccessControlEntries for anonymous users to the BDC model:

  1. In Central Admin Manage the BCS service application you created and add the Execute right for a specific user.  This will give you an entry that you can do a search and replace on in the XML file later.

    ExecuteRight

  2. Go back to SharePoint Designer and export the default model for your external content type.  Once you’ve exported it you can rename it or delete it. (You need to do this or you won’t be able to import your edited copy later)

     spdexport

  3. Now edit the BDC model XML file that you exported. Do a search and replace for the user you added and replace them with ‘NT AUTHORITY\ANONYMOUS LOGON’
  4. Go back to Central Admin and use the Import button on the ribbon to import the edited BDC model into your BCS service app. When you return to SPD 2010 your edited External Content type will now display like the original.

    bcsImport

  5. Do an IISreset to make sure that you flush any BCS caching that is in place

After completing the above steps you can browse out to your anonymous access site and access the external list you created from your external content type.  As you can see from the screenshot below anonymous users now have access to the BCS external content type and the BDC Identity can now access and display the data.

BCSAccessWorks

Published by

Paul Papanek Stork

I am a SharePoint MVP who has specialized in Microsoft products since the mid-1990s. As a "Jack of all Trades" I have developed expertise as a network administrator, developer, and DBA. I works as a consultant/trainer where my breadth of knowledge makes me ideally suited to combine Administrative, Development, and SharePoint Designer topics. My 20+ years of experience and broad background make me a much sought after resource for SharePoint questions that cross traditional boundaries. I was a contributing author to the Developer's Guide to Windows SharePoint Services v3 Platform and the SharePoint Server 2007 Deployment Best Practices. My most recent book, the MCTS Windows SharePoint Services 3.0 Configuration Study Guide: Exam 70-631, was released in October, 2009.

6 thoughts on “Enabling Anonymous Access to a BCS External List”

  1. Glad to hear that, but I tried again and still can't get it to add via the UI. If you can add it, then just assign the execute permission to it and you won't have to edit the XML.

  2. This post was good, paul. I did need to access the links to the other related sites to finish it off, but was the best approach to anonymous BCS access I’ve found.

Leave a Reply

Your email address will not be published. Required fields are marked *