How do you get SharePoint My Links after deleting and restoring a profile?

We are running SharePoint 2007 Service Pack 1 (SP1), and profiles are imported from Active Directory (full import is performed daily). We had a problem where many users were inadvertently disconnected from Active Directory, and this led to the removal of their profiles from SharePoint. We re-enabled their Active Directory accounts and performed a full import, which restored their SharePoint profiles. However, all of their My Links are missing. Is there a way or best practice to restore them?

+3
source share
3 answers

I posted this because I could not find the answer to my problem anywhere. This Joel Oleson post , which describes a similar problem with mine, gave me a hint about where to look for the missing data. And This post from Corey Roth showed me how to programmatically add links to My Links users.

First of all, you need to restore a backup of the database containing My Links data. You do not want to restore your working database, you want to restore it in another place. Links stored in the SSP database. (You can find out the name of the database by going to Central Administration → Shared Services Administrator, then open the menu for the Shared Services Provider and click "Edit Properties" - the SSP database is listed on the properties page.)

:

  • , ,
  • URL-

:

SELECT UPF.NTName, UL.Url, UL.Title
FROM UserLinks UL INNER JOIN UserProfile_full UPF ON UL.recordID = UPF.recordID
INNER JOIN UserPrivacyPolicy UPP ON UL.PolicyId = UPP.id
ORDER BY NTName

( , , , , , , UserPrivacyPolicy)

Excel CSV ( ) - , , . Title Last, Title , , . ( , - , .)

. :

:

  • Microsoft.Office.Server(C:\Program Files\Common Files\Microsoft Shared\ -\12\ISAPI\Microsoft.Office.Server.dll)
  • Microsoft.SharePoint(C:\Program Files\Common Files\Microsoft Shared\ -\12\ISAPI\Microsoft.SharePoint.dll)
  • System.Data​​li >
  • System.Web
  • System.Xml

:

using System;
using System.IO;
using System.Collections.Generic;
using System.Text;
using Microsoft.Office.Server;
using Microsoft.Office.Server.UserProfiles;
using Microsoft.SharePoint;
using Microsoft.SharePoint.Administration;
using System.Web;

namespace UserLinks
{
    class Program
    {
        static void Main(string[] args)
        {
            string _accountName = "", _linkTitle = "", _url = "", _tmp = "", _path = "", _SPSsite = "";

            // Check arguments
            if (args.Length != 2)
            {
                ShowUsage();
                return;
            }

            _path = args[0];
            _SPSsite = args[1];

            using (SPSite _site = new SPSite(_SPSsite))
            {
                ServerContext _context = ServerContext.GetContext(_site);
                UserProfileManager _userProfileManger = new UserProfileManager(_context);

                /* Expecting a comma seperated list with 3 columns:  
                 * AccountName in the format Domain\Account name - I am assuming there are no commas in this field
                 * URL - I am assuming there are no commas in this field
                 * Link Title - link title is last because there may be commas in the title
                */
                TextReader _reader = new StreamReader(_path, System.Text.Encoding.Default);
                while (_reader.Peek() != -1)
                {
                    _tmp = _reader.ReadLine();
                    _accountName = _tmp.Substring(0, _tmp.IndexOf(','));
                    _tmp = _tmp.Replace(_accountName + ",", "");
                    _url = _tmp.Substring(0, _tmp.IndexOf(','));
                    _linkTitle = _tmp.Replace(_url + ",", "");

                    try
                    {
                        UserProfile _currentUser = _userProfileManger.GetUserProfile(_accountName);
                        QuickLinkManager _quickLinkManager = _currentUser.QuickLinks;
                        _quickLinkManager.Create(_linkTitle, _url, QuickLinkGroupType.General, null, Privacy.Private);  //I am assuming that all links have no group assigned to them and they are all private links
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine(_accountName);
                        Console.WriteLine(ex);
                    }

                }
                _reader.Close();

            }
        }

        private static void ShowUsage()
        {
            Console.WriteLine("Usage");
            Console.WriteLine("UserLinks [FilePath] [SharePoint URL]");
        }

    }
}

, " " .

+6

When you import a profile, you usually run the risk of losing your existing setup / updated information.

0
source

Source: https://habr.com/ru/post/1719047/


All Articles