in

SharePoint Blogs

The Best Place for SharePoint-related Blogs

Michael Hofer - SharePoint Blog

Michael Hofer's blog about adventures in SharePoint land, including tips and tricks for all products and technologies used in Information Worker solutions.

September 2007 - Posts

  • SharePoint Wiki: Create pages based on a template

    Creating Wiki-Pages from a Template

    To make Wiki pages look uniform, it would be handy if there was always the same template used when the pages  are created. Unfortunately, WSS 3.0/MOSS 2007 doesn’t support this functionality (yet). The below paragraphs show the concept on how to achieve this functionality. Neither the code nor the configuration steps described are suitable for a production environment – they are just the proof-of-concept that it is possible. Adopt it freely!

    The configuration part

    1.       Create a WIKI site

    2.       Create a Custom List called something like “Page Templates”

    3.       Add a custom column “Template” and make it multi-line rich-text including pictures etc.

    4.       Now create your HTML Template.

    5.       Copy your HTML (only the part inside the <body> of course) and add an entry in your custom list. In my example, the title is “Wikipedia” and in the “Template Column” switch to HTML view and paste your HTML Teplate

    6.       If your template needs a separate stylesheet, you must proceed like with any other stylesheet in MOSS (and make sure it doesn’t interfere with the standard styles so your layout gets corrupted…):

    a.       Upload the style sheet to the appropriate location in the Styles Library

    b.      Add a link to the style-sheet to the master page (Example: <SharePoint:CssRegistration name="<% $SPUrl:~sitecollection/Style Library/wikipedia_common.css %>" runat="server"/>)

    The development part

    Before I show the development steps this warning: This is a quick’n’dirty approach in a development environment and you mustn’t change standard MOSS-files! If you want to use this in a real environment, create a custom site definition where the Wiki Pages list doesn’t point to _layouts/CreateWebPage.aspx but to your own page which is deployed with your custom site definition. However, the scope of this instruction is only to show how it is supposed to work. Please keep this also in mind when looking at the code!

    1.       Create a new class-library

    2.       Make sure it will be signed

    3.       Add two references:

    a.       Microsoft.SharePoint.dll (12\ISAPI)

    b.      Microsoft.SharePoint.ApplicationPages.dll (\12\CONFIG\BIN)

    4.       Create your class inheriting from CreateNewWeb as shown in the code example. I guess the code is self-speaking:

    using System;
    using System.Web.UI;
    using Microsoft.SharePoint.ApplicationPages;
    using Microsoft.SharePoint.WebControls;
    using Microsoft.SharePoint;

    namespace Mho.SharePoint.Trials
    {
        public class EnhancedCreateWebpage : CreateWebPage
        {
            protected ListFieldIterator listFieldIterator;
            protected string template;

            public EnhancedCreateWebpage() { }

            protected override void OnPreRender(EventArgs e)
            {
                if (!this.Page.IsPostBack)
                {
                    // Get the templates list
                    SPList templatesList = this.listFieldIterator.Web.Lists["Page Templates"];
                    if (TemplateSourceDirectory != null && templatesList.Items.Count > 0)
                    {
                        // Just take the first template for demonstration
                        this.template = templatesList.Items[0]["Template"].ToString();
                    }
                    templatesList = null;

                    this.FindRichTextControl(listFieldIterator);
                }
                base.OnPreRender(e);
            }

            private void FindRichTextControl(Control control)
            {
                foreach (Control childControl in control.Controls)
                {
                    if (childControl.GetType().Equals(typeof(Microsoft.SharePoint.WebControls.RichTextField)))
                    {
                        ((RichTextField)childControl).Value = this.template;
                        return;
                    }
                    this.FindRichTextControl(childControl);
                }
            }

        }
    }

    5.       Compile and deploy to the GAC

    6.       <Warning! See above paragraph – this is not supported!>

    a.       Open the file “12\TEMPLATE\LAYOUTS\CreateWebPage.aspx” (a backup could maybe be handy…)

    b.      Change the header to point to your assembly:
    <%@ Assembly Name="Mho.SharePoint.Trials, Version=1.0.0.0, Culture=neutral, PublicKeyToken=261ba54b9846991b"%>

    c.       Set the correct class to inherit from
    <%@ Page Language="C#" Inherits="Mho.SharePoint.Trials.EnhancedCreateWebpage"…

    d.      Add the name of the “ListFieldIterator” control you’ve used in the class code as its ID:
    <SharePoint:ListFieldIterator ID="listFieldIterator"

    7.       Recycle the application pool and try it out.

      

     

  • MOSS 2007 profile import using BDC with Single Sing-On: Permissions

    If you want to extend your profiles with data not only coming from an LDAP source, but also from the BDC you have to be aware of some permission settings in order to prevent you from a severe headache. And even more when you connect to your external data source using the Single Sign-On service.

    Configuring the import's custom datasource is pretty easy, so I won't get into this. But now comes what is not so obvious: How to set the permissions to make this work

    1. Make sure you know the account on which the profiles are crawled. This is ususally the default content access account specified for the search (you cannot specifiy a special useraccount for the BDC custom datasource!
    2. This account must be member of the group you've specified in the Single Sign-On settings page for the SSO application that is used in the BDC instance of your application definition.
    3. Also, this account must have "Execute" rights on the BDC, the application and don't forget the instance itself! (I'm not so sure here, but there are these 3 levels of permission - instance is needed in any case!)
    4. Make sure that this account hase the "Manage Audiences" right in "Personalization services permissions".

    Uff... that's all. Now it should work. Happy trying

     

  • Sharepoint cannot authenticate to ISA Server - Resolved: Kerberos needed

    This gave and gives me a hard time! Imagine MOSS 2007 running in a corporate intranet. Your requirement is to connect to datasources on the internet. There are various scenarios, the most common are to

    • Consume RSS Feeds using the RSSFeed webpart
    • Consume a WebService or Server-Side Script using the SharePoint Designer DataView Webpart

    When using the DataView WebPart, you'll get the following error message when trying to show the data from the internet source:

    “The server returned a non-specific error when trying to get data from the data source. …”

     

    When connecting using the RSSFeed Webpart, the error message will be even less saying...

     

    OK, what can we do? Make sure that you've set the proxy in the web.config of your SharePoint Site Collection, as documented by Microsoft here: http://support.microsoft.com/kb/923173

     

    However, this might still not do the trick! The DataView WebPart still shows the same error message. However, the RSSFeed Webpart is this time a little bit more specific:

     

    “ProxyAuthenticationRequired (The ISA Server requires authorization to fulfill the request…)"

     

    So wat is the problem? It seems (and some other bloggers mentioned this explicitely) that SharePoint doesn not authenticate itself towards the ISA Server! The only solution to this problem is to allow requests from all the IP addresses of all SharePoint WFE Servers to pass through ISA! (wheew, I hear your customers start to question you louder than normal - at least this is what happened here ;))

     

    Well, this is what I know so far and granting all requests of my SharePoint WFE's to pass through works just perfectly. I'll try to investigate in this a bit more internally and make sure that MOSS server-side authentication is included in Office 14...

     

    UPDATE: This is a double-hop problem! If you use Kerberos authenticaion, there is no problem! Thanks smyttie!!!

     

    Hope this helps some of you to save a lot of valuable time...

     


Need SharePoint Training? Attend a SharePoint Bootcamp!

Posts (c) their respective authors. Everything else (c) 2007 SharePoint Experts