如何在 SharePoint 中存储特定于用户的数据

发布于 2024-08-31 06:10:48 字数 377 浏览 2 评论 0原文

我需要将一些特定于用户的数据存储在 SharePoint 中,并让用户通过自定义 Web 部件进行访问。假设有一个最喜欢的 URL 列表。存储这些信息最直接的方法是什么?

  • 一些我不知道的 SPUser 或类似的内置属性包。
  • SPList,通过用户列关联。
  • 自定义数据库表,通过 SPUser ID 关联。
  • 否则?

对我来说听起来像是 RTFM,但我可能向 google 提出了错误的问题。

[更新]

我们最终将此信息存储在固定位置的简单列表中,并使用“人员”字段进行过滤。也许确实是最简单的解决方案,但从技术上讲,我认为下面标记的答案更好。

I have some user-specific data that I need to store in SharePoint and make accessible to the user through custom webparts. Let's say a list of favorite URLs. What would be the most straightforward way to store this information?

  • Some builtin propertybag for SPUser or similar that I'm not aware of.
  • SPList, associated through User column.
  • Custom database table, associated through SPUser ID.
  • Otherwise?

Sounds like a RTFM to me, but I'm probably asking google the wrong questions.

[Update]

We eventually stored this information in a simple list, in a fixed location, with a Person field to filter on. Perhaps the simplest solution indeed, but technically I think the marked answer below is nicer.

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

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

发布评论

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

评论(4

不气馁 2024-09-07 06:10:48

如果您想让每个用户在整个网站集中重复使用它们,您可以将字段添加到用户信息列表中。您可以向 Web 部件解决方案添加功能接收器,该接收器可以创建此列,或者检查此列是否存在于用户信息列表中以确保该列存在。

用户信息列表是 SharePoint 用于存储用户信息的标准 SharePoint 列表。
要访问用户信息列表,您可以转到网站集的根网站并使用 SiteUserInfoList 属性,

例如

SPList userInformationlist = SPContext.Current.Site.RootWeb.SiteUserInfoList;
//Or 
SPWeb web = SPContext.Current.Site.RootWeb;
SPList userInformationlist = web.SiteUserInfoList;

要访问用户列表项,您可以使用用户 ID 从用户信息列表中获取列表项,

例如:

SPListItem currentUserItem = userInformationlist.GetItemById(web.CurrentUser.ID);

如果您使用 MOSS,则可以将此信息存储在用户配置文件中,并使其在网站集中可用,这不需要启用“我的网站”。您需要使用用户配置文件类来访问它。

If you want to make them reusable across the site collection for each user you can add Fields to the User Information List. You can add a feature receiver to your web parts solution that can create this column or check to see if this column exists in the User information list to be sure that the Column exists.

The User Information list is a Standard SharePoint list that SharePoint uses to store user information.
To access the User Information List you can go to the Root web of the Site Collection and use the SiteUserInfoList property

E.G.

SPList userInformationlist = SPContext.Current.Site.RootWeb.SiteUserInfoList;
//Or 
SPWeb web = SPContext.Current.Site.RootWeb;
SPList userInformationlist = web.SiteUserInfoList;

To access a users List Item you can use the Users Id to get the ListItem back from the User Information List

E.G.

SPListItem currentUserItem = userInformationlist.GetItemById(web.CurrentUser.ID);

If you are using MOSS you can store this information in the User Profiles and make it available across Site Collections this does not need My Sites to be enabled. You would need to use the User Profile classes to access this.

猫烠⑼条掵仅有一顆心 2024-09-07 06:10:48

我会寻找用户配置文件上的属性。您不想将信息存储在根网站上,因为它不是有关根网站的信息。
您的示例中包含最喜欢的网址,每个用户的个人资料上都有一个“快速链接”集合。为每个用户存储 URL 的理想位置。 :)

I would go for the properties on the user profiles. You do not want to store the information on the root web as it is not information regarding the root web.
Your example with the favorite urls, each user has a "quick links" collection on their profile. An ideal place for storing urls for each user. :)

假装不在乎 2024-09-07 06:10:48

构建一个读取/写入自定义数据库的 Web 部件,您将可以灵活地跨 SiteCollections、Web 应用程序甚至单独的场使用该 Web 部件。

这是在我工作的地方实施的,并且取得了巨大的成功。我们需要一种方法来为最终用户提供大量重要的常用链接选择。最终用户能够显示对其特定工作职能有用的链接,并拥有一个可放置在任何地方的 Web 部件来引用对他们来说重要的链接。您还可以让“管理员”访问自定义数据库并更新任何可能更改的 URL,而不会影响最终用户或导致链接损坏。

Build a webpart that reads/writes a custom database and you'll have the flexibility to use the webpart across SiteCollections, WebApps, or even seperate Farms.

This was implemented where I work and it has been a big success. We needed a way to provide our end users a large selection of important, commonly used links. End users have the ability to display the links that are useful for their particular job function and have a webpart that can be put anywhere to reference those links that are important to them. You also have the ability for an “admin” to go to the custom database and update any URL’s that might change without the end user ever being impacted or ending up with a broken link.

爱你不解释 2024-09-07 06:10:48

这是一个很好的问题。

虽然我没有完美的答案,但您可以考虑以下一些事项:

  • 如果可行,请将数据存储在浏览器 cookie 中。

  • 存储在属性中网站集的 rootweb 中,由用户的登录 ID 键入。您可能希望在读取/写入属性时提升权限,以防用户有权访问子网站,但不能访问根网站。

This is a very good question.

Although I have no perfect answer, here are some things you can consider:

  • Store data in a browser cookie if this is feasible.

  • Store in the Site collection's rootweb in the Properties, keyed by the user's login ID. You may want to elevate when reading / writing the properties just in case the user has access to a subweb, but not the rootweb.

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