It is recommended that you create a new site definition and leave the original site definition intact when you want to modify or customize the default Microsoft® Office Project Web Access site definition.

You can create a new site definition by copying and modifying the existing Project Web Access site definition. This task involves use of Collaborative Application Markup Language (CAML) in two schema files: one that is a copy of a WEBTEMPP.XML file and the other a copy of a ONET.XML file. It is recommended that you create a site definition as described in this topic rather than modifying the originally installed WEBTEMPP.XML file.

  1. Copy the existing PWA folder located in the Local_Drive:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\60\Template\1033 directory. Name the new folder using all capital letters, for example PWAPLUS.
  2. Make a copy of the WEBTEMPP.XML file located at Local_Drive:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\60\TEMPLATE\1033\XML.You can give the file a unique name by appending a string to the name of the original file; for example, WEBTEMPPPLUS.XML. At run time, the compiler merges information contained in this file with the information contained in the original file in order to specify which site templates are available for creating new sites.
  3. Customize the contents of the new WEBTEMPP file.Each WEBTEMPP.XML file contains a collection of Template elements and Configuration subelements, which identify to the compiler all the site definitions that can be instantiated. The Configuration element defines a title, a description, and a URL for the image displayed in the user interface, which are properties common to each Web site created using the site definition.

    Important  In each Template element defined in the WEBTEMPP file, the Name attribute must contain the same name, in all capital letters, that is assigned to the new folder. Also, Project Server will only recognize site definitions and global templates with ID ranges between 6000 and 7000, so use unique values within that range for the ID attribute.

    The following example defines a new site definition called PWAPLUS.

    <Templates xmlns:ows="Microsoft SharePoint">
     <Template Name="PWAPLUS" ID="6400">
        <Configuration ID="0" Title="Project Workspace Plus" Type="0" Hidden="FALSE" ImageUrl="/_layouts/images/stsprev.png" Description="This template creates a site for Microsoft Office Project Server 2003 users to organize and share project documents, and to track and resolve project risks and issues. It includes document libraries, a risk tracking list, an issue tracking list and a change tracking list in which the items can be linked to projects and tasks in Project Server. It also includes other basic lists for project collaboration, such as Announcements, Events, Contacts and Quick Links.">
  4. Save the file.
  5. You may need to reset Microsoft Internet Information Services (IIS) for the new template to appear as an option on the Template Selection page.

If you find that the changes you intend to make through a definition or Feature do not take effect, consider the following possible causes:

  • All definition and Feature XML logic is cached in memory. When you install any new files into Windows SharePoint Services 3.0 (for example, new .aspx pages or XML files under the \web server extensions\12 directory), be sure to reset Microsoft Internet Information Services, which you can do by typing IISReset at the command prompt.
  • Windows SharePoint Services 3.0 logs errors during provisioning. Look under \12\Logs and check the latest log for hints as to what might be causing problems.
  • As you debug your feature, you frequently need to accomplish tasks such as changing scopes and changing definitions. If you make changes without deactivating and reactivating Features, you might cause problems for Windows SharePoint Services—for example, having the same Feature registered at both the site collection level and the Web site level.
  • If you create a custom list type through a Feature definition but receive a “File not found” error when you try to create a list, your Schema.xml file might refer to a file that is absent. Ensure that each file referred to within a View or a Form element exists in the underlying file system.
  • Be sure to use “Feature.xml” as the name of your Feature file; otherwise you may receive an error message saying that a “value cannot be null” when you try to install or activate the Feature.

This programming task provides steps for customizing Microsoft® Windows® SharePoint™ Services so that documents can be created or edited from a third-party application. The task involves creating a document template file to complement the ONET.XML file of the site definition, modifying the DOCICON.XML file, and creating a DLL that provides the same functionality as described for the OpenDocuments control.

Adding the ability to create or edit documents within an application involves the following subtasks:

  • Creating a document template file, which in effect adds a DocumentTemplate element to the ONET.XML file of the site definition.
  • Adding a Mapping element to DOCICON.XML for a file type icon and for identification of the control to use to open the file.
  • Creating a DLL that provides the necessary functions for creating or editing documents in the application.

Note  To perform the customizations described in this topic, you must be an administrator on the front-end server running Windows SharePoint Services.

Warning  Changes that you make to originally installed files may be overwritten when you install updates or service packs for Windows SharePoint Services, or when you upgrade an installation to the next product version.

Adding a document template

To add an existing application document as a template that can be used in document libraries, create an XML file in the Local_Drive:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\60\TEMPLATE\Locale_ID\Site_Definition\XML folder containing the ONET.XML file. Give the new file a name in the format doctemp*.xml, where * represents arbitrary text used as part of the file name. Windows SharePoint Services searches this directory for any .xml file that begins with “doctemp” and merges its contents with the document template definitions contained in ONET.XML. The advantage to adding a doctemp*.file, as opposed to modifying ONET.XML directly, is that the custom definition will not be overwritten when Windows SharePoint Services is updated.

The following example shows the format of a doctemp*.xml file for adding a document template. The file can be created in Notepad and given any name that begins with doctemp, for example, doctempmyTemplate.xml.

<?xml version="1.0" encoding="utf-8" ?>
   <DocumentTemplate DisplayName="Blank Document" Type="105" Default="FALSE" Description="A blank document.">
         <DocumentTemplateFile Name="doctemp/Template_Folder/psdtmp1.psd" TargetName="Forms/template.psd" Default="True"/>

The DisplayName attribute of the DocumentTemplate element specifies the text that is displayed in the drop-down list for selecting a document template type when creating a new document library. The Type attribute uniquely identifies the document type and can be any integer that is not already used for another document template. The Default attribute specifies whether the template is selected by default in the drop-down list. The Name attribute of the DocumentTemplateFile element specifies the physical path to the template file on the server computer, while the TargetName attribute specifies the address of the template relative to the document library.

Reset Microsoft Internet Information Services (IIS) for changes to take effect.

Adding a mapping definition for a file type

To map a file extension to a document type, and to identify the control to use when opening a document that has the file extension, add a Mapping element to DOCICON.XML. DOCICON.XML resides in the Local_Drive:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\60\TEMPLATE\XML directory.

Adding the following line within the ByExtension element in DOCICON.XML maps the .psd extension to an image file named icpsd.gif, which provides the icon that is displayed in document libraries for files of this type:

<Mapping Key="psd" Value="icpsd.gif"/>

To enable editing within an application, the Mapping element must also include EditText and OpenControl attributes, as follows:

<Mapping Key="psd" Value="icpsd.gif" EditText="Application" OpenControl="ProgID"/>

The EditText attribute specifies the application name that is displayed on the drop-down menu when a user clicks the Edit arrow for a document. The OpenControl attribute specifies the ProgID of the control to use for opening files of the specified type.

The image file that is specified by the Value attribute must reside in the Local_Drive:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\60\TEMPLATE\IMAGES directory. If the specified image file is missing from this directory, a “missing image” icon appears beside the document.

To prevent users from being prompted for credentials to see the icon when Anonymous Access is enabled, you must set inheritable permissions on the image file by performing the following steps:

  1. Right-click the referenced image file in the IMAGES folder, and then click Properties.
  2. On the Security tab in the Properties dialog box, click Advanced.
  3. On the Permissions tab in the Advanced Security Settings dialog box, ensure that the check box is selected for Allow inheritable permissions from the parent to propagate to this object and all child objects. Include these with entries specifically defined here.

Note  The default size for icons in Windows SharePoint Services is 16 x 16 pixels.

Reset IIS for changes to take effect.

Adding an editing application

Create a DLL providing the control to load for a document of the specified type whose ProgID identifies the control, for example, SharePoint.OpenDocuments. The control that you create must provide the same methods for creating, opening, and viewing documents as described for the OpenDocuments control.

To customize the logos used on the home pages of SharePoint Web sites, do the following:

  1. Open the Local_Drive\Program Files\Common Files\Microsoft Shared\Web Server Extensions\60\TEMPLATE\IMAGES directory.
  2. Copy the images that you want to appear on the home pages of your Web sites to this directory.
  3. Remove the image files HOME.GIF and HOMEPAGE.GIF, which contain the logos used on the left and right sides of the home page, respectively.
  4. Rename the new image files HOME.GIF and HOMEPAGE.GIF.

All sites now display new logos on their home pages.

Warning  The image files that you add may be overwritten when you install updates or service packs for Windows SharePoint Services, or when you upgrade an installation to the next product version.

You can add new themes or customize existing ones for application to Web sites in Microsoft Windows SharePoint Services 2.0. This programming task shows how to customize an existing theme.

  1. Copy one of the theme folders in Local_Drive:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\60\TEMPLATE\THEMES and give the folder a unique name. In this example, the name is MyTheme. This folder contains cascading style sheets (CSS) files, image files, and other files that define the styles, formatting, and color for the various user interface (UI) elements that are used in the theme.
  2. Find the .inf file in the copied folder, and rename it with the name given to the folder.
  3. Open the .inf file and assign the same name to the title in the [info] section of the file.
  4. Customize the styles defined in the .css files of the copied folder as needed. See CSS Class Definitions in Windows SharePoint Services for information about the classes used in Windows SharePoint Services, including sample code that can be added to ASPX pages to learn which classes apply to which UI elements. The following example from THEME.CSS changes the color that is used for sections of the navigation area.
    border-bottom:1px solid #8D4D03;
    .ms-nav .ms-navwatermark{
  5. Modify the image files in the copied folder by using the business graphics software of your choice.
  6. Add thumbnail and preview image files for your custom theme to the Local_Drive\Program Files\Common Files\Microsoft Shared\Web Server Extensions\60\TEMPLATE\IMAGES directory. In this example, the files are called myThumbnail.png and myPreview.gif.
  7. Add a theme template definition to SPTHEMES.XML, which is the file that determines which themes are available as options on the Apply Theme to Web site page. This XML file is located in the Local_Drive:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\60\TEMPLATE\LAYOUTS\1033 directory. The following example specifies a template for the custom theme.
       <DisplayName>My Theme</DisplayName>

Your custom theme now appears in the list of options on the Apply Theme to Web site page and can be applied to SharePoint sites.

Warning  Changes that you make to SPTHEMES.XML may be overwritten when you install updates or service packs for Windows SharePoint Services, or when you upgrade an installation to the next product version.

Classes and Object used…

·         SPWebApplicationBuilder: Creates an SPWebApplication object, providing default settings for all the required values and allowing the caller to change only those properties that need values different from the default

·         SPFarm: Represents a Windows SharePoint Services farm. To access the current server farm object, you can use members on SPFarm.Local.

·         SPWebApplication: Represents an Internet Information Services (IIS) load-balanced Web application that is installed on the server farm.

·         SPSiteCollection : Represents a collection of SPSite objects, or site collections.

·         SPSite : Represents a collection of sites on a virtual server, including a top-level site and all its subsites. Each SPSite object, or site collection, is represented within an SPSiteCollection object that consists of the collection of all site collections.

·         System.Security.SecureString: Represents text that should be kept confidential. The text is encrypted for privacy when being used, and deleted from computer memory when no longer needed. A SecureString object is similar to a String object in that it has a text value. However, the value of a SecureString object is automatically encrypted, can be modified until your application marks it as read-only, and can be deleted from computer memory by either your application or the .NET Framework garbage collector.


Let’s start…


Creating web Application at Port no 2007 ( Assuming user spuser with password Password is present in system administrator group)

SPWebApplicationBuilder webAppBuilder = new SPWebApplicationBuilder(SPFarm.Local);

SPWebApplication newApplication;
int myPort = 2007;

webAppBuilder.Port = myPort;

webAppBuilder.ApplicationPoolId = “site-appol”; // application pool

webAppBuilder.ApplicationPoolUsername = webAppBuilder.DefaultZoneUri.Host + \\spuser;

System.Security.SecureString password = new System.Security.SecureString();               

string strName = “Password”;               

char[] pass = strName.ToCharArray();               

foreach (char c in pass)               


webAppBuilder.ApplicationPoolPassword = password;

webAppBuilder.CreateNewDatabase = true; // Create new database           

webAppBuilder.DatabaseName = “wss_site2007_content”;    // database name           

webAppBuilder.DatabaseServer = webAppBuilder.DefaultZoneUri.Host;  //Host name/computer name          

webAppBuilder.UseNTLMExclusively = true;  // Use NTLM authentication

newApplication = webAppBuilder.Create(); // Create new web application
newApplication.Provision();           //Provision it into web farm    


Creating site Collection at root level with Blank site template

SPSite mySiteCollection = newApplication.Sites.Add(“/”,                       //Root

“Cgosite”,              // site title

 “”,             //description

1033,                         //language

“STS#1”,                //Blank site template  

webAppBuilder.ApplicationPoolUsername, // Site owner

“Name”,                 // Name

“”); //Email


Creating web



Activating publishing feature at site collection



Close Site Collection

Here is a piece of code that I know you will find useful one day. Basically, you supply it with an existing site definition, say “STS#1”, and this will then create a site for you, based on the supplied site definition, at the URL you asked for.

Here goes –

public static bool CreateSite(
    string parentSiteURL, string siteURLRequested, 
    string siteTitle, string siteTemplateName)
    bool returnCondition = false; // Assume failure.

    const Int32 LOCALE_ID_ENGLISH = 1033;

    using (SPSite siteCollection = new SPSite(parentSiteURL))
        SPWeb parentWeb = siteCollection.OpenWeb();
        SPWebTemplateCollection Templates = 
        SPWebTemplate siteTemplate = Templates[siteTemplateName];
        if (parentWeb.Webs[siteURLRequested].Exists)

            false, false);

        // All is good? 
        returnCondition = true;

    return returnCondition;