Required using statements
using Microsoft.SharePoint; using Microsoft.Office.Server; using Microsoft.Office.Server.UserProfiles;
Then sample code
try { site = SPContext.Current.Site; ServerContext serverContext = ServerContext.GetContext(site); UserProfileManager userProfileManager = new UserProfileManager(serverContext); UserProfile currentUserUserProfile = userProfileManager.GetUserProfile(System.Web.HttpContext.Current.User.Identity.Name); string nameSurname = (string)currentUserUserProfile["preferredname"].Value; string email = (string)currentUserUserProfile["workemail"].Value; string companyName = (string)currentUserUserProfile["company"].Value; } finally { site.RootWeb.Dispose(); site.Dispose(); }
Remember Me
Page rendered at Friday, March 12, 2010 8:21:49 PM (GMT Standard Time, UTC+00:00)
Disclaimer The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.