Life, the universe and whatever

Something to say about most things

Archive for the tag “LinkedIn”

Search index configuration for FBA MOSS

I am working with a client on a public facing internet site that includes a public area for unauthenticated users and a ‘members’ area for which there is already a bespoke SQL database holding all members’ credentials (including clear text passwords!)  Given the tight timeframe and the amount of bespoke development required for other areas of the site I decided that it would be best to use the standard .NET Framework forms based authentication (FBA).  The site owners manually process new member applications and maintain the existing database so we will create an additional administration screen to maintain the FBA database via SharePoint.  The site owners would use Windows authentication (NTLM) via an ’authoring.companyname.co.uk’ URL and members will use FBA via an ’internal.companyname.co.uk’ URL.

The requirement

At least two document libraries will be included in the members area of the site but they will not be directly exposed to members.  Instead, each library will have a dedicated page on the site where members can browse through all the documents in the library or submit a basic search.  The documents will be displayed in a formatted table (grid) for both browsing and search results.

The solution

As the CSS formatting of the page was so bespoke I decided that my starting point would be a clone of a WCM page from elsewhere on the site to which I would add an ASP.NET GridView control.  When a user first visits the page it displays all the documents in the related document library by binding the grid (called searchResultsTable) to an SPDataSource object that has had the List property set to reference the document library.

bind to SPDataSource

figure 1 – binding to an SPDataSource

That was the easy part.  To perform the search I added a text box and an image button as per the following screen shot.

formatted results page

figure 2 – formatted results with paging

When the user submits a search the grid is bound to the results of an SPQuery that has been loaded into a DataTable.  The important thing to note here is that the AuthenticationType property of the SPQuery object must be correctly set depending on whether the user is NTLM or FBA authenticated as per the highlighted section in the code below.

SPQuery code

figure 3 – binding to an SPQuery filled DataTable

The problem

Before any of this will work the search indexer has to be configured to index the FBA version of the site.  The NTML site is automatically included in the default search content source (typically named ‘Local Office SharePoint Server sites’) and therefore any documents stored anywhere in the site are automatically indexed.  However, FBA authenticated users trying to search the site don’t see anything in that index as they are accessing the site through a separate URL.  I therefore added a search content source that I dedicated to indexing the site via the FBA URL.

FBA content source

figure 4 – adding a dedicated FBA search content source

As per the code in figure 3 the query passed into the SPQuery object via the QueryText property specifies the name of the search scope to be queried similar to this (where x, y, z are the fields to return and scope_name is the name of the search scope);

SELECT x, y, z FROM Scope() WHERE "scope"=’scope_name’

I therefore needed to set up a search scope for the document library but ensure it worked from both the NTLM and FBA sites.

NTLM & FBA search scope

figure 5 – document library search scope for NTLM & FBA

The final piece of the puzzle is ensuring that the search indexer has access to the FBA site.  As per the following screen shot, on a standard SharePoint Shared Service Provider the default content access account (used for indexing site content) is an NTLM account.

image

figure 6 – default content access account

Therefore the default content access account cannot create an index that FBA users can query.  I tried to add a crawl rule that would use a specific FBA account to crawl the FBA site.

add crawl rule 

figure 7 – add a crawl rule

The FBA site is currently using the default SharePoint FBA log in page which unauthenticated users are automatically redirected to when they first attempt to access an area of the site that requires authentication.  I entered the URL of the log in page (http://internal.companyname.co.uk/_layouts/login.aspx) in the Form URL field (under the Specify Authentication section) but when I clicked the Enter Credentials button I got a 403 error.

Enter Credentials 403 error

figure 8 – 403 error when entering FBA credentials

I noticed that every time a user is redirected to the log in page a ‘ReturnUrl’ query string is appended to the URL something like this:

http://internal.companyname.co.uk/_layouts/login.aspx?ReturnUrl=%2f_layouts%2fAuthenticate.aspx%3fSource%3d%252f&Source=%2f

When I used this extended URL on the Add Crawl Rule page and and clicked the Enter Credentials button the site log in page was correctly displayed.  I entered the credentials of the FBA search content access account and was redirected to the default FBA site page.  The following dialog popped up asking if the log in had succeeded.

image

figure 9 – successful log in with FBA credentials

After clicking OK I was returned to the Add Crawl Rule page and a message (highlighted below) indicated that the credentials had been accepted.

apparently correct

figure 10 – apparently correct FBA credentials

However, when I clicked OK I got an error telling me the credentials had either not been entered or had not been accepted?!

credentials not accepted!

figure 11 – credentials not accepted?!

 

This got very frustrating.  I couldn’t find anything useful in my excellent reference book Inside the Index and Search Engines: Microsoft Office SharePoint Server 2007 because it is nearly 2 years old and there have been some significant advances since then such as the infrastructure updates.  Just like my book, the most relevant information I got from searches was about using the addrule.exe command line tool which didn’t seem right for an installation up-to-date with service packs and hotfixes. 

The fix

One blog post I found explaining how to add a crawl rule caught my attention because of the log in page URL that was specified.  It was similar to the URL I had used but the ‘ReturnUrl’ query string parameter was notably shorter (just ‘%2f’) so I tried creating the crawl rule again using the shortened URL:

http://internal.companyname.co.uk/_layouts/login.aspx?ReturnUrl=%2f

This time everything worked and the crawl rule was successfully added!

crawl rule added

figure 12 – crawl rule added

With the crawl rule in place the indexer had FBA credentials and details of the log in page but the FBA account still needs to be given permission to read all the content in the FBA site.  This is accomplished in exactly the same way that the default access account is granted rights to browse an entire (NTLM) site, by means of a policy.  From the Application tab in Central Administration click on the Policy for Web application link.

image

figure 13 – Policy for Web application

On the Policy for Web application page click the Add Users button and ensure that the appropriate Web Application is selected.  Select the zone that the FBA site is running under then click the Next button.  Then enter the FBA user account and check the “Full Read – Has full read-only access” check box before clicking the Finish button.

And finally I could run a full crawl against the FBA site content source…

start a full crawl

figure 14 – start a full crawl of the FBA site

… and watch the index grow!

finally an FBA index!

figure 15 – finally the FBA site is indexed!

SharePoint Property Hash Tables

Today I read another great article by Andy Burns entitled Control the RSS Feed Settings on an SPList via the API.  What I love about Andy’s posts are the way he describes the problem first and then how he goes about tackling them, he’s obviously not just a SharePoint specialist but also clearly a true professional when it comes to software development.  If you haven’t read Andy’s blog before I seriously recommend subscribing and then making yourself a coffee and taking a good look through his back catalogue.

Andy used his experience and a nifty tool from Codeplex called SharePoint Manager to inspect the RootFolder Properties HashTable of the SPList object and sure enough he found the settings.  When you’ve come across this concept once or twice it becomes a logical place to look for properties and configuration settings and Andy’s post reminded me of a similar scenario I found myself in recently.  I have a client who are building a new intranet based on WSS 3.0 and Search Server 2008 Express and they want it branded the same as their new internet site.  I created two master pages and a site definition and I wanted to add a Search Center when a new Site Collection is provisioned from the site definition.  That part was straight forward;

SPWeb searchSite = rootWeb.Webs.Add("search", "Search Centre", string.Empty, rootWeb.Language, "SRCHCENTERLITE#0", false, false);

When Search Server is installed a file called webtempsrch.xml is added to the C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\TEMPLATE\1033\XML directory containing details of the template used to create the Search Center site, that is where the template name and ID are taken from to form the SPWebTemplate parameter “SRCHCENTERLITE#0”.

I then wanted to associate the search box found on most standard WSS 3.0 site pages (a.k.a. the small search box) with the Search Center results page rather than the standard /_layouts/OSSSearchResults.aspx page.  Through the user interface this is easily achieved by opening the Site Settings and selecting Search settings from the Site Collection Administration group.

image

On the Search Settings page simply select the first radio button to send searches to a Search Center and provide the relative URL.  However, I faced a similar problem to Andy and wanted to configure this programmatically when the site collection is provisioned.  A quick look at the SPWeb object model in the SDK didn’t reveal anything obvious and neither did searches on Bing and Google.  My next thought was the SPWeb Properties Hashtable so I took a look in there and found something that looked promising;

image

Using the AllProperties property of the SPWeb it is possible to set the value of the Search Center for the Site Collection as follows;

rootSite.AllProperties["SRCH_ENH_FTR_URL"] = "/search"; // Site Settings > (Site Collection Administration) Search Settings > Use custom scopes
rootSite.Update();

Social computing with SharePoint

I have a couple of clients at the moment who are very interested in exploring social computing trends and how they might apply within the organisation.  I have to admit I find it all very interesting if not a little overwhelming and being relatively new and such a fast evolving area it’s quite a challenge to get onboard.

I’m currently making hard work of reading the rather catchily entitled Social Computing with Microsoft SharePoint 2007: Implementing Applications for SharePoint to Enable Collaboration and Interaction in the Enterprise.  Hard work not because of the book, it’s content  or how it is written but simply because I just don’t make the time to read right now.  I do however make sure I keep on top of my RSS feed list and have just stumbled upon an interesting looking Microsoft blog: The Enterprise Social Computing Blog.  It looks to have been running since January 2009 but I’ve only just noticed it so I have some catching up to do but if the opening sentence of the first post is anything to go by then it will be the perfect place to get up to speed;

Welcome to the new Microsoft mini-site dedicated to enterprise social computing– what it is, what it can bring to your organization, and how the social power of Microsoft SharePoint and other Microsoft offerings can help you collaborate, communicate, and achieve your business goals more effectively than ever before.  If you are interested in enterprise social computing, SharePoint, or both, you’ve arrived at the official river of news and perspectives from Microsoft on this hot topic for enterprises.

So if you have an interest in social computing for the enterprise I suggest you get over there, check it out and look around the rest of the Microsoft Office Social Computing site which looks full of great content.

VSeWSS v1.3 and source control

I have recently looked into using the Visual Studio extensions for Windows SharePoint Services (VSeWSS) that are currently at release version 1.3.  I evaluated the initial releases a couple of years ago and was completely underwhelmed; it was very buggy, very restrictive and, as far as my clients were concerned, I had to recommend an alternative approach to structuring Visual Studio solutions for deploying SharePoint solutions.  A few months ago I was challenged on this point by another experienced SharePoint development consultant and after reviewing Kirk Evans’ series of articles and webcasts I downloaded the March 2009 CTP and set about recreating a few existing solutions using the extensions.  I am very impressed with how far the extensions have advanced since those early releases and they are now supported by the Feedback and Feature Requests forum on MSDN.

The extensions are obviously a work-in-progress but my concerns lay with the upgrade path to Visual Studio 2010 and the indicated/anticipated increase in the level of integration for SharePoint as a development platform.  However, I quickly discovered there is an issue with the extensions when it comes to source control because the feature.xml files are dynamically generated.  This is all well and good except that there is no chance that the standard, minimal settings generated will be sufficient for a production release; the project assembly name is used for the feature title (I think), there is no description, the version number is always 1.0.0.0, the list goes on.  Using the WSP View it is possible to open feature.xml files and make any necessary updates but the problem is the extensions store the physical files in a sub-directory of the project named pkg.  When another developer opens the project from source control the pkg sub folder is not included and it is therefore auto-generated when they first package or deploy the solution. 

Richard Slater is one of many people who have already raised the issue of source control for VSeWSS 1.3 solutions.  As per the MSDN article How to: Create an Automated Build and Deployment Solution with Team Foundation Server Team Build (taken from the SharePoint Guidance on Codeplex) the recommended approach is to add the pkg folder to source control;

To permit team development, you must add this folder to the source control repository. This makes any WSP structure customizations that one developer performs available to the other developers on the team.

The guidance also says;

…the Setup.bat file must be placed under source control so that a build process can use these files to generate a .wsp file and deploy it.

Whether I am automating the build process or not, when the .wsp file is the output to a client I also want this under source control.

Okay, so it seems that we have everything we need in source control for team development and although it doesn’t exactly feel quite right we can live with it because we know this is a work-in-progress and an interim solution before we can get our hands on Visual Studio 2010.  Is it robust enough?  I’m not 100% convinced but I’ve now committed some current projects to the setup so time will tell and if I find more issues then I will report them to the Feedback and Feature Requests forum and blog them here.

Update: I should also have mentioned that when version 1.3 of the extensions is installed a help file is deployed to “[drive_letter]:\Program Files\Microsoft SharePoint Developer Tools 9.0\VSeWSS13.CHM”.  The “Application Lifecycle Management with VSeWSS” chapter should be considered essential reading when using the extensions and there is a section entitled “Source Control using TFS” which details a good demonstration of adding the necessary files and folders to source control.

Technorati Tags: ,,
 

SharePoint as a development platform

Any developer who has interacted with SharePoint in any way, shape or form will surely have asked themselves the question, asked someone else the question or read or partook in at least one of the many debates that have raged over the years.  For me the question “is SharePoint a good development platform?” is pointlessly provocative so I would rather ask “can SharePoint be a good development platform?”.  Instead of giving my own answer to that question I will quote Kirk Evans reflecting on a 6 part series of articles and screen casts he authored entitled SharePoint for Developers:

This series has been building up to an application that provides the ability for an end user to pause a video (rendered through a Silverlight media player) and capture annotations about the video at a particular time segment.  You can imagine that, in a media company, there very well could be additional actions taken when someone creates an annotation such as automatically sending a formatted email to an advertiser (“The text formatting at time 00:00:28.4500000 does not comply with our standards for broadcast”).  This is the real power and benefit of leveraging SharePoint as an application platform: we can incrementally add value to our solution without requiring us to build that functionality into the service.  In a traditional ASP.NET application, you would likely add new functionality in a business logic layer, requiring a change in database storage, changes to the UI to display the new functionality, and changes to the service layer to expose the data to remote consumers.  With SharePoint, you could simply attach workflows to the content type, and any updates to the list via our web service will enjoy this new functionality without making any changes to the web service.  Or you might create a new content type and attach that to an existing list. 

This is a hugely powerful concept, and strongly demonstrates why you should consider using SharePoint as a development platform.  The separation of fields and content types and the ability to apply workflows to content types is huge.  This separation provides the framework for reusable components that can be easily assembled by end users through the web UI instead of requiring developers to code more functionality.  This lets you focus on creating the really cool building blocks and focusing on how to add value rather than writing monotonous forms code that performs CRUD operations against yet another custom database.  It provides a single, consistent platform that provides the web UI, services, and storage within a single platform.

The possibilities here are staggering, because it truly changes the way we think about building applications.

I certainly do not want to reignite any of those previous flame wars about SharePoint as a development platform, I simply saw Kirk’s excellent work which clearly articulates how the development story around SharePoint is continuing to gather pace, credibility and substance.

Please; anyone wishing to express their views on this subject (for or against), I am happy to moderate comments from the well reasoned voices of experience but I have no inclination to host yet another flame war on the subject.  I myself have struggled over the years with trying to build professional, robust systems on SharePoint but I would urge you to take the time to watch Kirk’s screen casts and read the wealth of information and resources he has taken considerable time to pull together.  Nobody can deny the additional overheads (time, experience, software, hardware) involved and it boils down to whether those overheads outweigh the benefits that Kirk succinctly sums up and that can only be done on a person-by-person, situation-by-situation basis.

SharePoint, Silverlight and WCF

These are interesting times in the SharePoint space, Microsoft SharePoint 2010 is on the horizon but as yet very few details have emerged.  As a freelance SharePoint developer and consultant I have for some time been carefully considering which “horses to back” in terms of the technologies to skill up on and introduce into my everyday work.  I believe that both Silverlight and Windows Communication Foundation (WCF) will play a significant and evolving role in the future of Microsoft Office and SharePoint so I have been tracking their evolution and have been slowly and selectively introducing them into my clients’ solutions.

Today I came across the article I have been waiting for: SharePoint 2007 with WCF and Silverlight.  For sometime I have been struggling to put all the pieces of the puzzle together in a deployable and supportable way and, even though this excellent article by Sahil Malik takes a bit of working through, I now have an end-to-end solution template for displaying rich UI with Silverlight interacting with the SharePoint object model through WCF services.  The benefits that make this worth while for me are;

  • a level of UI functionality, look and feel that users are coming to expect
  • the potential to develop far more efficient SharePoint pages that don’t round trip just to update a small area on a page (jQuery and AJAX are also very definitely on my radar)
  • free upgrades – Silverlight 3 is already in beta and promising even more new features, imagine the mouth watering possibilities of SharePoint with out-of-browser support!

Incidentally, I would strongly recommend that anyone interested in Silverlight for SharePoint should read Professional Microsoft SharePoint Development Using Microsoft Silverlight 2.

More clues on IR35

I read this really interesting article about IR35 on the Contractor UK site recently and it evoked more thought.  The article serves to enforce my belief that nobody is able to definitively judge an individual’s position in relation to IR35 when they operate in a freelance role out of a limited company as I wrote about in a previous post.  However, the article suggests to me that HMRC attempt to discern the general attitude of the freelancer through certain operational behaviours to assess their chance of a “successful investigation”.  The quote that says it all to me is;

A HMRC spokesman responded: “Any individual who provides his/her services through a service company to an end client potentially falls within IR35.”

Clearly the HMRC take exception to how individuals like myself position ourselves to pay tax.  I strongly believe the whole tax system needs to be strongly and vigorously policed however, it is clear to me that what is required here is clear and sensible legislation not a government department with a chip on it’s shoulder.  Then I read something like this about how Barclays are allegedly dodging £1bn every year and it’s difficult not to get angry.

Technorati Tags: ,,

SPDisposeCheck and Visual Studio

If you haven’t heard the SharePoint Pod Show yet then I highly recommend you try it out.  One of the hosts, Nick Swan is a good friend and occasional golf buddy and I’ve also had the pleasure of meeting co-host Brett Lonsdale a few times.  Together with US based Rob Foster they are doing a great job of bringing SharePoint current affairs to us by interviewing a wide range of really interesting people in the field.

In episode 16 Brett interviewed the amazing Todd Bleeker and believe me, I use the word amazing quite advisedly. A couple of years back I was fortunate enough to attend a Combined Knowledge 5 day WSS 3.0 Developer course delivered by Todd and not only does he have a rack of Quad core, HP Proliant blades running 128Gb RAM for a brain but he is also a genuinely nice and really interesting guy with an obvious passion for SharePoint and development (listen to the interview and you will know exactly what I mean).

In the interview Todd talks about the SPDisposeCheck tool, where it’s at, what’s missing and how to use it.  I was especially interested by what he had to say on integration with Visual Studio and I noticed that Eli Van Eenwyk blogged a post on the subject here.

I often read people gushing about the SharePoint community for just this sort of thing; people like the SharePoint Pod Show guys, Todd, Eli and an absolute host of others continually give up their own time for nothing more than the buzz of helping others (special mention to guys like Andrew Woodward, Andrew Connell, Chris O’Brien, Joel Oleson and Scott Guthrie to name but a few who have been of particular help to me over the years).  However, I have noticed an overall increase in community activity throughout the areas I am interested such as Silverlight and SQL Server too and this is further evidenced in the UK through events like DeveloperDeveloperDeveloper! Day and the Next Generation User Group meetings.

UK contracting and the ever mobile IR35 goalposts

Since going out on my own as an independent in the UK, the single biggest concern has always been the IR35 law.  This is our government’s attempt to make people like myself pay tax on our income in exactly the same way as a permanent employee would.  I’m not going to stand on my soapbox (well maybe just a little) and I don’t have the inclination to debate the moral or legal arguments around IR35.  It is clear that nobody, legally trained or otherwise, is able to definitively determine when an independent is (or is not) operating outside of IR35.  However, I noticed this article recently published on the Contractor UK website that certainly helped to reassure me.

Personally, I have never been interested in the ‘security’ of a longer term contract as one of the many reasons I left permanent employment was to get away from the monotony of spending Monday to Friday, 9 to 5  doing the same work with the same people staring at the same 4 walls.  I have therefore tended to gravitate to work and contracts that are project based but, especially when applying for work through agencies, it is not until you are actually doing the work that you get the full picture of what is required of you.

*** What follows is pure opinion and a self gratifying rant ***

The bottom line for me is that I am more than happy to contribute a fair rate of tax and pay my way, even though the UK government seems preoccupied with using it to drop bombs and bail out greedy bankers.  Tony Blair, Gordon Brown and Alistair Darling have proven to be three of the most ineffective individuals this country could have had guiding it into and through a global recession and have left us far worse off than we need to have been.  That just irritates me all the more when I work in excess of 5 days a week and feel like I’m seen as a wanton tax dodger.

Technorati Tags: ,,

Excellent demonstration of the power in the SharePoint platform

As a SharePoint developer and consultant, when I am asked if something can be done with SharePoint or how to solve a business problem my thoughts often start with (or quickly arrive at) SharePoint Features created in Visual Studio projects and deployed as SharePoint Solutions.  In truth I shouldn’t need reminding, I see evidence all the time that there are often very simple solutions to solve business requirements and the use of Visual Studio can often be seen as a sledgehammer to crack a nut.

Case in point, UK based SharePoint MVP Alex Pearce has posted a really nice little tutorial; Add a Banner to your SharePoint Site.  It’s a perfect example of the power in the WSS/MOSS platform; a solution that can be quickly and easily created and up and running on a pilot site but has the potential to be deployed as a SharePoint Feature, and therefore a Solution, if so required.

Technorati Tags: ,,

Post Navigation

Follow

Get every new post delivered to your Inbox.