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

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

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

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code class="" title="" data-url=""> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre class="" title="" data-url=""> <span class="" title="" data-url="">