如何从网站及其子网站中获取不同的用户?

发布于 2024-10-01 05:25:57 字数 128 浏览 10 评论 0原文

我收到客户的要求,他想了解网站及其子网站中有权访问网站的不同用户信息。每个子站点都有单独的组(贡献、批准和完全访问)。从这些组中可以找到不同的用户信息。

我们如何使用对象模型来做到这一点?请帮帮我。

提前致谢。

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 技术交流群。

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

发布评论

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

评论(2

执笔绘流年 2024-10-08 05:25:57

SharePoint 2010 - 当有人询问谁拥有网站的权限时,我经常使用此 PowerShell 脚本。这不包括直接授予权限的用户或网站集管理员,但它仍然很有帮助。

您必须在 SP2010 服务器上才能运行此程序。

#Get a list of groups in a site, then a list of people in each group

Add-PSSnapIn Microsoft.SharePoint.PowerShell

$spWeb = "http://sharepoint/site/"
foreach($group in ((Get-SPWeb $spWeb).Groups)){
    foreach($user in $Group.Users)
    {$group.Name  + "  - " + $user.Name
    }
}

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.

#Get a list of groups in a site, then a list of people in each group

Add-PSSnapIn Microsoft.SharePoint.PowerShell

$spWeb = "http://sharepoint/site/"
foreach($group in ((Get-SPWeb $spWeb).Groups)){
    foreach($user in $Group.Users)
    {$group.Name  + "  - " + $user.Name
    }
}
凉宸 2024-10-08 05:25:57

这是非常普遍的要求之一,但很快就会变得非常困难。听起来他们正在尝试创建某种安全审核。

如果您假设每个网站只有由 SharePoint 用户组成的 SharePoint 组,并且所有内容都继承权限,那么这就稍微容易一些。您可以递归地迭代每个 SPWeb(以及每个 SPWeb 中的子 SPWeb)以查找所有 SP 组。然后,使用字典,您可以跟踪找到的用户及其权限级别。他们的权限级别由他们在组中的成员身份决定,您可能会使用 web.RoleAssignments.GetAssignmentByPrincipal(group) (GetAssignmentByPrincipal) 获取作业列表(例如:阅读、贡献等)。

然而,这种情况可能不是您的客户所遇到的。需要考虑的事情(有些事情比其他事情更容易克服):

  • 当用户存在于同一站点的多个组中时会发生什么?
  • 对站点具有单独权限的用户?
  • SPWeb 级别的权限继承被破坏?列表权限怎么样?项目权限?当您看到“限制访问”时会发生什么?
  • AD 组是否在任何地方使用?是否必须列出每个 AD 组中的所有用户?那么像“所有经过身份验证的用户”这样的特殊组呢?

实际上,编写准确的安全审计非常困难。对此的最佳解决方案可能是找到熟悉如何设置安全性的人,通过每个站点来修复它们。

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):

  • What happens when a user exists in multiple groups in the same site?
  • Users with individual permissions to a site?
  • Broken permission inheritance at a SPWeb level? What about list permissions? Item permissions? What happens when you see Limited Access?
  • Are AD groups used anywhere? Do you have to list all the users in each AD group? What about special groups like "ALL AUTHENTICATED USERS"?

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.

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