Query Component 0 not responding


Recently I went back to my development VM which contains AD, Win Server 2008 R2, SharePoint 2010, etc. I use this VM to build a number of demo sites and when I tried to search, I cannot get any results.

I went to Search Administration to see what is the issue, whether I turned off the crawl, did not set the correct content source, or what. The first thing I see is the propagation status is Query Component is not responding. So my first instinct is to check the error log in event viewer and ULS. The error I got is:

* file copy failed (error 0x80070035: The network path was not found). 0x80070035, source C:\Program Files\Microsoft Office Servers\14.0\data\office server\applications\[Guid]-crawl-0\projects\portal_content\indexer\cifiles001000F.ci, destination \\Machine Name\[Guid]-query-0\[Guid]-query-0\Projects\Portal_Content\indexer\CiFiles000.0001000F.ci.cp) [indexpropagator.cxx:403] d:\office\source\search\native\ytrip\tripoli\propagation\indexpropagator.cxx

Looking at this error, I assume it has to do with SharePoint unables to copy/move index files from crawl temp folder to query search folder. So to resolve this, I went to ensure WSS_WPG group has full control access to the destination folder.

However, when I looked at the shared folder permissions and security, WSS_WPG group already has the appropriate access.

The next thing I do is to ensure I disable the loopback check, because I only use a single server for my environment, and Windows Server 2008 has a loopback check. So I follow the steps specified in http://support.microsoft.com/kb/896861

After disabling the loopback check and recreating a new Search Service Application, I checked whether the propagation to Query component has been successful. Unfortunately, it gave me the same error.

Then I remember that I use to have performance issue with this VM and I disabled a number of services and uninstall the unnecessary components. One of the things I uninstalled is File and Printer Sharing for Microsoft Networks in my network card properties. So I installed it back in the network card.

After restarting the machine, and recreating the Search Service Application, I ran the fresh crawl and hope for the best. Couple minutes later (since it only contains a number of demo sites with minimal content), I can see successful propagation. Yay me!!

So in summary, if you have a problem with Query Component 0 not responding, please ensure you check:

  1. WSS_WPG has the right permissions to the shared folder
  2. If it is a single development server, ensure you disable loopback check
  3. Ensure you have File and Printing Sharing for Microsoft Networks installed in your network card.

That’s all from me. Happy SharePointing!!

SharePoint 2007 – Predefined Table format


During the implementation of our project, we needed to create predefined table format that can be used in rich text editor. In order to achieve this, we updated the HTMLEditorTableFormat.css that resides in 12 Hives/Template/Layouts/1033/Style folder with new styles in the provided CSS classes.

However there are already existing table formats which were added previously by other projects. And with SharePoint 2007 SP1 (my client is yet to upgrade their environment), we found an issue where the new format that we defined do not show up in the drop down list selection when user wants to use a predefined table format.

When SharePoint detects that there are predefined table formats that are not part of the out-of the box table formatting, SharePoint will strip the out-of the box formats and only display the custom ones as part of the selection. For some reasons, the new formats on top of the previously defined format cannot be displayed (it looks like it’s being cached somewhere unknown).

To get around this issue, I come up with a change that will force the display of all available predefined table formats. In order to do this, you will need to change SharePoint system file (so this is not officially supported, and make sure you backup the original file).

What you need to do is to update the RTE2ETable.aspx in the 12 hive/Template/Layouts. Replace the following line of code:

var availableTableStyleNumbers = getAvailableTableStyleNumbers(tableValidRules, tablePrefix);

with

var availableTableStyleNumbers = getAvailableTableStyleNumbers(tableAllRules, tablePrefix);

Once you save the file, the drop down list in selecting the predefined table formats will display all available formats.

Hope this is useful for you.

Happy SharePointing.

SharePoint 2007 – SPWeb Navigation properties


To set SPWeb Navigation properties through code, you can use:

  • SPWeb.Navigation.UseShared for top navigation. If you set SPWeb.Navigation.UseShared = true; it will inherit top navigation from the parent web.
  • SPWeb.AllProperties[“__InheritCurrentNavigation”] for Quick Launch navigation. If you set SPWeb.AllProperties[“__InheritCurrentNavigation”] = “False”; it will only display navigation below the current site.
  • SPWeb.AllProperties[“__NavigationShowSiblings”] for displaying navigation on sibling site. If you set SPWeb.AllProperties[“__NavigationShowSiblings”] = “True”; it will display navigation from the sibling sites.

Hope this helps.

SharePoint 2007 – Applying new page layout to publishing site default.aspx


Recently while working on a client site to create a new extranet site, one thing I found that is annoying on SharePoint 2007 is that I cannot change the default.aspx, that is created automatically when you create a publishing subsite, to use my new page layout.

The workaround to do this is by creating a new page using the intended page layout, and set the subsite welcome page to the new page.

However, in my project, I have to do the workaround for 700 plus subsites. To make my life a little bit easier in deploying this project, I wrote a custom solution to help me achieve this.

The following is the snippet of my code:

using (SPSite site = new SPSite(url)) {
using (SPWeb web = site.OpenWeb())  {
SPContentTypeId ctId = SPContentTypeId.Empty;
using (SPWeb rootWeb = site.RootWeb)  {
//Find the content type that is associated to the new page layout
SPContentType ctWelcomePage = rootWeb.ContentTypes[“Welcome Page”];
ctId = ctWelcomePage.Id;
}
if (ctId != SPContentTypeId.Empty) {
PublishingWeb pWeb = PublishingWeb.GetPublishingWeb(web);
PageLayout[] pLayouts = pWeb.GetAvailablePageLayouts(ctId);
PageLayout pLayout = null;
//Find the page layout that we want to use for the new page
foreach (PageLayout pl in pLayouts) {
if (pl.Name.Equals(“MyWelcomePage.aspx”,                   StringComparison.InvariantCultureIgnoreCase))

{

pLayout = pl;

break;

}

}
if (pLayout != null) {
PublishingPageCollection pages = pWeb.GetPublishingPages();
//Create new default page using our chosen page layout
PublishingPage page = pages.Add(“MyNewDefault.aspx”, pLayout);
page.Title = “Home”;
page.Update();
pWeb.DefaultPage = page.ListItem.File;
pWeb.Update();

//By default, Pages will have approval workflow. Just ensure you approve the page
if (page.ListItem.File.CheckOutStatus != SPFile.SPCheckOutStatus.None) {
page.ListItem.File.CheckIn(“New page with proper page layout”);
}
page.ListItem.File.Publish(“New page with proper page layout”);
page.ListItem.File.Approve(“New page with proper page layout”);
}
}
}
}

Of course if you are neat-freak, you can delete the existing default.aspx, rename the new page we created to default.aspx.

For my case, I created a console application that helps me during deployment to automatically create default page using my page layout throughout my subsites.

Note that to use PublishingWeb class, you need to add reference to Microsoft.SharePoint.Publishing.dll that can be found in 12 hive under ISAPI folder. And ensure you reference Microsoft.SharePoint.Publishing in your code.

Happy coding…

p.s: Apology for non-tabbing codes. WordPress keeps losing the tabbing on the code snippet.

Word Web App cannot open this document for viewing because of an unexpected error. To view this document, open it in Microsoft Word.


Ever get this error message when you try to view or edit Word Document within the browser for SharePoint 2010?
 
" Word Web App cannot open this document for viewing because of an unexpected error. To view this document, open it in Microsoft Word"
 
There are a number of possibilities that caused this issue. The issues that I encountered is with my standalone development VM, which is a Windows Server 2008 R2 Standard x64 with a DC role enabled.
 
First issue I encountered is due to having a DC role within the SharePoint server. To resolve this issue, Jie Li posted a solution for this, which involves executing several PowerShell commands (http://blogs.msdn.com/b/opal/archive/2009/11/16/installation-notice-for-sharepoint-2010-public-beta.aspx)
 
However, I encountered second issue that took me awhile to notice that it got nothing to do with my configuration. What I found is that the error will still occur if your Word document has Track Changes on. For some reasons, Word Web App does not support word document that has Track Changes.
 
Once I adjusted my document, it works like a charm.
 
I will encourage my users to leverage version control and version comparison function within Word, instead of Track Changes for my site that needed to use Office Web App, and I will suggest for you to do the same.
 
Happy SharePointing! 

Internet Explorer 9 Beta (Updated with RC)


So I finally managed to install Internet Explorer 9 Beta RC. My first impression is good. I like the minimal approach on the UI. However, there are  few shortcomings that I hope Microsoft will fix it for final release since it is a deal breaker for me:
  • I dislike the display of frequently visited sites when I open the new tab, because it displayed up to the page level. I prefer if I have the control to set whether I want the site or page level.
  • It does not seem like IE 9 Beta is fully integrated with SharePoint 2010. It is such a shame and forced me to downgrade to IE 8. Hopefully the fix comes soon.
  • I enabled ClearType in rendering the page, however it looks a bit fuzzy on my work laptop. It is unfortunate that such a wonderful browser cannot render sharp font text. Perhaps it is due to my laptop’s graphic card.
  • The page loading could be more prominent, since I spent a lot of time waiting for a response when I connect to SharePoint 2010 in my VM and unsure whether the page is loading or not.

I guess I will wait until the full release before making my judgement on whether I switch from Google Chrome to IE 9.

I must say that I am quite pleased with IE9 RC. The progress wheel on the tab, though it is small, now show the correct progress while the page is loading. I also like the fact that I can move the tabs into separate row, since I look at URL a lot as a SharePoint consultant.

Overall feel for IE9 RC is that it is snappier and able to load most of the websites I go regularly.

I am going to give it a go for couple months, but so far my impression of IE 9 RC is very good 🙂

Delete files through SharePoint Designer data view webpart


 

In keeping with the scary Halloween theme, I would like to share a quick tip on how to provide SharePoint Designer data view webpart the ability to delete file (gasp…)

In order to achieve this, we will have to tinker with the xslt that is generated by the data view webpart. So first, you will need to add the dataview webpart on your page to display the contents of document library. You can also use the webpart to aggregate the contents from multiple document libraries. Once you have done that, you will need to add a column (any column will be fine), where we will replace the content of that column to provide the delete link.

Once you add the “dummy” column, locate that in the source view. Replace that with the following:

<a href="javascript:SubmitFormPost(‘/[Relative site]/_vti_bin/owssvr.dll?Cmd=Delete&amp;List=[List GUID]&amp;ID={@ID}&amp;owsfileref={@FileRef}&amp;NextUsing=[Page to go after delete]’);" onclick="return DeleteItemConfirmation();">Delete </a>

Replace the following:

  • [Relative site] = The relative site where your document library is (e.g. /sites/test)
  • [List GUID] = The list GUID. You can find it easily by looking at the web address URL when you browse to list settings (e.g.: =%7B9A3C5BDF%2DDA36%2D4D48%2DBE5D%2D7CAC5B0C9975%7D)
  • [Page after delete] = The page you want redirection to once the delete function is called. (e.g.: /sites/tests/pages/delete_dataview.aspx)

It is scary how simple we can provide delete functionality to end users. However, you do not need to worry. This delete function does exactly what the delete function through SharePoint UI, so if you have recycle bin, then the document will be sent to it.

Note that if your dataview webpart aggregates the contents from multiple document libraries, then you need to provide separate links for separate document libraries, since you will need to pass appropriate document library GUID. What I have done for my dataview webpart is to provide choose-when-otherwise clause of XSLT.

Happy Halloween and happy coding…

Selectively hiding contents in SharePoint page


 

Have you ever needed to hide certain contents on your SharePoint page, be it a control or custom javascript? Luckily, SharePoint provides a control to allow you to do just that. The control is SPSecurityTrimmedControl. If you use SharePoint Designer to edit your page and insert this control, anything within this control will only be rendered on your page if it passes the criteria. The criteria it uses is SharePoint permission. You can easily google/bing this control for more information.

However, this control does not meet my requirements. I needed to selectively provide contents based on SharePoint groups, not permissions, since multiple groups can have the same permissions. If you ever have to meet this kind of requirement, do not panic. The SPSecurityTrimmedControl can be easily extended. Below is the code I created for my custom control that extends SPSecurityTrimmedControl.

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Microsoft.SharePoint;
using Microsoft.SharePoint.WebControls;
namespace Yaohan.SharePoint.CustomControls
{
    public class SPGroupTrimmedControl : SPSecurityTrimmedControl
    {
        private string groupName;
        public string GroupName
        {
            get { return groupName; }
            set { groupName = value; }
        }
        protected override void Render(HtmlTextWriter output)
        {
            if (IsUserInGroup())
                base.Render(output);
        }
        private bool IsUserInGroup()
        {
            bool retVal = false;
            foreach (SPGroup group in SPContext.Current.Web.Groups)
            {
                if (group.Name.Equals(GroupName))
                {
                    retVal = group.ContainsCurrentUser;
                }
            }
            return retVal;
        }
    }
}

What you need to do is whip up Visual Studio and create a web control project. Make sure you “strong name” the project and sign it.

To deploy, you can drop the DLL in GAC, however I will strongly advise you to package this up using SharePoint solution, which should be simple enough to do (create manifest.xml, reference the DLL on assemblies tag and the safe control tag).

After you deploy your DLL, you need to register your custom control, either on your page (if it’s page-specific), page layout or masterpage. Below is the snippet of control registration

<%@ Register Tagprefix="Yaohan" Namespace="Yaohan.SharePoint.CustomControls" Assembly="Yaohan.SharePoint.CustomControls, Version=1.0.0.0, Culture=neutral, PublicKeyToken=3e15ae9471d9f940" %>

And to use the control in your page, you can do the following:

<Yaohan:SPGroupTrimmedControl ID="GroupTrimmedControlForReaders" GroupName="Yaohan Special Group" runat="server">

Kudos to Yaohan special group only.

</Yaohan:SPGroupTrimmedControl>

Now you can extend this control to selectively display contents to not just SharePoint group, but AD group (ala target audience). Multiple groups, or collection of users.

You may ask why you should do this instead of using content editor webpart with target audience. In my scenario, I cannot use content editor webpart, because I need a quick and easy way to hide fields in item display form based on the group the current user belong to. For example, if you have details of asset inventory, I only want to show a general information about the assets for read-only general readers (such as description, photo, etc), but for specific group, I want to show more details.

The way I achieve this is by having a javascript between my custom controls to hide the fields I don’t want to show. Beware that the javascript is only to hide the information, not securing it, thus if users know what they’re doing and view the page source, they can still find the information. If you want a field-based security, there is a third party product that caters for that.

Credit goes to http://blah.winsmarts.com/2008-5-Enhancing_the_SPSecurityTrimmedControl_-_Trimming_UI_on_any_critereon.aspx for providing me inspiration.

STSADM restore collaboration portal site collection in new content database issue


Today, I tried to restore a site collection from a backup site collection file to a site collection that I created in new content database. The following is the scenario I took:

1. I used stsadm –o backup –url to create a site collection backup file. My site collection is based on collaboration portal site definition (SPSPORTAL#0)

2. I created a new site collection in new content database using stsadm –o createsiteinnewdb using SPSPORTAL#0 as my site template

3. I used stsadm –o restore to restore my backup file into the new site collection.

Everything is reported okay, but beware that the site is not correct. If you go to check the site content types and site columns, it is empty. Thus, it will cause all sorts of problems.

So, just be careful when you’re trying to move your site collection using stsadm backup restore while using SPSPORTAL#0 site definition.

p.s.: My environment is MOSS 2007 SP1

 

UPDATE: Issue still occurs when you do import export of site collection based on SPSPORTAL#0 with site collection in new content database. In particular, I cannot access the site output cache settings. I didn’t have time to investigate further, so just be aware of this issue.

SharePoint and Kerberos Authentication – Beware of duplicate SPNs.


 

I recently enabled kerberos authentication on MOSS 2007 that uses least privilaged access. While setting up the SPN, I learnt one valuable lesson. You cannot have multiple AD accounts that are associated with the URL.

For example, you cannot have:

domain\app_pool1 associated with http://myportal.com and domain\app_pool2 associated with http://myportal.com

Kerberos ticket won’t be issued when it encounters 2 different account associations for the URL. This article that I found is so valuable:

http://www.windowsecurity.com/articles/Troubleshooting-Kerberos-SharePoint-environment-Part1.html

Kudos to Jesper M. Christensen. You saved a lot of hard work for me

In summary, when you want to enable kerberos on your web application, you just need to associate the identity of your app_pool to the URL.