如何从 SharePoint 网站集中清除特定用户/组?
我正在尝试编写一个实用程序来从 SharePoint 网站集中查找/删除特定用户和组。此时,我正在使用 SPWeb
类的 SiteUsers
属性来完成这项工作,但我想知道:为什么 SPWeb
类中没有类似的属性代码>SPSite类?这对我来说似乎完全违反直觉(尽管此时 SharePoint 已经不再让我感到惊讶了)。
有更好的方法来做我想做的事情吗?
I am trying to write a utility to find/delete specific users and groups from a SharePoint site collection. At this point I'm using the SiteUsers
property of the SPWeb
class to do the job, but I'm wondering: why isn't there a similar property in the SPSite
class? This seems completely counter-intuitive to me (though at this point nothing about SharePoint surprises me anymore).
Is there a better way to do what I'm trying to do?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
不幸的是,我无法真正回答为什么会这样......:) SharePoint 的事实是您必须调用 SPSite.OpenWeb() 或SPSite.RootWeb,然后使用 SPWeb 获取 SiteUsers。我认为您使用对象模型的方式很好。
如果您改用 SharePoint 的 Web 服务,可以使用以下两种方法: 从站点中删除用户 和删除组。
Unfortunately, I can't really answer WHY it ended up that way... :) it is a fact of SharePoint that you have to call SPSite.OpenWeb() or SPSite.RootWeb and then use the SPWeb to get at SiteUsers. I think the way you are doing it using the object model is fine.
If you switch to use SharePoint's web services you could use these two methods: RemoveUserFromSite and RemoveGroup.