Get userprofile properties in SharePoint 2013 object model
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;
}
}
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;
}
}
Comments