Pages

Jan 17, 2011

SharePoint Object Model – Users

Have you ever tried listing the users for a site collection from the object model and realized that the list isn’t what you expected? I ran into that recently and realized that there were several ways to get to the users and there are subtle differences in the results. Here is a quick listing:

SPWeb.AllUsers Property (Microsoft.SharePoint)

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 Property (Microsoft.SharePoint)

Gets the collection of all users that belong to the site collection.

SPUtility.GetAllAuthenticatedUsers Method (Microsoft.SharePoint.Utilities)

Returns All authenticated users of a site

SPAlertCollection.GetUniqueUsers Method (Microsoft.SharePoint)

Returns a string array that lists all the users of a site, without listing them more than once, who receive alerts for list items.

No comments: