Pages

Monday, March 12, 2012

Manage User Properties

In many of my SharePoint projects I need to add some information about the logged user.
The User Profile Services is able to do that, I show you how step by step:
  1. Go to Sharepoint Central Administrator and go to Manage service applications and click on User Profile Services
    09-03-2012 12-57-11
  2. Then click on Manage User Properties
    09-03-2012 12-57-49
  3. Create New Property and insert the information that you need
    09-03-2012 12-59-24
  4. Now come back and click on Manage User Profiles
    09-03-2012 12-57-49
  5. Find the user where you want insert the new property and edit it
    09-03-2012 12-58-19
  6. Add the value that you need
    09-03-2012 12-58-37
Off course you can get the value programmatically:
//Get Current Site
var site = SPContext.Current.Site; 
//Define Server Context
var cx =  SPServiceContext.GetContext(site);
//Create an instance of the User Profile Manager
var profileManager = new UserProfileManager(cx); 
var user = profileManager.GetUserProfile(SPContext.Current.Web.CurrentUser.Name); 


string str = user["CustomerClassification"].Value.ToString();


bye

No comments:

Post a Comment