Had a recent issue after migrating our users from one domain to another.  Their MyLinks did not come over after running stsadm migrateuser.  Found the links in the database and wrote a quick winforms app to move them over.  Permissions need to be allowed in Central Admin, Shared Services,  personalization services as well as site col admin on SSP.

Here’s how to populate them:

  1. Extract the MyLinks information from the database
  2. Create a Winforms App
  3. Add a web reference to the webservice
  4. Concatenate the extracted data into a comma separated list in excel
  5. Run the app

1.  In SQL, join the UserLinks table in the SSP database with the UserProfile_Full table to get a list of links:

SELECT     UP.NTName, UP.PreferredName, UP.Email, UL.Id, UL.RecordId, UL.Title, UL.GroupType, UL.GroupTitle, UL.Url, UL.ContentClass, UL.PolicyId, UL.ItemSecurity
FROM         UserLinks AS UL INNER JOIN
                      UserProfile_Full AS UP ON UL.RecordId = UP.RecordID

domainjsmith  Home  http://site/Pages/Default.aspx General 
domainjsmith  Yahoo  http://yahoo.com  General  16 
domainjsmith  Sharepoint Site  http://site/IT/default.aspx General 

The numbers are the security ID, public, private, etc.

2. Create a basic Winforms app

3. Add a web reference to http://site/_vti_bin/userprofileservice.asmx

In Visual Studio 2008, References, Add Service Reference, Advanced, Add Web Reference

4,5.  Code and load.

using System;

using System.Collections.Generic;

using System.ComponentModel;

using System.Data;

using System.Drawing;

using System.Linq;

using System.Text;

using System.Windows.Forms;

namespace MyLinksLoader

{


public
partial
class
frmMyLinksLoader : Form

{


public frmMyLinksLoader()

{

InitializeComponent();

}


private
void btnSubmit_Click(object sender, EventArgs e)

{

LoadMyLinks();

}


private
void LoadMyLinks()

{


//loop through text box


foreach (string line in txtSource.Lines)

{


//make sure line is valid


if (line.ToString().IndexOf(“http”) < 0)

{


continue;

}//


//split commas


string

[] arrValues;


char[] charDelim = { ‘,’ };

arrValues = line.ToString().Split(charDelim);

txtResults.Text += arrValues[0] + “,” +

arrValues[1] + “,” +

arrValues[2] + “,” +

arrValues[3] + “,” +

arrValues[4] +

System.Environment.NewLine;

txtResults.Text += txtSource.Lines.Count();


//AddLink


//AddLinkAccountName, Title, URL, Group, Privacy Level)


//Privacy is Public=1, Contacts, Organization, Manager, Private=16, or Not Set.

wsName.UserProfileService userProfile = new wsName.UserProfileService();

userProfile.Credentials = System.Net.CredentialCache.DefaultCredentials;

wsName.Privacy privacy = wsName.Privacy.Public;


if (arrValues[4] == “16”)

{

privacy = MyLinksLoader.wsName.Privacy.Private;

}//

userProfile.AddLink(arrValues[0],

arrValues[1],

arrValues[2],

arrValues[3],

privacy);

txtResults.Text += “Links Added”;

}//

}//

}

}