ConfigLabs

November 16, 2009

Step by step process for changing master page automatically using STSADM command line tool

Recently, my colleague (Ankul Mathur) and me (much of the work done by him!) created a custom solution to change the SharePoint master page automatically on day to day basis.

Requirement: Change the master page based on the day of the week. Example; Monday should have Yellow master page and similarly each day will have its own master page. In a nutshell, the client wants a different looking very day. I know this is usability failure but can’t help!The requirement seems bit weird as we could have done this using CSS alone, but the master page components differ from one master page to the other.  

Ok enough of bantering, lets dive deep into process;

Step 1: Download Gary Lapointe’s Custom Stsadm Command Line tool WSP file for MOSS or WSS from http://stsadm.blogspot.com/2009/02/downloads.html .

Step 2: Follow the steps giving in the article to install and activate the wsp service on the server using Stsadm command line tool.

Step 3: On the server under bin folder in 12 hive run the Stsadm command for setmasterpage to check the Stsadm for setmasterpage is working correctly.

Step 4: Create a Project in VS 2005/2008 named it CustomSTSADM and added a reference for commandlineprocess after download a file from http://www.codeguru.com/csharp/csharp/cs_misc/userinterface/article.php/c8503 . Here is the code;

Project.cs

   1: using System;

   2: using System.Collections.Generic;

   3: using System.Linq;

   4: using System.Text;

   5: using twComps;

   6: 

   7: namespace CustomSTSADM

   8: {

   9:     class Program

  10:     {

  11:         static void Main(string[] args)

  12:         {

  13:             DateTime dt = DateTime.Now;

  14:             string masterPage = string.Empty;

  15: 

  16:             switch (dt.DayOfWeek.ToString().ToLower())

  17:             {

  18:                 case "monday":

  19:                     masterPage = System.Configuration.ConfigurationSettings.AppSettings["masterPageMon"];

  20:                     break;

  21:                 case "tuesday":

  22:                     masterPage = System.Configuration.ConfigurationSettings.AppSettings["masterPageTue"];

  23:                     break;

  24:                 case "wednesday":

  25:                     masterPage = System.Configuration.ConfigurationSettings.AppSettings["masterPageWed"];

  26:                     break;

  27:                 case "thursday":

  28:                     masterPage = System.Configuration.ConfigurationSettings.AppSettings["masterPageThu"];

  29:                     break;

  30:                 default:

  31:                     masterPage = System.Configuration.ConfigurationSettings.AppSettings["masterPageDef"];

  32:                     break;

  33:             }

  34: 

  35:             string masterPageLink = System.Configuration.ConfigurationSettings.AppSettings["masterPageLink"];

  36: 

  37:             CommandLineProcess cmd = new CommandLineProcess();

  38:             cmd.Command = "stsadm";

  39:             cmd.Arguments = string.Format(" -o gl-setmasterpage -url \"{0}\" -sitemaster \"{1}{2}.master\" -systemmaster \"{3}{4}.master\"",

  40:                 System.Configuration.ConfigurationSettings.AppSettings["portalLink"],

  41:                 masterPageLink, masterPage, masterPageLink, masterPage);

  42: 

  43:             bool bSuccess = cmd.Start();

  44:         }

  45:     }

  46: }

App.Config

   1: <?xml version="1.0" encoding="utf-8" ?>

   2: <configuration>

   3:   <appSettings>

   4:     <add key="masterPageMon" value="blue" />

   5:     <add key="masterPageTue" value="green" />

   6:     <add key="masterPageWed" value="yellow" />

   7:     <add key="masterPageThu" value="grey" />

   8:     <add key="masterPageDef" value="pink" />

   9: 

  10:     <add key="masterPageLink" value="/_catalogs/masterpage/"/>

  11:     <add key="portalLink" value="http://server name" />

  12:

  13:   </appSettings>

  14: </configuration>

Step 5: Build the Project. This will create a folder with the project name inside that there will be a Bin folderàRelease folder à CustomSTSADm.exe, CommandLineProcess.dll, and CustomSTSADM.exe.config file.

Step 6: Copy all the above 3 files to bin folder under 12 hive on the server.

Step7: Run the .exe file on Windows Server 2003 and the master page is automatically set to the site set in the .exe.config file. And for Windows server 2008 right click on the .exe file and click on “Run as Administrator” it will set the new master page.

Step 8: Schedule the .exe file in Windows Scheduler to be run on daily/weekly/monthly basis.

On Windows 2008 Server;

Go to Start –> Programs –> Accessories –> System Tools –> Task Scheduler and set the following setting as shown in the images below:  

image

image

As always, if you happen to know a much better way to accomplish this, please feel free to share.

September 11, 2009

Resources from AUTechEd Talk: Designing for Enterprise Grade Document Management Systems using SharePoint

I attended this great talk on using SharePoint for designing a enterprise wide document management system at recent Microsoft Tech-Ed in Gold Coast, Australia. The Speaker (John Wise) shared huge number of resources with the audience. I think it you gone through this path of implementing DMS using SharePoint, then you might have known the path involved! The resources below should shed some light for us in implementing better SharePoint DMS solutions and/or maintain the existing ones.

More Information about Document Management:

TechNet: Plan document management

TechNet Presentation: Microsoft Office SharePoint Server 2007: Document Management

MSDN: Enterprise Document Management Overview

MSDN: Document Management Overview

Managing the Full Lifecycle of Documents:

ECM Team Blog: Walkthrough – Using the SharePoint Server 2007 Approval Workflow

TechNet Presentation: Designing, Deploying, and Managing Workflow in SharePoint Sites

TechNet: Understanding Workflow

MSDN: Workflow Information Center

MSDN: Workflows in Office SharePoint Server 2007

Increasing IT Manageability and Efficiency:

MSDN: Information Rights Management Overview

MSDN Blog: MOSS Architecture and Shared Services

TechNet: Plan Shared Services Providers

TechNet: Analyze document usage

MSDN: Item-Level Auditing with SharePoint Server 2007

Increased Adoption through Usability:

MSDN: Document Information Panel and Document Properties

Microsoft SharePoint Technologies Blog: Getting Started with Personalization in MOSS 2007 (Audience Targeting)

MSDN: User Profiles and Audience Targeting Overview

TechNet: Plan versioning, content approval, and check-outs

Integrating and Extending Your Document Management Capabilities:

MSDN: Document Information Panel

TechNet Presentation: Content Types and Metadata

Video: Extending the Document and Records Management Features of SharePoint Server 2007

MSDN Blog: InfoPath Forms in Office SharePoint Server 2007

MSDN: What Are Composite Applications?

Interoperability TechCenter

Customizing the Document Information Management Panel

Customizing the Document Information Panel – Presentation

Customizing the Document Information Panel – Script

Program Governance

Governance Resource Center for SharePoint Server 2007

Microsoft Whitepaper – Information Worker Competence Center

Microsoft Australia – Information Management home page

Microsoft Australia – Information Management home page

SharePoint out of the box answers many of the DMS requirements. But when it comes to compliance it take a step back. It is a good idea to checkout the partner solutions to enhance the SharePoint functionality in order to get compliant! The image below summarises different partner solutions for DMS requirements.

image

Links to partner sites

AvePoint

K2

Metalogix

OBS

Quest

SchemaLogic

SeeUnity

Unique World

Note: if you happen to know of any better third party solution for SharePoint DMS please feel free to share!

Building InfoPath forms in Office 2010

Filed under: InfoPath, Microsoft — Tags: — Jag @ 3:43 pm

Here is nice video on how to build forms in InfoPath 2010.

If you learned something new from this, why not checkout more info on InfoPath 2010 @ http://msdn.microsoft.com/en-us/office/aa905434.aspx 

Thank You

September 8, 2009

Easiest way to find SharePoint Site Collection ID

Filed under: SharePoint 2007, Tip — Tags: , — Jag @ 11:16 am

I found a couple articles/tips explaining you different ways to find out the site collection ID on your SharePoint farm.

Retrieving the Site Collection ID from SharePoint (WSS 3) Chris

A Very Fast Method to Get the Site Collection’s Web Structure

In my opinion the easiest way to find the site collection ID is through the Central Admin site. Follow the instructions below to get the site collection id.

You can find the Site Collection ID by opening the Central Administration, then opening the Application Management, and

then clicking Site Collection Administrators in the SharePoint Site Management section.

SiteCollectionID2[1]

There you choose the administrators for your site collection.

SiteCollectionID1[1]

The Site Collection ID shows up in the URL of the site collection selected. If you can’t find the ID change the web application and try again.

Tell me if this is the easiest way!

August 15, 2009

What is SharePoint?

Filed under: SharePoint 2007 — Jag @ 7:34 pm

Found this cool commoncarft video on ‘SharePoint in plain English’. SharePoint better explained as colloboration platform in the today’s corporate world.

July 3, 2009

Identity and Access Strategies for SharePoint

Filed under: SharePoint, TechNet — Tags: , — Jag @ 11:19 am

Microsoft is publishing series of articles on the Identity and Access Strategies for SharePoint.  Watch this space for new updates as the new articles are published on this topic. These articles are must read, if you are dealing with different membership providers.

Articles

Identity and Access Strategies for SharePoint Products and Technologies, Part 1: Membership and Provider Architecture

Explore the membership and role provider architecture and how it operates in SharePoint Server 2007 and Windows SharePoint Services 3.0.

Identity and Access Strategies for SharePoint Products and Technologies, Part 2: Membership and Role Provider Assignment

Explore how to configure the LDAP Providers in SharePoint Server 2007, how to automate provider assignment and provider registration, and how to configure Web Single Sign-On with Active Directory Federation Services.

Code Sample:

Sample: Identity and Access Strategies for SharePoint Server 2007

Learn how Windows SharePoint Services 3.0 and SharePoint Server 2007 use membership and role providers, and how to automatically configure providers into SharePoint Server so it can manage the configuration settings.

Thanks for shedding light on this!

TIP: Hide Site Actions Menu using SharePoint Designer.

Filed under: SharePoint 2007, SharePoint Designer, Tip — Tags: , , — Jag @ 10:52 am

Use the SharePoint:SPSecurityTrimmedControl WebControl to wrap the Site Actions menu in your master page.  The control allows you to hide the contents if the currently logged user doesn’t have the required permissions.

Older Posts »

Blog at WordPress.com.