Vanou’s Blog

Archive for the ‘SPS 2003 – SharePoint 2003’ Category

Few days ago I add to copy Alerts and QuickLinks from a UserProfile to another in SPS 2003. I managed to create the functions, it seems easy at first, but the one thing I forgot is that I was on .Net Framework 1.1 withVisual Studio 2003!! argh! intellisense sucks compare to VS2008 or 2005

Copy QuickLinks:

/// </summary>

/// copy QuickLinks to another userprofile

/// copy if not exist, update otherwise

/// </summary>

/// <param name=”userProfile”>UserProfile that will contain the links</param>

/// <param name=”links”>Links to copy</param>

public static void CopyQuickLinks(UserProfile userProfile,QuickLinkManager links)

{

foreach(QuickLink link in links)

{

QuickLink newLink = null;

newLink= userProfile.QuickLinks.Add(link.Title,link.URL,link.Group,link.Public);

newLink.ContentClass= link.ContentClass;

newLink.Commit();

}

}

Copy Alerts:

///<summary>

/// copy a list of a alert to another userprofile

/// copy if not exist, update otherwise

/// </summary>

/// <param name=”userProfile”>UserProfile that will contain the alerts</param>

/// <param name=”alerts”>alerts to create for user</param>

public static void CopyAlerts(UserProfile
userProfile,ArrayList alerts)

{

foreach(Microsoft.SharePoint.Portal.Alerts.Alert alert in
alerts)

{

Microsoft.SharePoint.Portal.Alerts.Alert newAlert = null;

if(userProfile.Alerts[alert.Name] == null)

{

newAlert=
userProfile.Alerts.CreateAlert();

newAlert.Type = alert.Type;

foreach(Microsoft.SharePoint.Portal.Alerts.DeliveryChannelSettings channelSettings in alert.DeliveryChannels)

{

newAlert.DeliveryChannels.Add(channelSettings);

}

}

else

{

newAlert =
userProfile.Alerts[alert.Name];

}

newAlert.Name = alert.Name;

newAlert.ObjectDisplayName =
alert.ObjectDisplayName;

newAlert.ObjectID = alert.ObjectID;

newAlert.ObjectUrl = alert.ObjectUrl;

newAlert.Query = alert.Query;

newAlert.ConditionText =
alert.ConditionText;

newAlert.QueryLocale =
alert.QueryLocale;

newAlert.Commit();

if(alert.Active)

newAlert.Activate();

else

newAlert.Deactivate();

}

}

Since System.Collections is pretty limited in .net 1.1 I used an ArrayList of Alerts, which contains the alerts of the user to copy from