none
Difference b/w web.AllUsers and web.SiteUsers

    Question

  • I got the below error.

    This page is available only for a Web site with unique permissions.

    When I started debugging, I found it was failing with "allusers". I then replaced with "siteusers" and started working.

    Wanted to know the pros/cons of using "allusers" vs "siteusers". 

    pls suggest.

     

    Friday, May 28, 2010 7:57 PM

Answers

  •  

    > "allusers" vs "siteusers"

    And just for fun, there are three user collections available from SPWeb: .Users, .AllUsers and .SiteUsers.

     

    SPUserCollection users = web.Users ;
    SPWeb.Users gets the collection of user objects that are explicitly assigned permissions in the Web site . It will not return users who have access through a group.

    SPUserCollection users = web.AllUsers ;
    SPWeb.AllUsers gets the collection of user objects that represents all users who are either members of the site collection or who have browsed to the site as authenticated members of a domain group in the site.   (note the "browsed to" here... adding a AD group to a site does not add the users to AllUsers immediately... they will not be listed here until they have visited the site at least once.)

    SPUserCollection users = web.SiteUsers ;
    SPWeb.SiteUsers gets the collection of all users that belong to the site collection.


    Mike Smith TechTrainingNotes.blogspot.com
    Saturday, May 29, 2010 1:34 AM
  • AllUsers contains any user that has accessed the site whether it be because they have been explicitly added to the site as a user, or because they belong to a group (typically an Active Directory group) that has been given access. E.g. You could add you AD "Users" group to the Members group of a site, this would allow anyone in your AD Users group to access the site, however they are not explicitly added to the site users list.

    SiteUsers is just those users that have been explicitly added as a user to the site.

    I have not actually seen the error message you refer to though, so can't say why this occurs.


    Read my wiki at www.intheknow.it for more code and tips for developing with SharePoint 2007 & 2010
    Twitter: @starznet

    Technical Architect at Starznet Ltd. WSS/MOSS development and customisation with a primary focus on CMS.
    Friday, May 28, 2010 8:15 PM

All replies

  • AllUsers contains any user that has accessed the site whether it be because they have been explicitly added to the site as a user, or because they belong to a group (typically an Active Directory group) that has been given access. E.g. You could add you AD "Users" group to the Members group of a site, this would allow anyone in your AD Users group to access the site, however they are not explicitly added to the site users list.

    SiteUsers is just those users that have been explicitly added as a user to the site.

    I have not actually seen the error message you refer to though, so can't say why this occurs.


    Read my wiki at www.intheknow.it for more code and tips for developing with SharePoint 2007 & 2010
    Twitter: @starznet

    Technical Architect at Starznet Ltd. WSS/MOSS development and customisation with a primary focus on CMS.
    Friday, May 28, 2010 8:15 PM
  • so anything defined with "Siteusers" will not be available to the root-site or site collection?
    Friday, May 28, 2010 8:23 PM
  • What exactly do you mean by that?

    The SiteUsers property is available on an SPWeb object whether that be the site collection root web or any other web. It is not available on the SPSite object (which is technically the Site Collection object).


    Read my wiki at www.intheknow.it for more code and tips for developing with SharePoint 2007 & 2010
    Twitter: @starznet

    Technical Architect at Starznet Ltd. WSS/MOSS development and customisation with a primary focus on CMS.
    Friday, May 28, 2010 8:28 PM
  •  

    > "allusers" vs "siteusers"

    And just for fun, there are three user collections available from SPWeb: .Users, .AllUsers and .SiteUsers.

     

    SPUserCollection users = web.Users ;
    SPWeb.Users gets the collection of user objects that are explicitly assigned permissions in the Web site . It will not return users who have access through a group.

    SPUserCollection users = web.AllUsers ;
    SPWeb.AllUsers gets the collection of user objects that represents all users who are either members of the site collection or who have browsed to the site as authenticated members of a domain group in the site.   (note the "browsed to" here... adding a AD group to a site does not add the users to AllUsers immediately... they will not be listed here until they have visited the site at least once.)

    SPUserCollection users = web.SiteUsers ;
    SPWeb.SiteUsers gets the collection of all users that belong to the site collection.


    Mike Smith TechTrainingNotes.blogspot.com
    Saturday, May 29, 2010 1:34 AM