Nov 30, 2009

How to use SPSWC controls in Sharepoint DataFormWebpart

If you try to add a control such as to a Sharepoint Data View Webpart inside the XSLT, Sharepoint Designer will crash and your page won't render correctly.

You need to add two things to fully register the SPSWC namespace for use in XSLT.

1. Add at the top of your page:

<%@ Register Tagprefix="SPSWC" Namespace="Microsoft.SharePoint.Portal.WebControls" Assembly="Microsoft.SharePoint.Portal, Version=, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>

2. In the <xsl:stylesheet> tag at the beginning of your Data View Webpart, add an entry for:

That should do it.

Nov 20, 2009

Sharepoint and Reporting Services: User cannot be found

As you can deduce from the error, the problem is that the author of a Sharepoint web site cannot be found.

When Reporting Services tries to render a page, it seems to read the Author field of every web site of all site collections in all web applications. If the author cannot be resolved in just one web site(the user had been deleted), this fails.

You can see the same error with Sharepoint Manager 2007 tool ( by browsing to a web site and viewing the Author field.

I copied code from this blog post ( to reset the Author field for sites that have this error in a site collection.

Here's the modified code:

// BEGIN SPResetAuthor

using System;
using System.Text;
using Microsoft.SharePoint;
using Microsoft.SharePoint.Administration;

namespace SPResetAuthor
class Program
static void Main(string[] args)
if (args.Length < 2)
string sFormat = "{0,5}{1,-20}{2}\n";
StringBuilder sb = new StringBuilder();
sb.Append("\nSYNTAX: SPResetAuthor.exe webURL DOMAIN\\USER \r\n");
sb.AppendFormat(sFormat, " ", "", "The Web URL where"
+ " the author needs to be reset");
sb.AppendFormat(sFormat, " ", "", "The Login Account"
+ " for the new author, i.e. DOMAIN\\USER");

// Open the site collection
Console.WriteLine("Opening site collection for: {0}",args[0]);
SPSite site = new SPSite(args[0]);
String userName = args[1];

fixEmptyAuthors(site.AllWebs, userName);


private static void fixEmptyAuthors(SPWebCollection webs,String userName) {
foreach (SPWeb web in webs)
bool authorEmpty = true;

authorEmpty = false;
catch (Exception e)
authorEmpty = true;

Console.WriteLine("Site (web) title: " + web.Title);

if (authorEmpty)
Console.WriteLine("Resetting Author to: {0}", userName);
SPUser user = web.EnsureUser(userName);
web.Author = user;



// END SPResetAuthor

Create a Console application with this code (don't forget the reference to Microsoft.Sharepoint.dll) and run the app with: spresetauthor.exe http://server:port domain\user

You'll need to run the application for all site collections you have (My Sites, SSP, etc) and I recommend the "sharepoint\system" as the new author.

Good luck!