Building public-facing websites using SharePoint 2007: search functionality

This is a third post of the blog post series on building public-facing websites using SharePoint 2007. The first part was dedicated to the planning building public-facing websites using SharePoint 2007. The second part was dedicated to custom branding and development in SharePoint.

Plan SharePoint search: performance and sizing

Here is an excellent post on planning performance and sizing for SharePoint search:

Customize search box

To customize search box in SharePoint:

  • Search for PlaceHolderSearchArea in the code
  • Change Visible property of PlaceHolderSearchArea section to False: visible="false"
  • Add Search Box web part
  • To hide search scope drop down, add <DropDownModeEx xmlns="urn:schemas-microsoft-com:SearchBoxEx">HideScopeDD</DropDownModeEx> tag to the Search Box web part section of the code. More options for Search Scope Drop Down can be found at
  • To hide Advanced Search option, add <Property Name="ShowAdvancedSearch">false</Property> tag to the Search Box web part section of the code
  • To change images for search buttons, modify GoImageUrl, GoImageUrlRTL, GoImageActiveUrl, GoImageActiveUrlRTL tags
  • There are a lot more things you can customize in the Search Box, just read through the tags within PlaceHolderSearchArea section

There is also another way to customize search box by modifying SearchArea.xml under C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\TEMPLATE\FEATURES\OSearchEnhancedFeature. This is a much less elegant way, but it works.

Clean up your SharePoint search results.

To remove noisy search results that users do not want and/or do not have permissions to see:

  • Open your Shared Services Provider
  • Click on Search Settings >> Crawl Rules
  • Add crawl rules to exclude the following paths:
    • *://*webfldr.aspx*
    • *://*my-sub.aspx*
    • *://*mod-view.aspx*
    • *://*allitems.aspx*
    • *://*all forms.aspx*
    • *://*/lists/*
    • *://*DispForm.aspx*

Permissions issues with search

I have already blogged about some permissions issues with SharePoint search and anonymous users. Basically it has to do with the page layout inheriting certain classes that are not accessible to the anonymous users, but you can read the rest in my previous blog post:

Block search engines from crawling non-public parts of the website

Activate ViewFormsPagesLockDown feature. This is a MOSS-only feature that disallows anonymous access to pages in the _layouts directory that inherit from LayoutsPageBase and disallows anonymous access any of the form or view pages (DispForm.aspx, AllItems.aspx). Otherwise, search engines will be able to view/crawl the parts of SharePoint you don't want them to see.

Best bets/Keyword feature

Use best bets feature in SharePoint search. Even though the interface is a bit awkward, I find this feature quite useful. Here are the instructions on how to manage best bets/keywords:

Performance optimization

Here are the best practices for search in SharePoint:

The next topic of this blog post series will be dedicated to implementing or preserving SEO practices in SharePoint…

Related resources:

A tiny bug in Service Pack 2 of MOSS 2007 and WSS 3.0

A tiny bug in Service Pack 2 of MOSS 2007 and WSS 3.0 has been discovered recently. Installing SP2 changes a product expiration date and sets your SharePoint install to 180-day trial. This expiration date bug should not affect the normal function of SharePoint, at least until the expiration date passes. After 180-day trial expires, customer's data, configuration or application code will still not be affected, but will render SharePoint inaccessible for end-users.

Microsoft promised a hotfix for this bug within the next 48 hours or so (KB971620). Meanwhile, you can easily fix this problem by re-entering your license key:

  • Open SharePoint Central Administration
  • Go to Operations
  • Under Upgrade and Migration section, click on Convert license type
  • Type in your license key and hit Enter
  • That's it, problem solved.

Service Pack 2 for Office SharePoint Server 2007 and Windows SharePoint Services 3.0 released

Microsoft has just released Service Pack 2 for MOSS 2007 and WSS 3.0. It includes all the fixes prior to SP2, and also several enhancements to improve server farm performance, availability and stability.

Here is the description of the for Service Pack 2 for WSS 3.0 and MOSS 2007.

To download the Service Pack 2 files:

Download Service Pack 2 for Windows SharePoint Services 3.0, x86 & x64

Service Pack 2 for Office SharePoint Server 2007, x86 & x64

To update your WSS 3.0 server (needs to be run on every SharePoint server):

  • Install Service Pack 2 for Windows SharePoint Services 3.0
  • Install Service Pack 2 for Windows SharePoint Services 3.0 Language Pack (if applicable)
  • Run the SharePoint Products and Technologies Configuration Wizard or "psconfig –cmd upgrade –inplace b2b -wait” in command line

To update your MOSS 2007 server (needs to be run on every SharePoint server):

  • Install Service Pack 2 for Windows SharePoint Services 3.0
  • Install Service Pack 2 for Windows SharePoint Services 3.0 Language Pack (if applicable)
  • Install Service Pack 2 for Office SharePoint Server 2007
  • Install Service Pack 2 for Office SharePoint Server 2007 Language Pack (if applicable)
  • Run the SharePoint Products and Technologies Configuration Wizard or "psconfig –cmd upgrade –inplace b2b -wait” in command line
The version of content databases should be after successfully applying these updates.

Using ADFS with SharePoint

To configure Active Directory Federation Services (ADFS) to work with SharePoint follow these instructions:

I have to say that it's awesome that we can configure SharePoint to use ADFS for user authentication as eases the burden on the SharePoint users because they don't have to remember another username and password. This is especially useful, if you're using SharePoint for public-facing website. I wish it was easier to configure though. Here are a few "gotchas" that I have encountered trying to get ADFS working with SharePoint:

  • Extend your SharePoint web application to dedicate a separate section/URL for ADFS authentication
  • The configuration guides are very exact, in the sense that everything must be done exactly as it says in the guide. If you do not follow the instructions to the point or if you miss a step or two, ADFS authentication won't work and it will be nearly impossible to figure out what you did wrong. More often than not, it will be a lot easier to uninstall/reinstall ADFS and try again
  • Read your old notes on PKI and DNS, because configuring ADFS with SharePoint requires your PKI and DNS skills to be very sharp. Let's face it we tend to forget skills that we do not use on day to day basis
  • Use ADFS Diagnostics Tool, it is a very useful tool
  • Use ADFS Organizational Group Claims when assigning access permissions in SharePoint
  • To assign permissions to a specific user (instead of the assigning permissions through ADFS Organizational Group Claims), user must log in to the SharePoint first.

Good luck!

Building public-facing websites using SharePoint 2007: custom branding and development

This is a second part of the blog post on building public-facing websites using SharePoint 2007. The first part was dedicated to the planning building public-facing websites using SharePoint 2007.

Start with the minimal master page

Create a new blank master page using SharePoint Designer. I do not recommend basing your first custom master page on existing master pages templates, as those usually have a lot of SharePointy fluff that you do not necessarily want on your page. Start from scratch and only add the stuff you want/nee into your master page. Remember you can always come back to that master page and add more stuff in it later, if needed. Here is an excellent guide from Microsoft on how to how to create a minimal master page.

Building content types and page layouts

Building content types and page layouts is done in the following order:

When creating page layouts, try keeping the number of created page layouts to a minimum. Remember that page layouts are to be used only to define common "layouts" of your site, and you do not need a separate page layout for every single page on your site. Keeping the number of page layouts to a bare minimum will not only keep the size of your content database(s) to a minimum, but it will also you're your site a lot easier to manage.

Custom XSLT

A lot of the stuff in SharePoint is customized using XSLT files. For example, pretty much everything in Custom Query Web Part can be customized in XSLT file. There is also built in XSLT files that allows you to customize they some of the SharePoint content looks:

XSL Style Sheet


Corresponding Web Part


"Application" XSL style sheet

Content Query


Group headers for Content Query and Summary Links, title headers for Table of Contents

Content Query, Summary Links, Table of Contents


Content Query and Summary Link item styles

Content Query, Summary Links


Table of Contents level styles, which includes the site and its pages

Table of Contents


"Application" XSL for Summary Links

Summary Links


"Application" XSL for Table of Contents

Table of Contents

Here is a guide on how to create custom item styles in SharePoint:

Source Control might save your…

It's always (and I mean always) a good idea to store your custom code in the Source Control such as Microsoft Team Foundation Server 2008. I strongly recommend that you store in the source control all your custom branding items: master pages, page layouts, CSS files, javascripts, images, configuration files, etc… Utilizing source control will not only allow you to keep a better track of the changes to your code, but it will also make it easier to integrate your custom code into the rest of your SharePoint deployment solution.

Use features to deploy

Features in SharePoint could be used to optimize the process of deployment and re-deployment of SharePoint master pages and page layouts. Here is couple of guides on how you can deploy master pages and page layouts as a feature: and

Also, you can use features to deploy reusable content, such as stylesheets, images, javascript files, configuration files, and, of course, the static pages that will always appear on the site (contact us, careers, etc.). This way moving that content between servers (between staging and production servers, for example), can be done using a simple mouse click (or two) instead of manually re-creating that content every step of the way.

Naturally, there is a lot more to SharePoint custom branding to development, but those are the items that I remember off the top of my head. I will update the blog post if I remember anything else.

Meanwhile, the next topic of this blog post series is everything about SharePoint search functionality on public facing websites.

Related resources:

Building public-facing websites using SharePoint 2007: Planning

ObjectSharp has been working with SharePoint technologies for years now: building public facing websites and intranet for the clients, developing custom SharePoint web parts and features, designing custom templates, and so on... Oh yes, I forgot to mention hundreds of hours of SharePoint training (public and private) for developers and power users that we have taught to our clients. But, despite this tremendous amount of SharePoint expertise ObjectSharp has built up internally, we never had time to move our own corporate website to Microsoft Office SharePoint Server 2007 platform. Long story short, finally, the vast benefits from moving to SharePoint platform outweighed the problems with dedicating our own internal resources to this project, and we have received a go ahead to proceed with the project. As a project manager for this SharePoint migration project, I would like to share with you the experience and the certain amount of wisdom we have gained from this project of moving our original "sophisticated and fancy-looking" website to the SharePoint-based web content management platform.



As in any other project, we have identified the goals that will determine if the projects have been successful or not:

  • SharePoint-based website must look exactly (or as close as possible) as our original website
  • SharePoint-based website must keep all existing functionality of the original website (public and administrative parts). All additional features for the new site will be added in the future website versions.
  • SharePoint-based website must leverage existing SharePoint features and minimize the amount of custom code as much as possible
  • The migration has to be transparent to our clients and the effect on our SEO ranking should be minimal


Planning infrastructure for SharePoint environment

To properly plan the infrastructure for SharePoint environment we need to know

  • What are we going to use SharePoint for?
  • What features of SharePoint will be utilized?
  • How many visitors do we expect on the website? What's the expected server load?
  • What will be the expected size of the website? How often will the website be updated?
  • What are the performance requirements for the site?
  • What are the availability requirements?
  • What are our disaster recovery policy and standard maintenance schedules?

Here is an excellent link for estimating performance and capacity requirements for SharePoint servers: Also if you require redundancy and availability in your SharePoint environment here are the guidelines from Microsoft for that: and


Planning the development and production environments

It's always a good idea to separate development environment from the production environment. D'oh! Ideally, you will have separate SharePoint farm for developers, testers, content authors, and, of course, separate SharePoint farm for production.

  • An authoring environment in which site content will be authored and approved for publication. This will also be the environment that site designers use to create layouts, master pages, and other site artifacts. This environment includes an Office SharePoint Server 2007 farm along with the workstations that site designers, authors, and editors use.
  • A development environment in which custom site elements will be developed. This includes developer server workstations, a source control system, and a small Office SharePoint Server 2007 integration farm for integrating the various coded elements and testing them by using sample content.
  • A production environment in which the Internet presence site is available to site visitors. This includes two server farms:
    • The primary publishing farm
    • A parallel but smaller farm that provides failover in case the primary farm becomes unavailable, and that also will be used to pilot new site features.

For more information visit


Determine website structure and navigation

To comply with the project goals we needed to keep the existing site structure and navigation, so we have copied over the website structure to the new site. Luckily, SharePoint allows you to shape your site structure any way you want. We have created a single web application for our website, as it's more than sufficient. We have enabled anonymous access to the web application. We have also extended this web application to include support for SSL.

Now, we had to find the way to transfer our navigation menu to the new site. One of our consultants and Microsoft MVP, Justin Lee, had an answer for us: to use ASP.NET menu control with CssFriendly adapter. With a minimum of configuration tweaking and no custom code necessary we're able to get the menu transferred within an hour or so, but let's not jump ahead J


Determine authored elements: custom master pages, stylesheets, page layouts, content types, web parts, etc.

At this point, need to come up with a draft of what and how many master pages will we require, what kind of page layouts do we need, what stylesheets and javascripts will be included in master pages or page layouts, what content types and site columns we need to create, what web parts and/or features we need to develop, and so on and so forth. Basically, we need to try to determine the kind of content that will be added to our website, and the best way we can implement those authored elements.

Because master page will be loaded with every page, you need to make sure that your master page(s) contain only the minimal amount of content. In other words, only include primary stylesheet and javascript files to the master page to make sure that your pages load fast(er). Microsoft has an excellent guide on how to create minimal master page. Please note that minimizing the number of master pages will help to promote the consistency of styles and branding throughout your site (ideally, you would have only one master page).

When determining the page layouts and content types required for the website, you need to know what kind of content will be present on the page(s) and how it will be displayed to the public. I usually compile a list of different type of pages that the website will have, along with the list of entries that will be displayed on those pages. Having an original wireframe for the website will make this process so much easier.

Almost all content in our new SharePoint-based website will be in a form of a web part. Fortunately, SharePoint has a lot of built-in web parts that will be able to accommodate most of the content to be moved. Content Editor webpart, Content Query webpart, Image webpart are three web parts that you will probably use the most on your website. Naturally, sometimes your website will require functionality that SharePoint does not support out of the box, so Microsoft has provided the tools that will help you to develop all kinds of custom features. You need will to download Microsoft Office SharePoint Server 2007 SDK, SharePoint Extensions for Visual Studio 2008, and, of course, the copy of SharePoint DLLs from the SharePoint server! Please note, you can find a lot of information for SharePoint developers at


Now it's time for a little bit of SharePoint branding and development….

Related resources:

Deploy SharePoint Central Administration to more than one server in the SharePoint farm

There is a lot of conflicting information on the net whether it's possible to have more than one SharePoint server hosting SharePoint Central Administration site in the farm. I know for the fact that it's possible to have more than one server hosting SharePoint Central Administration site to provide high availability for that part of the SharePoint environment. Here is it can be done:

  • Let's say you have two SharePoint servers: Server A and Server B. Server A hosts SharePoint Central Administration site, Server B doesn't
  • To add SharePoint Central Administration site functionality to the Server B, run SharePoint Configuration Wizard on the Server B and at the "Completing the SharePoint Products and Technologies Configuration Wizard" step, click on Advanced Settings
  • Select "Use this machine to host the website" to add SharePoint Central Administration site functionality and hit OK. Click Next to start the configuration wizard
  • After the configuration wizard completes successfully, you will have additional server providing Central Administration functionality. To verify that it's in fact true, open SharePoint Central Administration site and under Farm Topology you should have Central Administration functionality listed under both servers.

How to Fix “The file exists. (Exception from HRESULT: 0x80070050)…” error on SharePoint

If you're getting the error "The file exists. (Exception from HRESULT: 0x80070050)", when you attempt to access your SharePoint site, or even SharePoint Central Administration site, the chances are that some (or all) SIDs on your server were changed. This has probably happened because you have removed and recreated some user accounts that you use to run SharePoint services, or you have run sysprep on your server, or you have recently turned your SharePoint server into Active Directory domain controller. It's not a good idea to do any of those things with your SharePoint server, but I'm not here to judge – I'm here to help J

Please note, that the steps described below is a "low-tech" solution to the problem, which requires you to actually understand what you're about to do. USE AT YOUR OWN RISK!!! And, of course, do not forget about backups, backups, backups. Also, I would like to point out the credit for this solution goes to the blog and his/her author that is no longer online.

Anyway, to solve "The file exists. (Exception from HRESULT: 0x80070050)…" error:

  1. Login to your SharePoint and open SQL Server Management Studio. Create New Query
  2. To get the list of Site IDs you need to use SharePoint_AdminContent_* database for Central Administration Site and run the following query:
    SELECT s.Id, w.FullUrl FROM Sites s inner join Webs w on s.RootWebId = w.Id
  3. As a result of the query above, you will see all Site IDs for the selected database. Now, using that data, run a new query:
    SELECT * FROM UserInfo WHERE tp_Login='Hostname/Username' and tp_SiteID='XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX'
    where tp_Login is the hostname and username using which you're trying to login to SharePoint; and tp_SiteID is the site ID from the previous query
  4. As a result of the query above, you will see the SID for the selected user. Now, here comes the tricky part, you need to get SID number for the user account that you're logging in with (in my case, it was Administrator account) and convert it to hexadecimal format:
    1. To get SID for a user account, you can use PSTOOLS utility. Run PSGETSID \\HOSTNAME USERNAME to get SID info
    2. To convert the SID to hexadecimal format, use the following VB script and run it against the SID obtained in the previous step: sid2gex.vbs mySID, where my mySID is the SID for the user account you're working with. As a result, you will receive SID in the hexadecimal format.
  5. Now we will update our database table with newly obtained SID using:
    UPDATE UserInfo SET tp_SystemID = 0x010500000000000000000986BD9EA976E44036C3F5D3F04040000
    FROM UserInfo
    tp_Login='hostname\username' and tp_SiteID = 'XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX'
    where tp_ID, tp_guid, tp_Login and tp_SiteID are the attributes of the user account for which we want to update tp_SystemID. Note: you might have to repeat those steps for the services accounts which are running your search, shared services provider, etc.

After implementing the steps above, you might have to update service accounts in the SharePoint configuration. Microsoft has an excellent guide on how to make those changes.

Join SharePoint server to the Active Directory domain

If you need join existing SharePoint server to your Active Directory domain, then you're in for a treat. Joining the SharePoint server to the domain will mess up the authentication in SharePoint and cause errors. To join SharePoint server to the Active Directory domain without breaking SharePoint authentication:

  • Back up all SharePoint content databases and all customizations that you have made to the SharePoint (stylesheets, javascript files, image files, web parts, config files, and so on)
  • Uninstall SharePoint completely from the server
  • Join the server to the Active Directory domain
  • Reinstall SharePoint Server (make sure to use different names for content databases)
  • Restore your SharePoint content databases
  • Add restored content databases to the SharePoint web application(s) using "stsadm -o addcontentdb" command
  • In SharePoint Central Administration >> Application Management >> Content Databases, change status of existing content databases to Offline, and set the status of the recently restored database to Ready
  • Copy over the customizations that you have backed up in the beginning (stylesheets, javascript files, image files, config files, and so on) and install missing web parts, features, solutions, etc.

That should be it. Simple, right? J

Creating custom list from hidden Event content type

For some reason, Microsoft has decided to hide Event content type in SharePoint (MOSS/WSS) and prevent users from creating a custom list based on that content type. To unhide Event content type:

  1. Open your existing calendar on the site and go to List Settings
  2. Click on Advanced Settings and change the settings to "Allow Management of Content Types", which will reveal the Event content type in that list settings
  3. Click on the Event in the list of content types
  4. Under List Content Type Information click on the Parent link, which is strangely enough also called Event
  5. Under Settings click on the "Name, Description & Group" link and assign Event content type to the new group, for example "List Content Types". That's it, from now on you will be able to create custom lists based on the Event content type


There is another way to unhide Event content type, and even though I find it less graceful, I think it's worth mentioning:

  1. Go to [Drive]:\Program Files\Common Files\Microsoft Shared\web server extensions\12\TEMPLATE\FEATURES\ctypes\ folder and backup the contents of that folder
  2. To unhide Event content type, run
    stsadm -o deactivatefeature -filename "ctypes\feature.xml" -url http://[SharePointWebApp]
    stsadm -o activatefeature -filename "ctypes\feature.xml" -url http://[ SharePointWebApp]