Compartilhar via


Migrating MyLinks

So, I was recently asked how to migrate MyLinks from an SPS2003 SharePoint site. The hurdle is that that MyLinks are not easily available in the SPS 2003 API nor are they easy to migrate (provided you don't want to upgrade the shared services provider).

Well, I only need readonly access to the SPS2003 database (now decommissioned) and SharePoint admin rights (the MOSS admin account) to add new links to the MyLinks section for all users.

Querying the SPS2003 database
Connect to the *_PROF database and join on the QuickLinks and UserProfile table.

Select up.NTName, ql.Title, ql.Group, ql.PageUrl, ql.IsPublic
from quicklinks ql join userprofile up on ql.userid=up.userid
where ntname=@ntname
order by ntname, linkid

Creating the link
Create a UserProfileManager to get the UserProfile and retreive the QuickLinkManager.

ServerContext context = ServerContext.GetContext(siteCollection);
UserProfileManager profileManager = new UserProfileManager(context, true);
UserProfile userProfile = profileManager.GetUserProfile(accountName);
QuickLinkManager qlm = userProfile.QuickLinks;
QuickLinkGroupType groupType = groupName.Equals("General") ?
        QuickLinkGroupType.General : QuickLinkGroupType.UserSpecified;
Privacy privacy = isPublic ? Privacy.Public : Privacy.Private;
qlm.Create(title, url, groupType, groupName, privacy);

From the code above, it's just a distinct NTName query and a few loops away from migrating links for all users.

Comments