The following references are required:
- Microsoft.Office.Server
- Microsoft.Office.Server.UseProfiles
- Microsoft.SharePoint
- System.Web
{
try
{
using (var site = new SPSite(siteCollectionUrl))
{
var serverContext = SPServiceContext.GetContext(site);
var profileManager = new UserProfileManager(serverContext);
var userProfile = profileManager.GetUserProfile(currentUser.RawSid);
return userProfile != null ? userProfile : null;
}
}
catch (Exception ex)
{
// Handle error and write them to a log
return null;
}
}
I hope this has helped you, please feel free to drop me a note if you have any questions.