Hi All,
Today we will see about the Usercollections in SharePoint.Lets we see the Scenario
Scenario:
You want to get all the users who have access to the site. An SPWeb object exposes three different collections of users, as shown in this code below.
Code:
SPWeb web = SPContext.Current.Web;
SPUserCollection c1 = web.Users;
SPUserCollection c2 = web.AllUsers;
SPUserCollection c3 = web.SiteUsers;
Ok.... So what is the difference among these 3 collections.
The "Users" collection has the smallest membership of these three collections. This collection includes all the external principals that have been explicitly assigned permissions within the current site.
The "AllUsers" collection includes all members of the Users collection, plus external users that have accessed objects within the site using implicit permissions through group or role membership. For example, imagine a user named Sachin with the login of Company\Sachin that has never been given explicit permissions to access a site and view a particular list. However, he might still be able to view the list because of his membership within an Active Directory group that has been configured with list view permissions. When Sandeep first accesses the site or one of its objects (say, a list using implicit permissions), he is added as a member of the AllUsers collection, but he is not added as a member of the Users collection.
The "SiteUsers" collection is an aggregation that combines membership for each AllUsers collection within the current site collection. The membership of this collection includes all external principals that have been assigned permissions to any object within the site collection as well as all external users that have been granted access to any of the site collection's objects using implicit permissions.
I hope now u will get an idea about these collections.
Obviously there, u will get this doubt.
-----What will the SharePoint UserInfoList contain - AllUsers or SiteUsers or Users?
And the answer is, Actually it contains cached information about the users logged in at least once to the site collection.
See u on my next post :) byeee....
Today we will see about the Usercollections in SharePoint.Lets we see the Scenario
Scenario:
You want to get all the users who have access to the site. An SPWeb object exposes three different collections of users, as shown in this code below.
Code:
SPWeb web = SPContext.Current.Web;
SPUserCollection c1 = web.Users;
SPUserCollection c2 = web.AllUsers;
SPUserCollection c3 = web.SiteUsers;
Ok.... So what is the difference among these 3 collections.
The "Users" collection has the smallest membership of these three collections. This collection includes all the external principals that have been explicitly assigned permissions within the current site.
The "AllUsers" collection includes all members of the Users collection, plus external users that have accessed objects within the site using implicit permissions through group or role membership. For example, imagine a user named Sachin with the login of Company\Sachin that has never been given explicit permissions to access a site and view a particular list. However, he might still be able to view the list because of his membership within an Active Directory group that has been configured with list view permissions. When Sandeep first accesses the site or one of its objects (say, a list using implicit permissions), he is added as a member of the AllUsers collection, but he is not added as a member of the Users collection.
The "SiteUsers" collection is an aggregation that combines membership for each AllUsers collection within the current site collection. The membership of this collection includes all external principals that have been assigned permissions to any object within the site collection as well as all external users that have been granted access to any of the site collection's objects using implicit permissions.
I hope now u will get an idea about these collections.
Obviously there, u will get this doubt.
-----What will the SharePoint UserInfoList contain - AllUsers or SiteUsers or Users?
And the answer is, Actually it contains cached information about the users logged in at least once to the site collection.
See u on my next post :) byeee....
No comments:
Post a Comment