Friday, 30 August 2013

How to get userprofile properties in SharePoint 2013 object model?

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

}

http://www.fewlines4biju.com/2013/02/get-userprofile-properties-sharepoint.html

No comments:

Post a Comment