Monday, January 05, 2015

Where are My Links in SharePoint 2007

Following a hardware migration, I was able to get the My Site and personal sites working but as stated here (http://msmvps.com/blogs/shane/archive/2007/11/21/finding-my-links-in-the-database.aspx), the My Links are actually part of the SSP (or User Profile Service), thus not easily retrievable.
As mentionned in the above article, editing the SharePoint databases is not supported. However, I had to find a way to get my users' links back in there.
      1. So I copied the [NewSSP].dbo.QuickLinksAdd stored procedure to a personal "toolbox" database on the server.
      2. I modified this "local" storedproc to fetch the user's RecordId and force the policy number to a fixed value.So basically, the start of the stored proc goes like this:
        ALTER PROCEDURE [dbo].[QuickLinksAdd]
        --@RecordId bigint,
        @NTName nvarchar(400),
        @PageURL nvarchar(1250),
        @Title nvarchar(500),
        @ContentClass nvarchar(200) = null,
        @Group nvarchar(400) = '',
        @GroupType int = 2,
        @ItemSecurity int = 1,
        @PolicyId uniqueidentifier = '861D8FB6-7012-4CD9-A7A0-A615AED038B3',   --may be relative to our implementation
        @ColleagueRecordId bigint = null,
        @LinkUserIdIsWorkgroup bit = null,
        @LinkMemberGroupId bigint = null
        
        AS
        SET NOCOUNT ON
        DECLARE @RecordId bigint, 
        @ProfileObjectType int,
        @LinkId bigint
        
        -- Constants (used for events)
        DECLARE @ProfileChangeType_Add int
        SET @ProfileChangeType_Add = 1
        
        -- CHECK FOR CURRENT USER
        SELECT @RecordId = [RecordID] FROM [NewSSP].[dbo].[UserProfile_Full] WHERE NTName = @NTName
        IF (@@ERROR <> 0 )
          RETURN -1
        ...
        Followed by the rest of the stored proc, adding the database name where other stored procs are called.
      3. After testing one, I ran a loop on the data from the original SSP database.