Raghu's SharePoint Corner: How to retrieve User Profile Properties of User From SSP

My blog has moved!

You will be automatically redirected to the new address. If that does not occur, visit
http://www.sharepointcolumn.com
and update your bookmarks.

November 13, 2008

How to retrieve User Profile Properties of User From SSP

This article will be concentrating on how to retrieve user profile properties from SSP.In order to retreive user profile properties from SSP you need to first import all the Active Directory users to SSP.

Once the users are imported you can start accessing the user profiles. The following are the assmblies that will be used in order to achieve this

1. Microsoft.Office.Server
2. Micorsoft.Office.Server.UserProfiles
3. Microsoft.Office.Administration
4. And finally Microsoft.SharePoint

using (SPSite site = new SPSite(SSPsiteURL))
                {
                    using (SPWeb web = site.OpenWeb())
                    {
                        UserProfileManager manager = new UserProfileManager(ServerContext.GetContext(web.site));
UserProfile profile = manager.GetUserProfile(web.CurrentUser.LoginName);
                        string deptName = profile["Department"].Value.ToString();
                    }
                }

Department is a user profile property in ssp. Similarly you can access all the properties of a user from ssp

In order to iterate through all the user profiles in ssp, please go through my below post

Happy coding !

No comments: