如何获取 SharePoint“我的链接”在删除并恢复配置文件后返回?

发布于 2024-08-05 22:46:49 字数 240 浏览 2 评论 0原文

我们正在运行 SharePoint 2007 SP1,并且配置文件是从 Active Directory 导入的(每天运行一次完整导入)。我们遇到了一个问题,许多用户在 Active Directory 中被无意禁用,这导致他们的配置文件从 SharePoint 中删除。我们重新启用了他们的 Active Directory 帐户并运行了完整导入,以恢复他们的 SharePoint 配置文件。但是,他们的所有“我的链接”都丢失了。有没有恢复它们的方法或最佳实践?

We're running SharePoint 2007 SP1 and profiles are imported from Active Directory (a full import runs daily). We had a problem where many of the users were disabled unintentionally in Active Directory and this caused their profiles to be removed from SharePoint. We re-enabled their Active Directory accounts and ran a full import which restored their SharePoint profiles. However, all of their My Links are missing. Is there a method or best practice for restoring them?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

じее 2024-08-12 22:46:49

我发布此内容是因为我在任何地方都找不到问题的答案。 Joel Oleson 的这篇文章 描述了与我类似的问题给了我一个关于去哪里寻找丢失数据的提示。和 Corey Roth 的这篇文章向我展示了如何以编程方式将链接添加到用户的“我的链接”。

首先,您需要恢复包含“我的链接”数据的数据库备份。您不想恢复工作数据库,而是想将其恢复到另一个位置。存储在 SSP 数据库中的链接。 (您可以通过进入 Central Admin --> Shared Services Admin 找到数据库的名称,然后打开 SSP 的菜单并单击“编辑属性”- SSP 数据库列在属性页面上。)

数据库完成后已恢复 您想要检索链接信息:

  • 拥有该链接的用户的域帐户名称、
  • 链接的 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 和 Excel 中将其保存为 .csv 文件(逗号分隔列表) - 只是因为我的生产服务器无法访问我恢复数据库的位置。我最后订购了带有标题的列,因为标题可能包含逗号,这会扰乱我读取数据的方式。 (我检查过,其他两个字段不包含逗号 - 您应该在做出此假设之前检查您的字段。)

然后我编写了一个小控制台应用程序来导入数据。它需要两个参数:

  • 包含所有链接的文件所在的路径(即 c:\temp\links.csv)
  • “我的链接”中的 SSP 的 url 已丢失(即 https://portal.mydomain.com)

这些是使用的引用:

  • Microsoft.Office.Server (C:\Program Files\Common Files\ Microsoft Shared\Web Server Extensions\12\ISAPI\Microsoft.Office.Server.dll)
  • Microsoft.SharePoint (C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\12\ISAPI\Microsoft.SharePoint.dll)
  • 系统
  • System.Data
  • 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]");
        }

    }
}

所以问题解决了&作为一个附带好处,该程序可用于强制链接显示在用户的“我的链接”列表中。

I posted this because I couldn't find an answer to my problem anywhere. This post by Joel Oleson that describes a similar problem to mine gave me a hint as to where to go looking for the missing data. And This post by Corey Roth showed me how to programatically add the links to a users My Links.

First things first - you need to restore a backup of the database that contains the My Links data. You don't want to restore over your working database, you want to restore it to another location. The links stored in the SSP Database. (You can find out the name of the database by going into Central Admin --> Shared Services Admin then open the menu for the SSP and click on Edit Properties - the SSP Database is listed on the properties page.)

Once the database has been restored you want to retrieve the Link information:

  • the domain account name of the user who owns the link,
  • the url of the link
  • the name of the link

This query will get you that information:

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

(I should note that I did not take into account what group or what privacy level the links were set to, you could probably find that information by looking at the information in the UserPrivacyPolicy table)

I copied the results into Excel & saved it as a .csv file (comma separated list) - just because my production server did not have access to the location where I restored my database. I ordered the columns with Title last because the Title could contain commas and that would mess up how I'm reading in the data. (I checked and the other two fields do not contain commas - you should check yours before making this assumption.)

I then wrote a little console app to import the data. It takes two arguments:

  • the path where the file containing all of the links is located (ie c:\temp\links.csv)
  • the url of the SSP from with the My Links have gone missing (ie https://portal.mydomain.com)

These are the references used:

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

And this is the code:

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]");
        }

    }
}

So problem solved & as a side benefit, this program can be used to force links to show up in a user's My Links list.

最偏执的依靠 2024-08-12 22:46:49

这篇文章提供了一些关于 MyLinks 及其与 SSP 数据库的关系的非常好的信息(这实际上是这些链接违反直觉地存储的地方。)希望您可以让 DBA 验证这些链接是否仍然存在;并且它们与正确的配置文件相关联。

http://www.k2distillery.com/ 2009/01/moving-sharepoint-my-links- Between-ssps.html

This post has some pretty good information about MyLinks and its relationship with the SSP database (that's actually where these links are stored counterintuitively.) Hopefully you can have your DBA validate that these links still exist; and that they're associated with the correct profiles.

http://www.k2distillery.com/2009/01/moving-sharepoint-my-links-between-ssps.html

萌面超妹 2024-08-12 22:46:49

当您进行配置文件导入时,通常会面临丢失现有自定义/更新信息的风险。

When you do a profile import, you normally risk losing the existing customization/updated information.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文