vrijdag 28 maart 2008

iterating through user profiles

Today i was busy on migrating some userprofiles and for some reason i had to iterate through the existing userprofiles in the MOSS 2007 environment.

I got a nice, lovely errormessage saying that I wasn't allowed to enumerate through all userprofiles, because i didnt have the rights to "Manage user profiles".

Dave Hunter's Blog (http://www.davehunter.co.uk/Blog/default.aspx) provided me the solution:

iterate through a set number!

woensdag 19 maart 2008

Feature stapling - custom code OnSiteCreation

I wanted to enable some features upon a siteCollection creation, but i couldnt find an eventhandler which I could use to run some code in to activate those features. I found out that sharepoint is missing a OnSiteCreation event :(. After some search on the web, I found out some possibilities:

1) alter the SiteTemplates
This was no option for me: too much work for a lazy person like me
2) feature stapling
This was a technique I never heard of: A new, farm wide feature is created, with a
reference to a stapling.xml. That file is filled with:
* elements
* FeatureSiteTemplateAssociation Id: the feature that needs to be installed
* TemplateName

This way, features can be activated to some siteDefinitions (for example STS#1, BLANKINTERNET#0) or to the GLOBAL definition!

When making a custom feature with a OnFeatureActivated method, and that feature is deployed to GLOBAL, code can be executed ON SITE CREATION!

NOTE: the STS#1 (blank page) has a setting "AllowGlobalFeatureAssociations" set to false. This way, the STS#1 sitedefinition needs to be added to, when you want to execute custom code to be executed when any site is created.

Migration - QuickLaunch

It has been a long time ago since i made my last post, but that's because of my current project, there's a lot of pressure on it at the moment.

At the moment i am busy on migrating a SP2003 environment to a SP2007. Due to the customers wishes, this is a very time consuming project. I decided to write a nice tool to help me migrate all the webparts, it's data and the navigation, since we used Tzunami for the content migration. It helped me in some way, but i can say: it isnt worth it's money. 12000 Euro for a product that has a lot of bugs and misses a lot of functionality.

well, let me go further on the main subject ;) I was asked if it was possible to maintain all links in the quicklaunch and in the same order. At first, it didnt look too good for me: The object model of sharepoint 2003 didnt allow me to gather information about the quicklaunch menu.

So I decided to write a query to get the navigation information out of the database and stored into an xml file:




In SP2003, the order of Documents, PictureLibrary, Lists are in an order that is always the samen (when nog changed). In SP2007, the order depends on the order of creating doclibs and lists.

For example, when a list is created first and after that, a doclib is created, the menu "List" will be displayed above "Document Library" (or whatever its name is ;))

This problem is tackled with the following code:
- make all lists and doclibs invisible in the quicklaunchmenu:




afther that,

use this function to add items:



use the following function to add the items to the quicklaunch: they are added to the right subMenu


And use this function to put the subMenu items in the right order: