in

From the outside in

The blog of Iain Angus

Accessing User Profile Information in WSS 3.0

MOSS and WSS 3.0 handle user profiles differently. In MOSS, user profile information is stored centrally and can be shared across site collections. Profiles can be manipulated using the UserProfileManager class found in Microsoft.Office.Server.dll.

Life just isn't the same when working with WSS 3.0. When developing a workflow, for example, it may be useful to access a property of the user profile. You can't use UserProfileManager as it doesn't exist and SPUser doesn't expose most of the profile information. In WSS 3.0 the user profile information is stored in a hidden list specific to an individual site collection. If you have multiple site collections, a different hidden list is used for each site collection. The User Profile Information is just another list and can be treated as such -

SPList userProfileList = web.Lists["User Information List"];

foreach (SPListItem user in userProfileList.Items)
{
    Console.WriteLine(user["Name"] + " " + user["Department"];
}

The cut down C# above lists all the user names and departments.

Accessing the user profile information in WSS 3.0 is straightforward, once you know how ;-)

Published Jan 30 2008, 11:53 AM by Iain
Filed under:

Comments

 

Wael said:

There is a problem here , only administrators can view this list programmatically and how to view it if the looged user is not administrator ?????

please replay here and on my mail wael.mohamed@live.com

thanks

July 16, 2008 10:50 AM
 

John said:

Found this post you made just recently. It was helpful in at least getting me in the right ball park but the items returned above still seem to be limited. I can not find the Business phone number of a profile for the life of me. Any suggestions?

November 24, 2008 6:07 PM
 

Iain said:

Sorry Wael, had missed your comment, :-(

Run the code with elevated privileges, e.g.

SPSecurity.RunWithElevatedPrivileges(delegate()

{

   // implementation details omitted

});

Have a look at the MSDN article -

msdn.microsoft.com/.../microsoft.sharepoint.spsecurity.runwithelevatedprivileges.aspx

December 6, 2008 3:01 PM
 

Iain said:

Thanks for the comment John. I assume you have added Business Phone to the user profile list from the existing site columns? If so getting the business phone is straightforward. In the above example, simply use user["Business Phone"].

Let me know if this is what you were asking?

December 6, 2008 3:20 PM
 

Steve said:

Is there any difference between the "User Information List" and the "UserInfo" list?   It appears that the SPUserCollection at SPContext.Current.Web.Users appears to point to "UserInfo" which has a different GUID.  Is this just a subset of data, ie the "Person" ContentType of the "User Information List", and if so can you access custom fields or the row/item data from this object?

I'm trying to create a MembershipContentType that I can add to the "User Information List" along with a SharePointListMembershipProvider and was wondering the easiest way to obtain the requested user, either as a SPUser or a List Item.

December 29, 2008 10:32 PM
 

Ayush said:

Thanks a lot!!! This post was a great help to me as I was wondering how to access user profile in WSS.

October 6, 2009 4:03 PM

Leave a Comment

(required)  
(optional)
(required)  
Add
Black Marble 2004-2010
Powered by Community Server (Commercial Edition), by Telligent Systems