[SP201x] Implementing Kerberos delegation in SharePoint

Kerberos is often perceived as painful to setup and hard to debug. And to be honest: in my opinion it’s not one of the most user friendly techniques out there. But once you get the hang of it, the bigger picture start becoming clear and things get easier. In this article I will explain how to use Kerberos in combination with Business Connectivity Services (BCS) to delegate a users’ credentials to SQL Server. So let’s get to it! (more…)

SP2010: Problems with filtering and grouping for external data / BCS fields

Having one of the following two problems?

1) Grouped views not working properly when you’ve selected a BCS / External data field as the group field
2) Column filtering not working properly for BCS / external data fields

But these problems seem to be inconsistent, some records work and others don’t? Chances might be that you’ve selected a field for which the values contain newline characters. This consistenly brings problems with grouping and filtering. The best option you’ve got is just to eliminate newlines in your datasource. Using SQL? Then this will do: REPLACE([column], CHAR(10), ‘ ‘).

SP2010: Deleting old BDC invalid BDC column from list

One of our environments is one that was upgraded from MOSS 2007. In that transition, BDC changed to BCS and we didn’t really take care of that because we weren’t using BDC that much. One of the lists got migrated and stopped working, but because it was in a dark alley on our SharePoint site, no one really noticed. Untill last week, when one of our users tried to use it to discover all he was getting was errors. Hmmmm.

SP2010: BCS issue; CalculatePermissionsForCurrentThread

This probably is the last post in my latest BCS series for now, since our project is almost finished 🙂 One of the last hurdles I had to take was an error which only occured in our production environment for some reason (I guess production and test still aren’t similar enough). It occurred when trying to get a single BCS entity in code and had something to do with the permissions not being valid. (more…)

SP2010: Assembly was requested for LobSystem with Name, but this assembly was not returned

Working my way through BCS, I encountered another error which seems to be pretty undocumented. It’s as follows:

Error while executing web part: System.InvalidOperationException: Unable to open the specified list item. ---> Microsoft.BusinessData.Infrastructure.BdcException: The shim execution failed unexpectedly - Assembly was requested for LobSystem with Name 'Company.Projects.Contoso.BCSLobSystem', but this assembly was not returned. SystemUtility of Type 'Microsoft.SharePoint.BusinessData.SystemSpecific.DotNetAssembly.DotNetAssemblySystemUtility' requires the assembly to be uploaded.. ---> System.InvalidOperationException: Assembly was requested for LobSystem with Name 'Company.Projects.Contoso.BCSLobSystem', but this assembly was not returned. SystemUtility of Type 'Microsoft.SharePoint.BusinessData.SystemSpecific.DotNetAssembly.DotNetAssemblySystemUtility' requires the assembly to be uploaded.

When you read my previous blog posts, you know I’m working in a multi tenant environment, which is linked to a non-partitioned BCS service application. I don’t know for sure if that has something to do with this, but I’m guessing it does.

I also wished I could explain to you what’s going wrong here, but truthfully I really can’t. What I can do though, is provide you with the solution I found after some struggling with BCS and Powershell. Because the error stated the assembly needs to be uploaded, I came accross the Import-SPBusinessDataCatalogDotNetAssembly function. That proved to be the solution to my problem. Use it like this:

$url = "http://www.contoso.com"
$assemblyPath = "C:\lobsystem.dll"
$lobSystem = "Company.Projects.Contoso.BCSLobSystem"

Write-Host "Adding assembly to LOBSystem"
$serviceContext = Get-SPServiceContext $url
$lobSystem = Get-SPBusinessDataCatalogMetadataObject -ServiceContext $serviceContext -BdcObjectType lobsystem -Name $lobSystem
Import-SPBusinessDataCatalogDotNetAssembly -LobSystem $lobSystem -Path $assemblyPath

After executing this, everything started working!

SP2010: A multi tenant BCS scenario

I’ve done some posts about multi-tenancy and BCS lately, but haven’t combined the two. So todays topic (and no, it’s not a joke…) will be BCS in a multi tenant environment. Mainly because you have some choices to make and I want to provide you with some input on which you might be able to make the right one 🙂 (more…)

SP2010: Setting BCS column and related fields

I’ve been struggling for a while to programmatically set BCS columns. Setting the column itself isn’t that hard, but it’s getting all the related fields to show data too that’s a challenge. There seems to be no out of the box method to do this, so I’ve created one myself. Without further ado, let’s get to the code!

[sourcecode language=”csharp”]
/// <summary>
/// Set all secondary BCS fields for a given entity
/// </summary>
/// <param name=”listItem”>The item to set the fields for</param>
/// <param name=”dataField”>The BCS field itself</param>
/// <param name=”entityInstance”>The entity to get the values from</param>
private static void SetSecondaryFields(SPListItem listItem, SPBusinessDataField dataField, IEntityInstance entityInstance)
// Convert the entity to a formatted datatable
DataTable dtBDCData = entityInstance.EntityAsFormattedDataTable;

// Set the BCS field itself (Display Value)
listItem[dataField.Id] = dtBDCData.Rows[0][dataField.BdcFieldName].ToString();

// Get the specific finder method to get the columns that returns
IMethodInstance method = entityInstance.Entity.GetMethodInstances(MethodInstanceType.SpecificFinder)[0].Value;
ITypeDescriptorCollection oDescriptors = method.GetReturnTypeDescriptor().GetChildTypeDescriptors()[0].GetChildTypeDescriptors();

// Set the column names to the correct values
foreach (ITypeDescriptor oType in oDescriptors)
if (oType.ContainsLocalizedDisplayName())
if (dtBDCData.Columns.Contains(oType.Name))
dtBDCData.Columns[oType.Name].ColumnName = oType.GetLocalizedDisplayName();

// get the secondary field display names; these should be set
string[] sSecondaryFieldsDisplayNames = dataField.GetSecondaryFieldsNames();

// loop through the fields and set each column to its value
foreach (string columnNameint in sSecondaryFieldsDisplayNames)
Guid gFieldID = listItem.Fields[String.Format(“{0}: {1}”, dataField.Title, columnNameint)].Id;
listItem[gFieldID] = dtBDCData.Rows[0][columnNameint].ToString();

To use this to update a list item, call it like this:

[sourcecode language=”csharp”]
SPBusinessDataField dataField = listItem.Fields[“BCSField”] as SPBusinessDataField;
listItem[dataField.RelatedField] = customerId;
SetSecondaryFields(listItem, dataField, entityinst);

Special thanks to Wade A Hunter for providing the guidelines on how to do this in 2007, this code is based on that. See: http://wadehuntersblog.blogspot.com/2010/10/working-with-sharepoint-2007-business.html

Creating secured BCS objects with BCS Meta Man

We started using BCS in SP2010 to create External Content Types. This is really a powerfull system, and a huge improvement on the ‘old’ BDC approach.

For a project, I needed something more then just a BCS layer to get all the data. Data is being fetched from a 3rd party backend system in which customer data is stored. That data (customers, contacts, addresses, stuff like that) had to be available in SharePoint for reporting purposes. The entire site was accessible for Active Directory users, but also (and there lies the challenge) for external users. Those external users are all linked to a certain customer, but we definitely don’t want to give them access to the entire customer database!


SP2010: BDC Metadata Store is Currently Unavailable

I was really impressed by the new BCS stuff which I saw @ SPC2010. Offcourse, after installing the beta on my laptop, I wanted to test it out myself. So I downloaded SharePoint designer (which is pretty damn nice compared to the old one), connected to my newly created SharePoint site and clicked “External Content Types”.

Unexpectedly, this didn’t result in a fancy BCS screen, but gave me an error: “BDC Metadata Store is Currently Unavailable”. After some research, I found the following post on MSDN: http://social.technet.microsoft.com/Forums/en-US/sharepoint2010customization/thread/c9deb39e-d3c3-4102-a777-24a6dfed1701/?prof=required. The first fixes in there didn’t do the trick for me though. We tried analysing the results with Fiddler and found out that authorization was probabaly the cause of it, since the webservice requests were denied and followed by 302 redirects to the logon page of SharePoint.

I had my site setup with claims based authentication. I created a new site based on classic mode authentication and voila: it started working! It seems there’s a bug in SPD related to claims based sites, it also seems that this bug is already fixed in later releases, as posted by TAP members in the above forum post. So if all is well: this won’t be a problem any more in the RTM versions.