To retrieve User Profile information in SharePoint 2010
you should have User Profile Service application configured and
activated. Microsoft.Office.Server.UserProfiles.UserProfileManager dll
need to reference needed.
SharePoint 2010 object model code to retrieve the data:
using (SPSite site = new SPSite("Site URL"))
{
SPServiceContext context = SPServiceContext.GetContext(site);
UserProfileManager upm = new UserProfileManager(context);
UserProfile profile = upm.GetUserProfile("Domail\\UserName");
String WorkEmail=profile[PropertyConstants.WorkEmail].Value.ToString();
String FirstName = profile[PropertyConstants.FirstName].Value.ToString();
String FirstName = profile[PropertyConstants.FirstName].Value.ToString();
String LastName = profile[PropertyConstants.LastName].Value.ToString();
}
No comments:
Post a Comment