views:

428

answers:

1

I have a SharePoint site that I created some custom web parts for. One of them requires getting the list of SharePoint site users so I can assign different properties.

The code:

Dim Site As New SPSite(SPContext.Current.Site.Url)
Dim AllUsers As SPUserCollection = Site.RootWeb.AllUsers
Dim u As SPUser
For Each u In AllUsers
    'SOME CODE FOR DISPLAY
Next

Was working great, but yesterday I added a new user and they didn't show up in the list. I definitely see them in the list of users through the default page that shows users, so I'm wondering why this code wouldn't get the user as well.

Does anyone know why this wouldn't return every user in the SharePoint site?

Thanks.

+6  A: 

Not all user collections in sharepoint are created equally. Subtle differences:

http://www.sharepointblogs.com/tingfong/archive/2007/08/21/sharepoint-spweb-allusers-vs-spweb-users-vs-spweb-groups.aspx

(quick answer for the lazy - AllUsers shows active users, i.e. those who have interacted with the sitecollection at least once)

-Oisin

x0n
Killer, thanks!
Ryan Smith