确定指定用户可以通过编程方式访问的 SharePoint 站点和 Web?

发布于 2024-08-07 17:44:02 字数 174 浏览 2 评论 0 原文

我需要确定指定用户可以通过 SharePoint API 在 SharePoint Web 应用程序中访问的网站和 Web。请注意,指定的用户与调用代码的当前用户不同。我最初考虑使用 PortalSiteMapProvider,但它没有提供更改构建它的用户上下文的选项。任何人都可以提供任何替代方案吗?

谢谢,魔法安迪

I need to determine the sites and webs that a specified user can access in a SharePoint web application via the SharePoint API. Note the specified user is different from the current user that is calling the code. I initially was thinking of making use of the PortalSiteMapProvider, but it does not offer an option to change the user context in which it is built up. Can anyone offer any alternatives to this?

Thanks, MagicAndi

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

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

发布评论

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

评论(3

百变从容 2024-08-14 17:44:02

这不是解决此问题的最有效的解决方案,但您可以迭代 Web 应用程序中的所有网站集/网站,然后调用:

web.DoesUserHavePermissions(userID, SPBasePermissions.Open)

其中“web”是 SPWeb 对象,userID 是您的用户的“DOMAIN\user.name”正在检查访问权限。在 RWEP 中执行此操作,并确保正确处置 SPSite/SPWeb 对象。

Not the most efficient solution to this problem, but you can iterate through all the site collections / webs in the web application and then call:

web.DoesUserHavePermissions(userID, SPBasePermissions.Open)

where "web" is a SPWeb object and userID is "DOMAIN\user.name" of the user you are checking access permissions for. Do it within a RWEP and make sure you dispose of your SPSite/SPWeb objects correctly.

云仙小弟 2024-08-14 17:44:02

一种可能的方法是利用模拟来确定特定用户(当前用户除外)可以通过 PortalSiteMapProvider 访问的站点和 Web。此处描述了在 SharePoint 上下文中模拟其他用户的方法:

http://blackninjasoftware.com/2009/04/09/how-to-programmatically-impersonate-users-in-sharepoint/

One possible approach is to make use of impersonation to determine the sites and webs that a specific user (other than the current user) can access via the PortalSiteMapProvider. A method for impersonating another user in a SharePoint context is described here:

http://blackninjasoftware.com/2009/04/09/how-to-programmatically-impersonate-users-in-sharepoint/

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