如何从网站及其子网站中获取不同的用户?
我收到客户的要求,他想了解网站及其子网站中有权访问网站的不同用户信息。每个子站点都有单独的组(贡献、批准和完全访问)。从这些组中可以找到不同的用户信息。
我们如何使用对象模型来做到这一点?请帮帮我。
提前致谢。
I got a requirement from client that he wants to know distinct users information from sites and it sub sites those have access to site. There are separate groups for each subsite (contribute, approval and full access). From these all groups find distinct user information.
How can we do that using Object model? Please help me out.
Thanks in advance.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
SharePoint 2010 - 当有人询问谁拥有网站的权限时,我经常使用此 PowerShell 脚本。这不包括直接授予权限的用户或网站集管理员,但它仍然很有帮助。
您必须在 SP2010 服务器上才能运行此程序。
SharePoint 2010 - I use this PowerShell script quite often when someone asks who has permissions to a site. This wont include users given permissions directly, or site collection admins, but it's still helpful.
You must be on the SP2010 server to run this.
这是非常普遍的要求之一,但很快就会变得非常困难。听起来他们正在尝试创建某种安全审核。
如果您假设每个网站只有由 SharePoint 用户组成的 SharePoint 组,并且所有内容都继承权限,那么这就稍微容易一些。您可以递归地迭代每个 SPWeb(以及每个 SPWeb 中的子 SPWeb)以查找所有 SP 组。然后,使用字典,您可以跟踪找到的用户及其权限级别。他们的权限级别由他们在组中的成员身份决定,您可能会使用
web.RoleAssignments.GetAssignmentByPrincipal(group)
(GetAssignmentByPrincipal) 获取作业列表(例如:阅读、贡献等)。然而,这种情况可能不是您的客户所遇到的。需要考虑的事情(有些事情比其他事情更容易克服):
实际上,编写准确的安全审计非常困难。对此的最佳解决方案可能是找到熟悉如何设置安全性的人,通过每个站点来修复它们。
This is one of those very general requirements that gets very difficult very quickly. It sounds like they are trying to create some sort of security audit.
If you assume each site only has SharePoint groups filled with SharePoint users and everything is inheriting permissions, then it is a little easier. You could recursively iterate over each SPWeb (and the sub-SPWeb's in each SPWeb) to find all the SPGroups. Then, using a Dictionary, you would keep track of the users you find and their permission level. Their permission level is determined by their membership in the group and you'd probably use
web.RoleAssignments.GetAssignmentByPrincipal(group)
(GetAssignmentByPrincipal) to get the list of assignments (Ex: Read, Contribute, etc).However, the scenario is probably NOT what your client has. Things to think about (some easier to overcome than others):
Realistically, it is very difficult to write an accurate security audit. The best solution for this is probably to find someone who is familiar with how security should be set up going through each site to fix them.