码迷,mamicode.com
首页 > 其他好文 > 详细

SharePoint Users&AllUsers&SiteUsers

时间:2015-11-11 11:22:23      阅读:410      评论:0      收藏:0      [点我收藏+]

标签:

注意: 本文讨论基于SharePoint 2010, 其次文章比较罗嗦, 大神直接可以PASS.

序言

大家都知道SPWeb中有三个属性可以获取相关用户集合:

SPWeb.Users Gets the collection of user objects that are explicitly assigned permissions in the website.
SPWeb.AllUsers Gets the collection of user objects that represents all users who are either members of the site or who have browsed to the site as authenticated members of a domain group in the site.
SPWeb.SiteUsers Gets the collection of all users that belong to the site collection.

看文字描述大家都能理解, 但是具体系统中哪些用户或者用户组存储在里面可能还有点迷糊. 下面我们通过几个实验来分别看看里面是怎么样的.

第一回

当我们新建一个网站集的时候, 一般会将Domain中的Users组直接赋予网站集只读的权限(如下图所示).

技术分享

这时候我们来看看这三个属性中的值是怎么样的:

技术分享

此时, SPWeb.Users中没有数据, SPWeb.AllUsers和SPWeb.SiteUsers中的数量是一致的.

第二回

这时候当多个用户去访问该站点的时候, 又会怎么样呢?

技术分享

此时, 跟"第一回"的情况类似, 访问网站集的用户都出现在SPWeb.AllUsers和SPWeb.SiteUsers中, 而SPWeb.Users中还是没有数据.

第三回

当对某个用户自定义权限或者新建一个SharePoint自定义用户组并且赋予某个用户权限的时候, 又会怎么样呢?

技术分享

这时候我们发现"SPWeb.Users"的属性值已经发生了变化, 同样该用户出现在SPWeb.AllUsers和SPWeb.SiteUsers中.

SPWeb.EnsureUser

当通过EnsureUser方法将某个用户加到网站集的时候:

技术分享

这时候我们会发现SPWeb.SiteUsers相比SPWeb.AllUsers多了一个用户.

结束

SPWeb.SiteUsers中存储的数据是最多的, 其次是SPWeb.AllUsers, 最后是SPWeb.Users. 大家觉得呢?

enjoy SharePoint

SharePoint Users&AllUsers&SiteUsers

标签:

原文地址:http://www.cnblogs.com/jingnansu/p/4955334.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!