Navigation

Wednesday 31 August 2011

Slides from SUGUK London, Configuring Kerberos for SharePoint 2010

Just a quick note to publish the slides for my SUGUK London session on Configuring Kerberos for SharePoint 2010.

It was a great session hosted by LBi and many thanks to @TheRealRiaz for hosting and Matt Taylor (SUGUK) for organising.

The session went really well (my VMs were a little slow to warm up) but thankfully the demo gods smiled on my and my demos actually worked! (huzzah!)

We managed to go from a full NTLM SharePoint 2010 farm to configuring Excel Services to use Kerberos Constrained Delegation to SQL Analysis Services, and configuring the Web Applications to delegate to each other (to sort out that pesky RSS Viewer Web Part) and all in about 45 minutes!

For those who missed it, or wanted some notes from the session, you can access all of my slides below:
(PS - The PowerPoint Web App is powered by Office 365 and this is my first time trying to use it publicly, so hope it works well for you. Feedback welcome!)


Thursday 18 August 2011

I'm speaking at SUGUK London

Well I am very pleased to announce that I will be speaking at the SharePoint User Group UK (London) on Thursday 25th August.

I am basically doing a "practice run" of my Configuring Kerberos in a SharePoint 2010 Farm which I am doing at SharePoint Saturday UK later this year.

This will involve;
  • Configuring Kerberos Live on a SharePoint 2010 farm, taking it from NTLM to Kerberos/Negotiate authentication
  • Configuring SQL and Analysis Services to use Constrained Delegation
  • Configuring SP2010 Excel Services to pass through the authentication credentials using the Claims to Windows Token Services
  • How to prove it is all working using "out of the box" tools
  • A few other resources, caveats and tricks
This is a FREE event at LBi offices in central London, full details, signup and map details can be found on the SUGUK forum: http://suguk.org/forums/thread/27083.aspx

Should be a great event, hope to see you there and have a SharePint afterwards.

Tuesday 16 August 2011

I'm speaking at SharePoint Saturday UK (SPSUK)

I am proud to announce that I have been selected as one of the speakers at the SPSUK event this year in Nottingham on 12th November. The full session list can be found on their website and includes loads of great sessions throughout the day!

My session is going to be about configuring Kerberos in a SharePoint 2010 Farm and will include a live walkthrough of setting up Kerberos from scratch for a SharePoint 2010 environment, and how to use standard "out of the box" tools to prove that it is working.

This will include Excel Services and Analysis Services, constrained delegation and configuring the Claims to Windows Token Service.

This is the first IT Pro Session (9:15am) so hope you get there early! :)

For those of you who don't know about this fantastic event it is FREE to attend and consists of a whole day of SharePoint goodness. Here is a short quote from their website:
SharePoint Saturday UK 2010 was a great success with around 200 attendees!!
Brett Lonsdale (Lightning Tools), Mark Macrae (ID Live), and Tony Pounder (ID Live) are repeating last years efforts to bring you SharePoint Saturday UK 2011.
This year the event will be held in Nottingham at the East Midlands Conference Centre. The EMCC is close to East Midlands airport, Nottingham train station, and the M1 motorway with easy links to the M6 motorway.
If SharePoint Saturday is new to you, expect a day of great international speakers including Microsoft employees, SharePoint MVPs and SharePoint community experts, great content, and of course SharePint!
Hope to see you there! If you haven't already then sign up now!

Thursday 11 August 2011

How to enable Anonymous Access to a blog site on your Office 365 public website

This has been plaguing the forums for weeks now .. if I had a pound for everytime I've seen someone complaining about blogs on Office 365 .. I'd have .. erm .. about £15 ..

But seriously, this is something that a lot of folks have been complaining about .. but no more! :)

One thing that definately surprised me is that you can set anonymous permissions through Sandbox Solutions! This means that we can write our own custom code to enable full anonymous access for comments, categories and posts :) So I've done just that.

A link to download a Sandbox Solution can be found below. Just upload the WSP to your public website site collection, activate it, and drop the new "Hatch Solutions" web part onto the home page of your blog :)
NOTE: For those who aren't interested in how this works, and just want the web part, you can grab the WSP package here.
This installs a Web Part. Place this webpart on the home page of your Blog site, and hit the big button... it should do all of the work for you.

Important: You don't need to keep the webpart on there. Once you've checked it is working you can remove the webpart and remove the WSP from your Solution Gallery!
Regional Settings -  There have been numerous reported issues regarding regional settings (as the code looks for lists called "Posts" and "Comments"). Currently this WSP only works when your SharePoint Site regional settings are set to English.
So what are we doing?
This is really quite simple. The SharePoint API exposes the list permissions for anonymous users through an SPList property called AnonymousPermMask64. This is an enumeration of SPBasePermissions values which effectively describe what access anonymous users have.

The reason this doesn't work by default for anonymous users is because the "ViewFormPages" permissions is not included by default!

So our code is quite simple:

// get the "Comments" list
SPList list = SPContext.Current.Web.Lists["Comments"];

// check if it has unique permissions
if(!list.HasUniqueRoleAssignments)
{
 list.BreakRoleInheritance(true);
}

// make sure people can edit their own items
list.WriteSecurity = 2;

// grant permissions to anonymous users
list.AnonymousPermMask64 =
  (SPBasePermissions.Open |
   SPBasePermissions.OpenItems |
   SPBasePermissions.ViewFormPages |
   SPBasePermissions.ViewListItems |
   SPBasePermissions.AddListItems);

list.Update();


So all we are doing there is granting some additional permissions (ViewFormPages, ViewListItems and AddListItems) for anonymous users. Then we just rinse-and-repeat for Posts and Categories (but remember to remove the "AddListItems" bit!! otherwise anonymous users would be able to create new blog posts!).

That's it! I have a (short-lived) demo running on my current Office 365 site: www.hatchsolutions.co.uk/Blog/

Note - depending on how much spam and rubbish ends up on there, I will probably delete it sooner rather than later. I'll try and remember to update this post after I have.
To make this easy for you I have built a Web Part which you can download and install (link at the top of this post) which does all of the work for you.

So that is all you should need .. happy blogging folks!! (all we need now is a decent blog template with things like CAPTCHA.. )

Tuesday 9 August 2011

How to programmatically add the Related List Webpart to a list form

This is one thing that I have used a few times through the browser and always thought it was a feature missing from WSS 3.0 / MOSS 2007. But it was only when I tried to do this (relatively simple) thing as part of a list definition that I realised how oblique it was, and how little information there seems to be explaining how to do it... This blog post will try to address some of that.



So first off .. what is a Related List Webpart? This wasn't really a surprise but if you look under the hood you will notice that when you use the "Related List" ribbon button then it actually does 2 things:
  • Adds a new List View Webpart (in this case an XsltListViewWebPart) which is bound to the related list
  • Creates a web part connection from the (already present) ListFormWebPart which provides the ID which the related list will filter on.
In order to set this up programmatically we basically have to replicate this. In my example I am running this from a Feature Receiver which will setup the web parts. I have 2 lists which I will be referring to:
  • Main List (the main list which I will be modifying)
  • Related List (a list which contains a lookup field containing values from List A)
STEP 1 - Add a new List View Web Part to the List Form

In this step we will be modifying the DISPLAY form (DispForm.aspx). This is probably the most common approach although you can follow very similar steps for the Edit Form if you so wish)

// these are the 2 lists we will work with
SPList mainList = web.Lists["Main List"];
SPList relatedList = web.Lists["Related List"];

// this is the Display Form web part page
SPFile dispForm = web.GetFile(mainList.DefaultDisplayFormUrl);

// get the web part manage which we will use to interact
SPLimitedWebPartManager wpm =
dispForm.GetLimitedWebPartManager System.Web.UI.WebControls.WebParts.PersonalizationScope.Shared);

// only execute this code if there is a single web part (the default for this list)
// we don't want to add the web parts over and over again ..
if (wpm.WebParts.Count == 1)
{
   // create our List View web part
   XsltListViewWebPart wp = new XsltListViewWebPart();

   // Hook up the list and the view
   wp.ListId = relatedList.ID;
   wp.ListName = relatedList.ID.ToString();
   wp.ViewGuid = relatedList.DefaultView.ID.ToString();
   wp.XmlDefinition = relatedList.DefaultView.GetViewXml();

   // set basic properties along with the title
   wp.AllowConnect = true;
   wp.Title = "Related items from " + relatedList.Title;
   wp.ChromeType = PartChromeType.TitleAndBorder;

   // add the web part to the Main zone in position 2
   wpm.AddWebPart(wp, "Main", 2);

   // save the page
   webPartPage.Update();
}

So you can see from the example code above we are adding a simple List View webpart for our related list items. We are binding it to the "Related List" using the ID, and also choosing the View we want to display (here we have just used the Default View for simplicity).

We need to make sure we set "AllowConnect" (as we will need to use Connections in Step 2) and also set the ChromeType to "Title and Border" (as the default for Web Parts in List Forms is "None").

Finally we add the web part and save the changes to the Web Part Page ...

now for the slightly less well documented bit ..

STEP 2  - Create Web Part Connections between ListForm and ListView webparts
In this step we are going to take the Web Part which we added in STEP 1 and use standard Web Part Connections to bind them together ... don't be scared, it isn't as hard as yoy might think :)

We are going to be doing several things here:
  1. We will get instances of both web parts which need to be connected
  2. We will create "Connection Point" objects for each web part
  3. Specify which fields we want to filter on
  4. We will create a "Transformer" object which is able to pass values between each web part
  5. We will use the Web Part Manager to create the connection, using all of that information above.
// get instances of our two web parts
System.Web.UI.WebControls.WebParts.WebPart consumer = wpm.WebParts[1];
System.Web.UI.WebControls.WebParts.
WebPart provider = wpm.WebParts[0];

// Create our two Connection Point objects
// These are specific to our two types of Web Part

ProviderConnectionPoint providerPoint = wpm.GetProviderConnectionPoints(provider)["ListFormRowProvider_WPQ_"];


ConsumerConnectionPoint consumerPoint = wpm.GetConsumerConnectionPoints(consumer)["DFWP Filter Consumer ID"];

// create our "Transformer"
// we also specify which Field names we want to "connect" together
// here I am connecting my Related List's "MyLookupField" and filtering it
// using the "ID" of my List Form's item.

SPRowToParametersTransformer optimus = new SPRowToParametersTransformer();
optimus.ProviderFieldNames = new string[] { "ID" };
optimus.ConsumerFieldNames = new string[] { "MyLookupField" };

// Connect the two web parts together, using our Connection Point objects
// along with our Transformer

wpm.SPConnectWebParts(provider, providerPoint, consumer, consumerPoint, optimus);

And that is it! You don't need to do any more "Update" or "Save" methods .. your Related List web part should now be finished :)

So just to be clear, we are using the standard SPLimitedWebPartManager object and calling the SPConnectWebParts method. The only slightly odd call is the reference to the "SPRowToParametersTransformer" which is specific to the type of Connection we are making (the List Form representing a "Row").

Where did this information come from?
This is the easy bit :) I added a Related Lists Webpart using the browser, then opened up DispForm.aspx using SharePoint Designer .. and found this: 

<WebPartPages:SPWebPartConnection ConsumerConnectionPointID="DFWP Filter Consumer ID" ConsumerID="g_dc64a1e0_c2f4_4302_86df_e4d184203bbd" ID="c225174896" ProviderConnectionPointID="ListFormRowProvider_WPQ_" ProviderID="g_ffb9e36b_bc6d_489e_b7fc_e93048c32f5c"><WebPartPages:SPRowToParametersTransformer ConsumerFieldNames="IMSDataSource" ProviderFieldNames="ID"></WebPartPages:SPRowToParametersTransformer>
I have highlighted the references to the 3 things which made all of the dots join up for me: )
so if you are ever stuck, make sure you look in SharePoint Designer for :

  • Consumer Connection Point ID ("DFWP Filter Consumer ID")
  • Provider Connection Point ID ("ListFormRowProvider_WPQ_")
  • Transformer Type (SPRowToParametersTransformer)
So thats it :) Hope this was useful, comments always welcome