Adding BDC Columns to a Sharepoint List

I am trying to add BDC columns to a sharepoint list programatically.

In fact the application that I am working on has 140 lists each potentially with a different set of BDC extension columns.

This is of course impossible – at least no-one is saying how to do so on the blogs.

You cannot use the simple field constructor as business data is not in the enumeration.

The trick is to extract the XmlSchema from the field and remove the offending gumph (that is the specific guids – which I now think may be the cause of my problems).

There are two methods that I have found useful:

SPField.AddFieldAsXml is the key method on the list to allow the xml to be added.

You need to tell the client which bdc provider to use:

SqlSessionProvider.Instance().SetSharedResourceProviderToUse(“myssp_id”)

This almost works (the fields are added, you get a cryptic error about looking in the logs yet the bdc column does not work).

I suspect that the guids that I removed are the problem.

Normally I only post working examples – this is not one of them.

Kerberos

Kerberos is a security protocol that has been implemented in windows.

It is something that you need to get to work if you ever have a windows process that wants to perform an action on a users behalf under that users identity.  It is a bit of a pig to configure.  The only clue that you get is that the remote service is accessed using the Unknown User

Here is an article on enabling Kerberos.

Here is a Microsoft article on troubleshooting Kerberos under IIS.

Here is an article on the BDC and authentication.  The BDC is the expensive version of Sharepoint’s datasource abstraction layer (i.e. it can read from a system that supports .net 2 ado.net drivers or has a web service interface).

Classic Microsoft Documentation

This is a very typical piece of microsoft documentation.

It contains the call interface, and a trivial example, yet has left the end user to identify the useful information that should be documented.  It appears that most of the MSDN api documentation has been autogenerated from the code.  Which is completely useless when the names give no clue.

I have been looking at using the WF rules engine outside of the WF framework.  This should be easy to do, yet the documentation sucks.  You end up having to hunt around various blogs &c.

Loading data into a Sharepoint page from a webpart file

/*

using System;

using System.Xml;

using Microsoft.SharePoint;

using Microsoft.SharePoint.WebPartPages;

*/

 

            try

            {

 

                using (SPSite site = new SPSite(“http://mysite:123456/“))

                {

                    using (SPWeb web = site.OpenWeb(“MySubWeb”))

                    {

                        SPFile targetPage = web.GetFile(“default.aspx”);

 

                        SPLimitedWebPartManager webpartManager = targetPage.GetLimitedWebPartManager(

                            System.Web.UI.WebControls.WebParts.PersonalizationScope.Shared);

 

                        string errMsg;

 

                        // This is the file that can be exported from the webpart

                        XmlTextReader reader = new XmlTextReader(“summary.webpart”);

                        System.Web.UI.WebControls.WebParts.WebPart webPart = webpartManager.ImportWebPart(reader, out errMsg);

 

                        webpartManager.AddWebPart(webPart, “TopWebPartZone”, 1);

                        targetPage.Update();

 

                    }

                }

 

            }

            catch (Exception ex)

            {

                Console.WriteLine(ex);

            }