{"id":131,"date":"2010-07-30T09:31:07","date_gmt":"2010-07-30T13:31:07","guid":{"rendered":"http:\/\/www.dontpapanic.com\/blog\/?p=131"},"modified":"2010-07-30T10:13:29","modified_gmt":"2010-07-30T14:13:29","slug":"enabling-anonymous-access-to-a-bcs-external-list","status":"publish","type":"post","link":"https:\/\/www.dontpapanic.com\/blog\/?p=131","title":{"rendered":"Enabling Anonymous Access to a BCS External List"},"content":{"rendered":"<p>I co-presented a webinar this week for <a href=\"http:\/\/www.sharesquared.com\/\" target=\"_blank\">ShareSquared<\/a> on using the Business Connectivity Service (BCS) to integrate application data into SharePoint.&#160; A recording of the webinar is available <a href=\"https:\/\/www106.livemeeting.com\/cc\/sharesquaredinc\/view?id=D9RJCW&amp;pw=sm|5B\/\\4d\" target=\"_blank\">here<\/a>.&#160; One of the questions that came up in the Q&amp;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.&#160; 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.&#160; According to them this worked in SharePoint 2007 BDC, but something was preventing it from working in BCS.&#160; There wasn\u2019t really enough room in the Q&amp;A document we published after the webinar to go into detail so this post will explain why it didn\u2019t work and a step by step solution to the problem.<\/p>\n<p>For the purpose of this post I will assume that you have already successfully configured an External Content type to use <em>BDC Identity<\/em> as its security setting.&#160; Using any of the other three settings (User\u2019s Identity, Impersonate Windows Identity, or Impersonate Custom Identity) won\u2019t work with anonymous access because they are all dependent on the logged on User\u2019s Identity and anonymous users have no identity.&#160; You can read more about how to configure an External Content type to use the <em>BDC Identity<\/em> setting in this post on the BCS Team Blog:&#160; <a href=\"http:\/\/blogs.msdn.com\/b\/bcs\/archive\/2010\/03\/12\/authenticating-to-your-external-system.aspx\" target=\"_blank\">http:\/\/blogs.msdn.com\/b\/bcs\/archive\/2010\/03\/12\/authenticating-to-your-external-system.aspx<\/a>.<\/p>\n<p>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.&#160; But even if you use the BDC Identity setting an anonymous user will get an <em>Access denied by Business Data Connectivity <\/em>error like the one in the screenshot below.<\/p>\n<p> <a href=\"http:\/\/www.dontpapanic.com\/blog\/images\/EnablingAnonymousAccesstoaBCSExternalLis_85BB\/BCSAccessDenied.png\" target=\"_blank\"><img loading=\"lazy\" decoding=\"async\" style=\"border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px\" title=\"BCSAccessDenied\" border=\"0\" alt=\"BCSAccessDenied\" src=\"http:\/\/www.dontpapanic.com\/blog\/images\/EnablingAnonymousAccesstoaBCSExternalLis_85BB\/BCSAccessDenied_thumb.png\" width=\"244\" height=\"184\" \/><\/a>   <\/p>\n<p>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.&#160; 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.&#160; This is one of the most frequently overlooked steps when configuring an external content type using SharePoint Designer (SPD) 2010.&#160; After configuring an external content type in SPD you must set user permissions for the content type in Central administration.&#160; These permissions are displayed in SPD, but can\u2019t be set in SPD.<\/p>\n<p>But anonymous users by definition aren\u2019t logged in so how can we set permissions for them in central admin?&#160; There is a built-in group called <em>NT Authority\\anonymous Logon<\/em> 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.&#160; So how can we give anonymous users permission to access a BCS external content type?<\/p>\n<p><a href=\"http:\/\/www.dontpapanic.com\/blog\/images\/EnablingAnonymousAccesstoaBCSExternalLis_85BB\/bcs1a.png\" target=\"_blank\"><img loading=\"lazy\" decoding=\"async\" style=\"border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px\" title=\"bcs1a\" border=\"0\" alt=\"bcs1a\" src=\"http:\/\/www.dontpapanic.com\/blog\/images\/EnablingAnonymousAccesstoaBCSExternalLis_85BB\/bcs1a_thumb.png\" width=\"244\" height=\"184\" \/><\/a> <\/p>\n<p>The answer is that although you can\u2019t set these permissions in the user interface you can set them by editing the XML of the underlying BDC model directly.&#160; The XML of the BDC model for the external content type includes &lt;<font color=\"#804000\">AccessControlEntry<\/font>&gt; elements that specify what rights an individual user or group has to the BCS external content type.&#160; Adding users to the BCS permissions in the UI creates additional entries in the XML of the model.&#160; To give anonymous users access to the BCS model we need to add the following entry to several &lt;<font color=\"#804000\">AccessControlList<\/font>&gt; elements in the BDC model\u2019s XML.<\/p>\n<pre class=\"csharpcode\"><span class=\"kwrd\">&lt;<\/span><span class=\"html\">AccessControlEntry<\/span> <span class=\"attr\">Principal<\/span><span class=\"kwrd\">=&quot;NT Authority\\Anonymous Logon&quot;<\/span><span class=\"kwrd\">&gt;<\/span>\n  <span class=\"kwrd\">&lt;<\/span><span class=\"html\">Right<\/span> <span class=\"attr\">BdcRight<\/span><span class=\"kwrd\">=&quot;Execute&quot;<\/span> <span class=\"kwrd\">\/&gt;<\/span>\n<span class=\"kwrd\">&lt;\/<\/span><span class=\"html\">AccessControlEntry<\/span><span class=\"kwrd\">&gt;<\/span><\/pre>\n<style type=\"text\/css\">\n<p>.csharpcode, .csharpcode pre\n{\n\tfont-size: small;\n\tcolor: black;\n\tfont-family: consolas, \"Courier New\", courier, monospace;\n\tbackground-color: #ffffff;\n\t\/*white-space: pre;*\/\n}\n.csharpcode pre { margin: 0em; }\n.csharpcode .rem { color: #008000; }\n.csharpcode .kwrd { color: #0000ff; }\n.csharpcode .str { color: #006080; }\n.csharpcode .op { color: #0000c0; }\n.csharpcode .preproc { color: #cc6633; }\n.csharpcode .asp { background-color: #ffff00; }\n.csharpcode .html { color: #800000; }\n.csharpcode .attr { color: #ff0000; }\n.csharpcode .alt \n{\n\tbackground-color: #f4f4f4;\n\twidth: 100%;\n\tmargin: 0em;\n}\n.csharpcode .lnum { color: #606060; }<\/style>\n<p>&#160;<\/p>\n<h2>Here is the step by step procedure to add AccessControlEntries for anonymous users to the BDC model:<\/h2>\n<p><\/p>\n<ol type=\"1\">\n<li>In Central Admin Manage the BCS service application you created and add the Execute right for a specific user.&#160; This will give you an entry that you can do a search and replace on in the XML file later.\n<p><a href=\"http:\/\/www.dontpapanic.com\/blog\/images\/EnablingAnonymousAccesstoaBCSExternalLis_85BB\/ExecuteRight.png\" target=\"_blank\"><img loading=\"lazy\" decoding=\"async\" style=\"border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px\" title=\"ExecuteRight\" border=\"0\" alt=\"ExecuteRight\" src=\"http:\/\/www.dontpapanic.com\/blog\/images\/EnablingAnonymousAccesstoaBCSExternalLis_85BB\/ExecuteRight_thumb.png\" width=\"244\" height=\"184\" \/><\/a> <\/p>\n<p><\/li>\n<li>Go back to SharePoint Designer and export the default model for your external content type.&#160; Once you\u2019ve exported it you can rename it or delete it. (You need to do this or you won\u2019t be able to import your edited copy later)\n<p>&#160;<a href=\"http:\/\/www.dontpapanic.com\/blog\/images\/EnablingAnonymousAccesstoaBCSExternalLis_85BB\/spdexport.png\" target=\"_blank\"><img loading=\"lazy\" decoding=\"async\" style=\"border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px\" title=\"spdexport\" border=\"0\" alt=\"spdexport\" src=\"http:\/\/www.dontpapanic.com\/blog\/images\/EnablingAnonymousAccesstoaBCSExternalLis_85BB\/spdexport_thumb.png\" width=\"244\" height=\"184\" \/><\/a> <\/p>\n<p><\/li>\n<li>Now edit the BDC model XML file that you exported. Do a search and replace for the user you added and replace them with \u2018NT AUTHORITY\\ANONYMOUS LOGON\u2019 <\/li>\n<li>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.\n<p><a href=\"http:\/\/www.dontpapanic.com\/blog\/images\/EnablingAnonymousAccesstoaBCSExternalLis_85BB\/bcsImport.png\" target=\"_blank\"><img loading=\"lazy\" decoding=\"async\" style=\"border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px\" title=\"bcsImport\" border=\"0\" alt=\"bcsImport\" src=\"http:\/\/www.dontpapanic.com\/blog\/images\/EnablingAnonymousAccesstoaBCSExternalLis_85BB\/bcsImport_thumb.png\" width=\"244\" height=\"184\" \/><\/a> <\/p>\n<p><\/li>\n<li>Do an IISreset to make sure that you flush any BCS caching that is in place<br \/>\n    <\/li>\n<\/ol>\n<p>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.&#160; 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.<\/p>\n<p><a href=\"http:\/\/www.dontpapanic.com\/blog\/images\/EnablingAnonymousAccesstoaBCSExternalLis_85BB\/BCSAccessWorks.png\" target=\"_blank\"><img loading=\"lazy\" decoding=\"async\" style=\"border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px\" title=\"BCSAccessWorks\" border=\"0\" alt=\"BCSAccessWorks\" src=\"http:\/\/www.dontpapanic.com\/blog\/images\/EnablingAnonymousAccesstoaBCSExternalLis_85BB\/BCSAccessWorks_thumb.png\" width=\"244\" height=\"184\" \/><\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>I co-presented a webinar this week for ShareSquared on using the Business Connectivity Service (BCS) to integrate application data into SharePoint.&#160; A recording of the webinar is available here.&#160; One of the questions that came up in the Q&amp;A was from someone who was having a problem exposing a Business Connectivity Service (BCS) External List &hellip; <a href=\"https:\/\/www.dontpapanic.com\/blog\/?p=131\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">Enabling Anonymous Access to a BCS External List<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[44],"tags":[47,6,45],"class_list":["post-131","post","type-post","status-publish","format-standard","hentry","category-sharepoint-2010-designer","tag-bcs","tag-sharepoint_2010","tag-sharepoint_designer"],"_links":{"self":[{"href":"https:\/\/www.dontpapanic.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/131","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.dontpapanic.com\/blog\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.dontpapanic.com\/blog\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.dontpapanic.com\/blog\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.dontpapanic.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=131"}],"version-history":[{"count":2,"href":"https:\/\/www.dontpapanic.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/131\/revisions"}],"predecessor-version":[{"id":133,"href":"https:\/\/www.dontpapanic.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/131\/revisions\/133"}],"wp:attachment":[{"href":"https:\/\/www.dontpapanic.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=131"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.dontpapanic.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=131"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.dontpapanic.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=131"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}