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 ;-)