Monday 31 December 2007

OWSTimer Hogging Max Processor Time in VMWare

This issue isn't exclusive to VMWare, but is much easier to come across. You may notice your MOSS server being completely unresponsive for serveral minutes at a time. On investigation you find that OWSTimer is taking up 80%-100% processor utilisation. I have particularly found this occuring on VMWare MOSS installations, and often occurs straight after you restart a VM that has been off for a significant amount of time.

The issue here is clock time synch. If the SQL Server/SharePoint server do not agree then OWSTimer gets itself in a right tizz and maxes the processor. In a VM environment this might look particularly weird - as your VM Host may be reporting plenty of resources available.

To resolve this (in WMWare)


To resolve this do the following:
  • Stop and disable the OWSTimer and Windows SharePoint Services Tracing services
  • Install VMWare Tools if not already installed on the SQL and SP boxes
  • Right click on the VMWare System Tray icon and tick the "Time Synchronisation between the virtual machine and the console operating system
  • Ensure your VM host synchronises time from your internal time synch service (ie in synch with the AD controller)
  • Verify that all servers are time synched
  • restart OWSTimer and Tracing services

Why does this happen so much in VMWare?

Well, VMWare has issues when the CPU goes into powersaving modes, meaning that the clocks don't correctly calculate time (eg the VM image thinks it is running at 2.4Ghz, but is actually at 1GHz), therefore gets out of synch easily. The same effect seems to occur when you power up a VM image that has been left for months.

Tuesday 6 November 2007

Search Server 2008 Express RC

Today Microsoft released a bombshell: Search Server 2008 Express

In summary:
  • It's free
  • Standalone product
  • All the features of MOSS search
  • Limited to one query server – so not scalable for the very large enterprise look at the other variations if you're after this

This is going to really change the game for the low end users.

It's in RC now, so I'd think the end of Q1 will be the target launch. I'll post something in the next day or so relating my experiences with it

Friday 28 September 2007

MOSS - Targeting content to Sites not Audiences

Audience targeting is a great way to push information to individual users from a central source - but what about when you want to push information to particular sites? My example is a series of department sites. Sounds easy - content query web part (CQWP) filtered on a choice column on your list of announcements/documents/links etc to say which department the item is relevant to. Job done? well until you need to say that this item is for multiple departments...

Try changing the choice from dropdown to "checkbox/multiple". The text that appears in a list view is great "choice1;choice2;choice3" etc. Great! lets filter using "contains" in the CQWP. Not really - while you see the value in the interface as a string, th CQWP won't when filtering - so you end up with no results? The answer? Content Types and Workflow. For the rest of this article I'm working with a document library with a "Relevant Department" column

Create a new Content Type

(mine is at the top portal level for reuse). I called mine "My Choices Content Type", inherited it from "Document" and added it to "Test Content Types" to keep it seperate. I added 2 new site columns

  • MyChoices - a checkbox based choice column

  • MyChoices_Text - a single line text column

Go to your document library/annoucements list/ etc and change it to allow content types, add your new content type and remove any others from the list. Don't upload any documents or create any items yet.

Create a Workflow in SharePoint Designer

Open up the site containing your document library in SP Designer. From the file menu select New > Workflow, configure yours similar to mine below:






This workflow will copy the (non-text) multiple choices into a text column, thus exposing it as text to the CQWP.

Ammend CQWP to Filter based on our content type

Now that we have this property create a CQWP on your "department" site. Configure it as below to point at our list, our content type and then filter it based on the Site Column "RelevantDepartment_Text" and use the filter operator "Contains". Enter a string matching one of your choice values. OK these choices.



Congratulations, you should now have a list of documents that can be relevant to more than one department, pushed through to the site of your choosing.

Wednesday 13 June 2007

MOSS 2007 - The Great Hard Disk Consumer

Recently I've been performing a bit of a review on som MOSS servers that are a little "under-specified" on the hard disk front. While you probably shouldn't have anything with as little as 10GB as your only drive on a SharePoint server, it has got me looking at some of the places that SharePoint just eats needless space if you let it.

The Databases

Watch out for the SharePoint_Config database particularly - the log file can grow and grow in "default" SQL configurations. A sensible maintenance plan, or at the very least setting databases to backup in "simple" mode will dramatically reduce the size of the logs you are working with (GB down to about 20MB). You should understand the impact of changing your backup modes before you make any changes though. You have been warned™


IIS Logs from Searching

IIS will by default be generating loads of log file data - particularly when the content crawling is happening. You probably want to keep IIS logs for "normal" use, but not for content crawling. If you create yourself an alternative access mapping you can index all your content of one web application url (eg internal.enterprise.com), and turn off logging in IIS, while users access the other one (eg live.enterprise.com) , with logging switched on.


Diagnostic Logging

SharePoint puts its diagnostic logs in:

C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\LOGS

and by default logs very verbosely. You can change these settings to only log the more "interesting" severities through Central Admin > Operations > Diagnostic Logging

WSS_AdminService.log

You will find a log file called WSS_AdminService.log held in

C:\Documents and Settings\Default User\Local Settings\Temp

The file is being written to almost constantly and becomes very large (900Mb by the time I found it).Worse still, because it's in the

C:\Documents and Settings\Default User

folder it gets duplicated when a new user logs onto the server console. Deleting it resolves the situation temporarily (i didn't notice any errors), but it will appear again and start growing.I'm not sure how to "solve" this one, as it seems completely unknown to the internet aprt from this one link (no solution).

http://www.tek-tips.com/viewthread.cfm?qid=1363719&page=6

If and when I find the answer to this and other similar capacity issues I'll ammend this entry. For the meantime, careful monitoring and deletion should keep things right.

Friday 8 June 2007

Configuring MySites under your main portal

If, like the rest of the work, you'd prefer people to access their MOSS 2007 Mysites as

https://portal.enterprise.com/personal/username

rather than

https://mysites.enterprise.com

(which requires a different url, possibly new certificates, and probably mass confusion), then you can do no better than look to this blog entry from Chris Johnson.

http://blogs.msdn.com/cjohnson/archive/2006/09/15/754902.aspx

Thursday 24 May 2007

Site Collection Administrators and Adding Workflows to Sites with Broken Inheritance

Another gotcha in the SharePoint world. You would think that Site Collection Administrators could do anything on any site inside the collection. Being an administrator and all. Not so. If you've broken inheritance you will find that you no longer have the correct options in SharePoint Designer to add a new workflow. For the meantime I have solved this by explicitly adding the "Site Collection Administrator" account into the "SiteName Owners" group - which was created when we broke inheritance. Not exactly the functionality I was expecting.

Saturday 19 May 2007

Fear and Surprise and Permissions in MOSS Central Admin

Access denied when selecting "User profiles and properties"? Can't access your shared services provider? Can't get to the "Import Application Definition" page of the BDC?

No one expects the MOSS administration, and certainly - if you are looking at the Central Administration tool for the first time, you would certainly be forgiven for suffering from fear and surprise, the 2 weapons of the Administration.

Yes 2 are their weapons; fear, surprise and permissions...oh, no wait, that's 3. Anyway.....

As an external consultant, assisting with someone elses MOSS install, you can't always fall back on knowing the domain admin password, or being privvy to the setup accounts and passwords used for setting up the search, app pools etc. But you may need, like I do, to have access to administer everything about Central Admin after the initial setup, using a normal user account created for you by the IT team. I generally make sure this is all sorted out before I leave site the first time, along with any remote connection details required.

Giving this user account access sounds easy. The "original" administrator needs to go to Central Admin -> Operations -> Update Farm Administrator's Group, and simply add the user in. Easy! well....you'd think. Launch Central Admin with this new account and yes, you'll get in, but you'll quickly find you have no access to mysites, shared services providers or to any other site collections. However - you now have all the boot strapping you require.

First make sure you are a site collection administrator for mysites, the SSP, and any site collections you are interested in using the following procedure:
  • Go to Application Management -> SharePoint Site Management -> Site Collection Administrators
  • Select "change site collection" and select the correct web application using the over complex interface
  • Add yourself as the secondary site collection administrator
Great - I'm a site admin of the SSP - now I can do everything I need? Sadly not...

You may have got yourself into the SSP, but you'll find that you can't access several expected key features, notable being:
  • User Profiles and Properties
  • Import Application Definition
To do this, you'll have to assign yourself the permissions using the links:
Personalization services permisions
Business Data Catalog Permissions

Nothing complex here - just a step that I bet you wont be expecting already being as "admin" as you can get

Wednesday 25 April 2007

"fun" adding Webparts to SharePoint 2003

We're doing a bit of "retro" SP 2003 work for a client, and having written several webparts for 2003 I thought 1 more couldn't cause a problem. ha! how wrong could I be. We'll I created my webpart (see http://msdn2.microsoft.com/en-us/library/ms948909.aspx if you want a starting guide), and checked that everything was all named correctly. Then I tried to deploy the webpart (see http://www.codeproject.com/useritems/BasicWebPartPartII.asp) for another good guide.

When I couldn't get my web part to appear I checked the event log to find

"Failed to locate the assembly in the SafeControl assembly paths".

Trying to import the .dwp file directly from a team site (Modify Shared Page-> Add Web Parts -> Import) gave the similar error:

"A Web Part or Web Form Control on this Web Part Page cannot be displayed or imported because it is not registered on this site as safe."

After more checking and rechecking of the .dwp file and the section of the web config I checked the virtual server. It's an older IIS 6 box, and as such was still creating sites configured for .NET 1.1 by default. Aha - I'd built my assembly with .NET 2.0. No problem, change the Virtual server over to .NET 2? Well, not quite. SharePoint is "well secure (aye)" and won't run if you do that. You need to make the further step of running stsadm to upgrade the server configuration:

stsadm -o upgrade -forceupgrade -url http://URLOftheVirtualServer

You can find full information about the problem in KB Article 894903. I really hope this saves someone the headache in these circumstances - most of the newgroup posts/replies tend generally to ignore the users actual problems, or reply with "i've fixed it" without saying what the fix was.

Tuesday 13 February 2007

Access 2007 is useful! Stop Press!!!

Access has generally been the whipping boy of database products, mostly scorned by "real database developers" due to the fact that it allows users to think they can create databases. However, for the first time, I think I have seen a glimpse of something truely useful for Access 2007.

Where else might Access be useful but in MOSS 2007! Tired of your old views? bored with datasheets? Management requesting graphed reporting information from a list you wish you'd stored in SQL? "Access View" to the rescue! New in 2007 (along with Gant views - another favourite) you can produce any Access report - and better, link it directly to the list of views available from the SharePoint list.

1 - Create your view






Simply select "Access View" and it will launch Access 2007, with your list information already marked as a linked table. For this example I selected the "Pivot Table" option - surely the best demonstration of why you'd want an Access view. A quick bit of playing and I was done.

2 - Publish the result to SharePoint.

As simple as selecting the "Publish to SharePoint" option. Save the file in a document library (best make a hidden one for the purpose of access views). Make sure that when the dialog appears you say yes to adding this view to the drop down list of views available in the list.

3 - Select your view





Woohoo! Look - there is my new view. Sadly it loads Access 2007, rather than say, displaying the pivot chart directly in a web page, but I guess it is still a big step.

4 - Enjoy the results





And here is my completed pivot chart - 10mins from start to finish, no development, no reporting services, and Management can play to their hearts content.

Wednesday 24 January 2007

Word 2007 Content Placeholders and the Word 2003 plugin for Office 2007

It's to Microsofts credit that they have provided a plugin for Word 2003 that will allow the reading of a Word 2007 .docx file. And it (mostly) works. If however you need to use some of the new features office 2007 - such as the content placeholders you'll find that the content inside them won't render. I'm hoping they'll fix this soon.

If you haven't checked out content placeholders you can file many articles on it, but here is a reasonable overview on content placeholders in Office 2007. It's a great new feature, but as usual not without it's limitations, such as handling repeating sub groups, and the definate need of a configuration editor that others outside the Office team have had to write.

Forms Authentication in MOSS 2007 / WSS 3.0 - Not all that...

One of the great heralded features of the latest SharePoint release has been the integration of forms authentication Membership/role providers from ASP.NET 2.0, essentially allowing seamless integration of any list of users from any datasource to Authenticate to SharePoint/MOSS - the default one being through aspnetdb. I don't want to cover that, as it's been more than detailed elsewhere. I just thought I'd reveal a few of the important gotchas that you'll experience after getting it working.

  • You cannot create lists from excel spreadsheets, or make any use of a DataSheet mode for lists
  • You cannot (easily) publish an InfoPath form to a form library. (Our workaround was a second web application set to basic auth)
  • Give up hope of seeing any SharePoint plugins in Office documents
  • You won't get a "Edit in Word" style option for office documents of the context menus
  • As with all forms authentication you won't be able to download files directly using code means like WebClient() in C#
  • RSS Readers won't be able to get past forms authentication to subscribe
  • I'm sure there are other features similar that won't work

I think all this is a bit of a shame, as all the user creation user controls etc are provided for you, and it's quicker than Account Creation Mode for WSS 3.0, and works in MOSS 2007. It may still be the solution for you in a non-active directory world, but be very sure that the features that you are losing can afford to be lost

Friday 12 January 2007

Errors Switching to Edit Site Mode in CMS 2002

Apologies for using images to display code snippets. Blogger is not quite there yet, and strangely it conplains when you add a script tag in your blog post ;)

Up until now whenever a colleague or client tells me that they can't switch to "edit site mode" in CMS 2002 I've always immediately answered it with - "you've forgotten to and the CMS sub directory to your web application. And until now I've been 100% right. Today I found a new possibility. So, to recap here are both known solutions to the "switch to edit site mode" error, normally aparrent if the URL looks like the following

http://mysite/page.htm#

it's the trailing # that idicates the problem

Solution 1 - No id attribute on your form

CMS 2002 generates javascript (which I always process out of public view pages - why add 15K unusuable inaccessible overhead to every public view of a page) to handle the switching of its menu mode, one of which usually looks like this:



You'll find it just under the viewstate tag. If you somehow don't have an id attribute on your form however ie:



instead of the expected



Then you'll find that the CMS javascript generated is


..and this will give you an javascript error in the console when you try to switch mode. Incidentally if you use master pages you will find that the javascript generated is different. Having talked through the newsgroups to those that know (ie Stefan Gossner) - it appears that this may be a slightly undocumented "feature" of CMS2002 for VS2005. Worth paying attention to if you like to clean up unecessary scripts like I do.

Solution 2 - Missing CMS virtual directory in IIS

This is by far the most common, and often happens if you deploy your web app manually, mostly AFTER enabling a site for CMS in the SCA

Both your web application and the MCMS application underneath your website should contain a virtual directory called CMS. If you do not and you experience the problem mentioned you can take the steps below. I say only if, because IIS 5 has a habit of hiding the virtual directory in the IIS MMC plugin. To be certain, use IIS metabase Edit to see the real story.

To add the directory:

  1. In IIS, underneath your web application, create a new virtual directory called CMS
  2. point it at c:\program files\microsoft content management server\server\IIS_CMS
  3. ensure that only read access is ticked. Do not tick run scripts
  4. complete the wizard
  5. go back into the properties of the virtual directory and change the execute permissions to scripts only

refreshing your web page should not allow you to switch between site modes. It's a strange quirk, but enabling the run scripts option during the wizard itself always leads to failure (certainly on IIS 5). I have no idea why, but it to some finding out. Fortunately this is the default selection in IIS 6, so you are less likely to accidently set it.

Thursday 11 January 2007

A Simple Enforced Source Control for SQL using Team Foundation

One of the major issues in rolling product development is ensuring that you can reproduce a client version of software at the office. With a mature source control system such as Team Foundation this is not too much of an issue with code - at worst you go back through the changesets until you find the one that matches. But what about the database that this code relies on? How best to ensure that you have the same ER structure as the version of code? There are many methods, most of which are very hard to enforce (though I hope that the "Database" version of Visual Studio Team may sort this out).

Enter Team Foundation Policies. If you've not looked at this cool feature you should. TF ships with many cool policies - including; "must associate check in with work items", "must pass the following code tests" (using the testing features of VS Developer), "must pass a list of best practice polices", and the invaluable "must build before checkin".

That's not the extent of the power of policies. You can write your own - effectively you can do any action you want on checkin. If made use of this to force a copy of the entire database script to be placed on disk as check in occurs. All it takes is a little bit of .net code, a registry entry or two and use of a handy scripting tool.

More information on the creation of policies can be found at http://blogs.vertigosoftware.com/teamsystem/archive/2006/02/27/2302.aspx

Step 1 - Scripting the database

There is a handy tool shipped with SQL 2000, which sadly absent in SQL 2005 called "scptxfr.exe". It lies in the MSSQL\Upgrade folder under the normal program files root. This tool can quite easily script an entire database, a feature that seems harder to find in SQL 2005. I'm sure you can probably achieve the same affect with SMO, but fortunately the scptxfr tool works across both versions. Using the command like:

scptxfr /s DatabaseServer /d DatabaseName /P SAPassword /f file:////tfs-01/TFSSQLSynchRoot/$TeamProject$/$ChangeSet$.sql

will fire the whole thing out to disk, saved for posterity. You'll notice that my file path includes $ signs. That isn't actually a valid file path, but markers that I replace in the code shown below.

Step 2 - Write your own policy

Create a new library dll , and include
Microsoft.TeamFoundation.Client and Microsoft.TeamFoundation.VersionControl.Client
as references to the project

create a new class, inheriting from Microsoft.TeamFoundation.VersionControl.Client.PolicyBase

Most of the methods feedback information used to describe in the visual studio GUI the name and purpose of the policy, the error messages to be returned etc. The crux of the class is the Evaluate() method. My code works by launching another exe, by making use of System.Diagnostics.Process

public override PolicyFailure[] Evaluate()
{
int iLastChangeSet = PendingCheckin.PendingChanges.Workspace.VersionControlServer.GetLatestChangesetId();
System.Diagnostics.Process process1 = new System.Diagnostics.Process();
process1.EnableRaisingEvents = false;
process1.StartInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden;
process1.StartInfo.FileName = "CMD.exe";

StreamReader oReader = null;
try
{
oReader = new StreamReader(File.Open(@"C:\Program Files\TFS Extended Policies\sqlsynchconfiguration.txt", FileMode.Open));
string sTeamProject = this.PendingCheckin.PendingChanges.AffectedTeamProjectPaths[0].Replace("$/", "");
string sConfig = oReader.ReadLine().Replace("$ChangeSet$", (iLastChangeSet + 1).ToString()).Replace("$TeamProject$",sTeamProject);

MessageBox.Show("Synchronising SQL DB changes using:" + Environment.NewLine + sConfig + "" + Environment.NewLine + "last change set: " + iLastChangeSet + Environment.NewLine + sTeamProject);
oReader.Close();
process1.StartInfo.Arguments = sConfig;
process1.Start();
//process1.WaitForExit();
//process1.Close();
}
catch(Exception err)
{
MessageBox.Show("SQL Synchronisation failed. Check that the configured scripting command exists, and that you have permission to access to the file shares." + Environment.NewLine + err.Message);
}

if (false)
{
return new PolicyFailure[]
{
new PolicyFailure("Please provide sql details", this),
};
}
else
{
return new PolicyFailure[0];
}
}

Note that you could wait for the scptfxr exe to complete by uncommenting

//process1.WaitForExit();
//process1.Close();


but as this operation could delay the checkin by a reasonable amount of time I elected not to. Build your assembly and all your coding is done!

To get this all working on all users machines I found that I needed the new assembly, scptfxr.exe and several of its required dlls in the same folder. The bute force approach...but if you include all the files below it should work with least hassle




Step 3 - Add your policy to a Team Foundation Projct

In order to add your policy to the available list each machine that runs the policy will need to add registry settings

Windows Registry Editor Version 5.00[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\VisualStudio\8.0\TeamFoundation\SourceControl\Checkin Policies]"SQLDatabaseSynchPolicy"="c:\\test\\SqlSynchPolicy.dll"

Then, in team explorer, go to
My Project -> Source Control -> Check-in Policy

and add the new policy from the available list. Note that the name of the policy will depend on the Type property you completed in your class.

Your policy is now among those enforced!