Mike's SharePoint Blog
"Everyone wants to be like Mike" - Wil Smith (Bad Boys)

I noticed a new “feature” that has been implemented with Service Pack 2 when performing stsadm backups. When performing a stsadm backup from the command line I now receive the following message before the backup starts:

Setting the site collection to be read-only for the duration of the backup. If the operation is interrupted, make sure to check the site lock for this site collection. For more information see stsadm.exe -help getsitelock and stsadm.exe -help setsitelock.
The setsitelock stsadm operation is described in TechNet article “Back up and restore site collections by using built-in tools (Windows SharePoint Services 3.0)”.

This operation has been available since the release of SharePoint 2007 but I had no knowledge of this operation until I installed Service Pack two and ran my first stsadm backup manually from the command line and received the message above. After performing some research I found the following information in the TechNet article “Setsitelock: Stsadm operation (Windows SharePoint Services)”, which states the following information:

“A common situation where the getsitelock and setsitelock operations are useful is when a site is backed up. Typically, before you back up a site collection, the site should be locked and no users should have access to it.”(TechNet)

Important:
In Service Pack 2 for SharePoint Products and Technologies, site collections are automatically locked as read-only before a backup process occurs. Therefore, there is no need to use the
Setsitelock: Stsadm operation (Windows SharePoint Services) operation. If you do not want site collections to be locked as read-only, you must specify the nositelock parameter of the Backup: Stsadm operation (Windows SharePoint Services) operation that is available in Windows SharePoint Services 3.0 with Service Pack 2 (SP2).

Apparently the best practice for backing up sites before service pack 2 was to set the site lock to read only and then remove the site lock after the backup using stsadm. Now with service pack 2 this is done automatically for SharePoint administrators. One thing I have noticed when the stsadm backup fails the site lock will not be released and must be removed manually using the commands from the TechNet article “Setsitelock: Stsadm operation (Windows SharePoint Services)”.

 

The Collaboration Portal template included as a part of SharePoint 2007 is a template that I use most often because of the features that it provides. It is a central location for master pages and CSS styles that are used throughout the sub-site of the main portal. One problem I have found with this is that when a team site is created under a collaboration portal the master page is not applied. When I go to "Site Settings -> Look and Feel -> Master Page" after a team site is created I see the following error messages:



This is because the Publishing Feature is not activated on a team site by default. I can do one of two things to correct this issue. One choice the master page I wish to apply to the site and second is to go to "Site Settings -> Site Administration -> Site Features" and enable the Office SharePoint Server Publishing feature.



Either of these choices may not be an option if your organization has governance policies that dictate what master pages are applied to a team site when it is created. This is also a problem for site owners that may not know how to delve through the SharePoint Site Settings to find how to change the master page for their site, also if you are creating many sub-sites this could be an administrative burden. Trying to find newly created team sites and then applying the proper master page throughout each site in the site collection.

In my search for an answer to this problem I found that there are many people who have either created a new team site definition or a SharePoint feature to fix this problem. Although a new site definition is a possible solution I do not need any new list or libraries with the team site when it created so I decided to go with a SharePoint feature to enable the Office SharePoint Server Publishing Feature when a team site is created.

There is a little known feature (at least to me until lately) called the "Publishing Stapling" feature. What this feature does is it enables the Publishing feature on a select set of SharePoint site templates. Here are a few of the templates that are included in this feature: SPSPORTAL#0 – Collaboration Portal, CMSPUBLISHING#0 – Publishing Site. If you want to see all the templates included in this feature go to the following directory: "C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\TEMPLATE\FEATURES\PublishingStapling" and look in the publishingStapling.xml file. Naturally these are sites that would have publishing enabled but what about the sites that are created under these publishing portal templates? After researching this subject I found that many people have created custom solutions that enable either the publishing feature or the automatic application of a master page upon site creation but I was looking for a solution that would not require code to be deployed to the SharePoint Server. I looked for and answer on Microsoft's MSDN and TechNet sites but only found the following:



Retrieved from: http://support.microsoft.com/kb/936908

What is feature stapling?


A basic explanation of feature stapling is that it is used to attach one or more features to a SharePoint site definition without modifying an existing site definition or creating a new site definition. Fro a more detailed explanation I recommend reading Chris Jonson's blog on "Feature Stapling in WSS V3".


After reading this TechNet article I decided to create a simple stapling feature based off the Publishing Stapling feature that would be applied the SharePoint Publishing feature whenever a team site is created in the SharePoint Farm. This way when site owners create a new team site publishing will be enabled and the site will inherit the master page from the site above it. If the site owner wants to change the look and feel of the site they can either choose the default.master page or turn off the Publishing feature but the site will maintain the same look and feel of the main portal site throughout the site collection by default. So now how did I do this?

The easy way would have been to add the STS#0 – Team Site into the existing Publishing Stapling feature but this file could be changed whenever an update or patch is applied, also it usually not a good idea to modify files in the 12 hive that are installed during the SharePoint installation. So I created a copy of the existing Publishing Stapling feature and then made modifications to the copied files. Here is a step by step explanation of what I did.

  1. Copy the "PublishingStapling" folder in the following location: "C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\TEMPLATE\FEATURES"
  2. Renamed the "Copy of PublishingStapling" folder to "MyPublishingStapling"
  3. Renamed the file in the "PublishingStapling" folder from "PublishingStapling.xml" to "My PublishingStapling.xml"
  4. Opened the "feature.xml" file in the "PublishingStapling" and made the following changes:

Here is the original: "feature.xml" file:

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

<Feature Id="001F4BD7-746D-403b-AA09-A6CC43DE7942"

Title="Publishing Features Stapling"

Description="Staple Publishing features"

Version="12.0.0.0"

Scope="Site"

Hidden="TRUE"

xmlns="http://schemas.microsoft.com/sharepoint/">


<ElementManifests>

<ElementManifest Location="publishingstapling.xml"/>

</ElementManifests>


</Feature>


Here is the file after my modifications:

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

<Feature Id="001F4BD7-746D-403b-AA09-A6CC43DE7943"

Title="My Publishing Features Stapling"

Description="My Staple Publishing features"

Version="12.0.0.0"

Scope="Farm"

Hidden="TRUE"

xmlns="http://schemas.microsoft.com/sharepoint/">


<ElementManifests>

<ElementManifest Location="Mypublishingstapling.xml"/>

</ElementManifests>


</Feature>


As you can see only minor modification were made and I changed the Feature Id so it would not conflict with the existing Publishing Stapling feature and install properly. Also note that this feature is scoped to the entire farm, this feature could be scoped to the web application or site collection level depending on the requirements for your SharePoint Farm.


  1. Then I opened the "MyPublishingStapling.xml" file.


Here is the original "MyPublishingStapling.xml" file.


<Elements xmlns="http://schemas.microsoft.com/sharepoint/">


<FeatureSiteTemplateAssociation Id="F6924D36-2FA8-4f0b-B16D-06B7250180FA" TemplateName="SPSPORTAL#0" />

<FeatureSiteTemplateAssociation Id="F6924D36-2FA8-4f0b-B16D-06B7250180FA" TemplateName="SPS#0" />

<FeatureSiteTemplateAssociation Id="F6924D36-2FA8-4f0b-B16D-06B7250180FA" TemplateName="SPSREPORTCENTER#0" />

<FeatureSiteTemplateAssociation Id="F6924D36-2FA8-4f0b-B16D-06B7250180FA" TemplateName="SPSTOC#0" />

<FeatureSiteTemplateAssociation Id="F6924D36-2FA8-4f0b-B16D-06B7250180FA" TemplateName="SPSTOPIC#0" />

<FeatureSiteTemplateAssociation Id="F6924D36-2FA8-4f0b-B16D-06B7250180FA" TemplateName="SPSNEWS#0" />

<FeatureSiteTemplateAssociation Id="F6924D36-2FA8-4f0b-B16D-06B7250180FA" TemplateName="SPSNHOME#0" />

<FeatureSiteTemplateAssociation Id="F6924D36-2FA8-4f0b-B16D-06B7250180FA" TemplateName="SPSSITES#0" />

<FeatureSiteTemplateAssociation Id="F6924D36-2FA8-4f0b-B16D-06B7250180FA" TemplateName="SRCHCEN#0" />


<FeatureSiteTemplateAssociation Id="F6924D36-2FA8-4f0b-B16D-06B7250180FA" TemplateName="CMSPUBLISHING#0" />

<FeatureSiteTemplateAssociation Id="F6924D36-2FA8-4f0b-B16D-06B7250180FA" TemplateName="BLANKINTERNET#0" />

<FeatureSiteTemplateAssociation Id="F6924D36-2FA8-4f0b-B16D-06B7250180FA" TemplateName="BLANKINTERNET#1" />

<FeatureSiteTemplateAssociation Id="F6924D36-2FA8-4f0b-B16D-06B7250180FA" TemplateName="BLANKINTERNET#2" />


<FeatureSiteTemplateAssociation Id="94C94CA6-B32F-4da9-A9E3-1F3D343D7ECB" TemplateName="SPSPORTAL#0" />

<FeatureSiteTemplateAssociation Id="94C94CA6-B32F-4da9-A9E3-1F3D343D7ECB" TemplateName="SPS#0" />

<FeatureSiteTemplateAssociation Id="94C94CA6-B32F-4da9-A9E3-1F3D343D7ECB" TemplateName="SPSREPORTCENTER#0" />

<FeatureSiteTemplateAssociation Id="94C94CA6-B32F-4da9-A9E3-1F3D343D7ECB" TemplateName="SPSTOC#0" />

<FeatureSiteTemplateAssociation Id="94C94CA6-B32F-4da9-A9E3-1F3D343D7ECB" TemplateName="SPSTOPIC#0" />

<FeatureSiteTemplateAssociation Id="94C94CA6-B32F-4da9-A9E3-1F3D343D7ECB" TemplateName="SPSNEWS#0" />

<FeatureSiteTemplateAssociation Id="94C94CA6-B32F-4da9-A9E3-1F3D343D7ECB" TemplateName="SPSNHOME#0" />

<FeatureSiteTemplateAssociation Id="94C94CA6-B32F-4da9-A9E3-1F3D343D7ECB" TemplateName="SPSSITES#0" />

<FeatureSiteTemplateAssociation Id="94C94CA6-B32F-4da9-A9E3-1F3D343D7ECB" TemplateName="SRCHCEN#0" />


<FeatureSiteTemplateAssociation Id="94C94CA6-B32F-4da9-A9E3-1F3D343D7ECB" TemplateName="CMSPUBLISHING#0" />

<FeatureSiteTemplateAssociation Id="94C94CA6-B32F-4da9-A9E3-1F3D343D7ECB" TemplateName="BLANKINTERNET#0" />

<FeatureSiteTemplateAssociation Id="94C94CA6-B32F-4da9-A9E3-1F3D343D7ECB" TemplateName="BLANKINTERNET#1" />

<FeatureSiteTemplateAssociation Id="94C94CA6-B32F-4da9-A9E3-1F3D343D7ECB" TemplateName="BLANKINTERNET#2" />


</Elements>


Here is the file after I removed the default entries and added the Team Site definition:


<Elements xmlns="http://schemas.microsoft.com/sharepoint/">


<FeatureSiteTemplateAssociation Id="94C94CA6-B32F-4da9-A9E3-1F3D343D7ECB" TemplateName="STS#0" />


</Elements>


As you can see you could add other site definitions to this file so when any site is created the publishing feature is enable but we decided to only enable publishing on Team Sites since they are the most widely used. Although through feature stapling you could enable custom workflows to be enabled whenever a Meeting Workspace is created using this example.

Once the files have been modified all that is left to do is to install the feature using stsadm.exe.

Here are the commands I used to install the feature:

Stsadm.exe –o installfeature –filename MyPublishingStapling\Feature.xml

Once this command is completed the feature is installed. On the environments where I have installed this feature I did not have to activate it after installing the feature. I ran the activate feature command just to be safe.

Stsadm.exe –o – activatefeature –filename MyPublishingStapling\Feature.xml

Once this command completes it will state that the feature has already been activated to the farm. If you are installing and activating this feature to a web application or site collection the stsamd.exe command will be different. Please review Microsoft's site foe the stsadm.exe index of commands here: http://technet.microsoft.com/en-us/library/cc263384.aspx

The last operation to perform is a reset of IIS for the feature to be used on any new Team Sites that are created.

NOTE:

There may be other ways to do what I have shown in the post but most that I have found require some programming which may not be optimal in some environments. If you find a better way or even another way of doing this please send me an email and let me know.




 

The mobile web view is not enabled on a MOSS Collaboration Portal site by default. On WSS sites this feature is enabled by default.
To enable this feature on a MOSS collaboration portal you must use the stsadm tool. You can use the following command to active the mobile web feature:

stsadm -o activatefeature -name MobilityRedirect -URL http://yourportalsiteurl/

Then you can access the mobile SharePoint site directly by going to http://YourPortalURL/m

 

In my research in how to structure the building a current development SharePoint Portal I ran accross the following material from Microsoft and though I would share this URL
Managing sites and site colections.

 

Great C# Book for Beginners

Posted In: , , . By Michael

I found that this book was extremely helpful in learning the key basics of the C# language. I am a novice programmer and trying to learn C# in order to become a developer and eventually take the MCPD (Microsoft Certified Professional Developer) exam. I am currently in college and have taken a class on C but this book with the examples provided the basics I need to continue forward. The author only shows examples of console application but from a beginner’s standpoint I think this is a great place to start. The language throughout the book was easy to understand and having examples to support what the author was trying to teach was helpful. The book has tutorials, examples, and drills that helped me to better understand what I was studying.

I would recommend this book to anyone that has some basic programming skills and wants to learn about the C# language.

 

Our company received a call on a late Friday afternoon from a customer who’s Internet facing SharePoint Portal was not working. The problem was when they went to the main portal page is would display the error of “Cannot connect to Configuration Database…”.
Apparently support deemed this a SharePoint problem and decided to reinstall SharePoint to see if they could create a new configuration database. After support was able to create a new configuration database they lost the connection after some time and then decided that it was a SQL problem and passed the support ticked to SQL support. Friday night I received a phone call from the customer saying that support did not currently have the resources to help with the problem. Support said they would get back to the customer as soon as resources became available. As you can imagine that this is not the response that a customer wants to hear when their internet SharePoint Portal is down.
So I and a coworker began working with the customer Saturday morning to see what the error and troubleshoot the problem to get the customer’s internet SharePoint Portal back up and running as soon as possible.
We had some minor issues to work with before we even began to work on the portal. The first issue was all three people were at home working remotely in the DC area on servers that were located in Florida. We had to find a way that all three of us could work together on the problem. The first idea would be to create a Microsoft Live Meeting but none of had accounts to create a Live Meeting (after this I do now have a company Live Meeting account). A coworker did a demo of Shared View (http://www.connect.microsoft.com/content/content.aspx?SiteID=94&ContentID=6415) a couple of months ago and since it was free and easy to use we decided to use Shared View to work together. The second issue, we needed a way that all three of us could be on the phone together to talk through the issues with the portal. Well none of us had three way calling so we did some quick research and found FreeConfernce.com (https://www.freeconference.com/Home.aspx) which allows people to use a conference call for free. The third issue was my coworker and I needed a way to talk to each other privately to confer on ideas and solutions prior to presenting them to the client that was on the phone. So for this we used MSN messenger to instant message ideas between each other while working on the problem.
Now about a half an hour later we are now all three working through Shared View as the customer walks through the issues that they are having and the way the SharePoint was originally configured and what support had done to try and solve the issues.
The first issue that was found was an improperly configure DNS server. The customer had three server one running active directory and DNS, another running SharePoint 2007, and the last running SQL 2005.The Active Directory server had an additional domain configured that was causing problems with DNS to the other two servers. This was removed and the NetBIOS was enabled all three servers in the SharePoint farm. Now we were able to perform nslookups to each server and resolve IP addresses. We opened Internet Explorer and were able to connect but SharePoint had been reinstalled so we needed to get the original configuration database and content back to its original state.
Fortunately support disconnected from the original configuration database prior to reinstalling SharePoint but they also for reason only known to them decided to delete the Central Administration site. In this state the option we saw was to uninstall SharePoint and reinstall SharePoint, and then connect back to the original configuration database. Once this was completed the customer’s internet SharePoint Portal was back up and running. There were also a few issues with the original configuration of the SharePoint server farm that we had to address but the portal was back up after 8 hours.
The point of this story is that just because you a SharePoint problem does not mean that SharePoint is always to blame. If support had looked at DNS first the problems could have solved in a matter of a couple of hours instead it took eight.

 

First open the WSS site where you want to use the data view web part.
Create a new page. Using “Create from Master Page…”



Select the Master Page you would like to use as the template for the
new web part page that you are going to create for you data view web part.



A new page will be created with the same look and feel of the current WSS site.



The next step is to create a place where you can add web part zones so you can add a data view web part. You do this by going to the “PlaceHolderMain” an select “Create Custom Content” from the “Common Content Tasks” as shown below.



Now you will be able to click inside the “PlaceHolderMain” box and
add a new web part zone from the “Insert” menu as shown below.



Now the page should look like the image below after adding the web part zone.



Now that you have a place to put the data view web part it is time to connect to the data source from the data source library.


On the right hand side of SharePoint Designer you see the toolbox by default. Select the “Data Source Library” tab.



Now click on “Connect to a database”, and then on “Configure Database Connection”.



You can connect to the data many different ways including Single Sign-on but for this example I am using a custom connection string.

An example of the connection string that I used is:

Data Source=MOSS;Initial Catalog=AdventureWorks;User Id=SQLAccountName;Password=SQLAccountPassword;Provider=sqloledb

and then click on “Next.” Then the next srceen you see you can select a table from the Adventure Works database to use in your data view or select a stored procedure. I used a stored procedure because I could not get a custom query to work. More information on how to create a stored procedure can be found on the Microsoft TechNet Site.



The next srceen you see you can then choose the stored procedure you would like to use to query the data.



In this instance I am using the stored procedure called “getContantName” (yes I know I miss spelled it) that uses a simple SQL select statement to get the first and last names of people in the Contacts table. I then click on “Ok:” If all goes well I see the following srceen and not an error message.



Click “Ok” again and now you will see the data source under “Database Connections.”



Now you should be able to left click on the database connection and click on “Show Data.” The data will show under the “Data Source Details” tab and then you can add the data to the web part zone you created.



That’s it. You have now added data from a SQL data source to your WSS site.


*One note to mention is while I was getting screenshots for this blob post I found the I would still get an error while trying to view the data. I closed and reopened SharePoint Designer but still had the error but when I cleared my web cache and reopened SharePoint Designer everything worked fine. I hope that help someone from having all the headaches I did when trying to figure out how to connect to SQL 2005 from SharePoint Designer.