确定指定用户可以通过编程方式访问的 SharePoint 站点和 Web?
我需要确定指定用户可以通过 SharePoint API 在 SharePoint Web 应用程序中访问的网站和 Web。请注意,指定的用户与调用代码的当前用户不同。我最初考虑使用 PortalSiteMapProvider,但它没有提供更改构建它的用户上下文的选项。任何人都可以提供任何替代方案吗?
谢谢,魔法安迪
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您可以使用 Webservices API:
确定使用 Web 服务 API 的 SharePoint 网站/工作区中的用户角色
You could use the Webservices API:
Determining User's role in a SharePoint site/workspace using the webservices API
这不是解决此问题的最有效的解决方案,但您可以迭代 Web 应用程序中的所有网站集/网站,然后调用:
其中“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:
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.
一种可能的方法是利用模拟来确定特定用户(当前用户除外)可以通过 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/