Getting User Information in Code – SPWeb.EnsureUser and SPWeb.AllUsers

7 01 2009

In relation to the post I made yesterday regarding using SPWeb.EnsureUser to check if a user is a member of a Site Collection and if not add them as a user.

If you then want to retrieve this user in code for whatever reason, make sure you use SPWeb.AllUsers and not SPWeb.Users. As I have found out this morning – the latter of the two returns nothing whereas SPWeb.AllUsers contains a full list of all the users in the Site Collection!




Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: