Saturday, February 16, 2013

How to get userprofile properties in SharePoint 2013 object model?

In this post we will discuss about how to retrieve UserProfile properties in SharePoint 2013 using object model. You can also check some tutorials on SharePoint Server object model and Client Object Model SharePoint 2010.

Below is the code:

using Microsoft.Office.Server.Social;

using Microsoft.Office.Server.Administration;
using Microsoft.Office.Server.UserProfiles;

using Microsoft.SharePoint.Portal.UserProfiles;

void GetUserProfileProperties()

SPWeb web = SPContext.Current.Web;

SPUser currentUser = SPContext.Current.Web.CurrentUser;

SPServiceContext serverContext = SPServiceContext.GetContext(web.Site);

UserProfileManager profileManager = new UserProfileManager(serverContext);

UserProfile profile = profileManager.GetUserProfile(currentUser.LoginName);

if (profile != null)
string displayName = profile.DisplayName;


You can also check out various posts on SharePoint 2013 Developer Site Template, What's new for 
mobile devices in SharePoint 2013 and  some SharePoint 2013 PowerShell commands.

No comments:

Post a Comment