SharePoint User Information List Extensions

I’m currently writing on issue 6 of USP Journal, which will revolve around two solutions I’m putting up on CodePlex next week (that would be the week beginning August 17 2009, if you are not reading this right after I publish this, which is a nice segue to reminding you that you can subscribe to updates from my blog using RSS).

Anyway, one thing that I’m using is extending the user information list to store additional user data. I wrote about manipulating the SharePoint user information list in issue 1 as well, and I think the user information list is a great way of storing information to personalize a SharePoint solution.

In any case, to work with the extended properties, you cannot address the SPUser object directly, as this object only contains pre-defined properties. As such, you need to convert the current user object into a regular SPListItem item, and then access the properties of that SPListItem.

The following code does the trick:

// Find current user from SPWeb web…
SPUser spUser = web.CurrentUser;
// …and the site’s user information list
SPList userList = web.SiteUserInfoList;
// …and again the user
SPListItem user = userList.Items.GetItemById(spUser.ID);

You can then access your extended properties as such:

string themeUrl = user["Style"].ToString();

Of course, the column Style must be present in the user information list, but you can simply add that column, either manually through the list settings or through code, as I’ll show you in issue 6.

By the way, USPJ issue 6 will be on two solutions, one for a solution to supportable custom SharePoint themes and the other for a sample data extractor, based on the technique I showed in one of the YouTube bonus videos from issue 5.

.b

Found this article valuable? Want to show your appreciation? Here are some options:

a) Click on the banners anywhere on the site to visit my blog's sponsors. They are all hand-picked and are selected based on providing great products and services to the SharePoint community.

b) Donate Bitcoins! I love Bitcoins, and you can donate if you'd like by clicking the button below.
Donate Bitcoins

c) Spread the word! Below, you should find links to sharing this article on your favorite social media sites. I'm an attention junkie, so sharing is caring in my book!

Tags: ,

Post Author

This post was written by who has written 423 posts on Furuknap's SharePoint Corner.

I do SharePoint. When I'm not doing SharePoint, I sleep, and then I dream about SharePoint. Oh, and I dabble a bit in cryptocurrencies (Bitcoin, Litecoin, etc)

One Response to “SharePoint User Information List Extensions”

  1. Anonymous March 10, 2010 at 10:08 pm #

    Your info was extremely helpful. Thanks for taking the time to write this blog.

Leave a Reply