Posted in Sharepoint - Sharepoint 2010
SPSecurity.RunWithElevatedPrivileges(delegate() {
using(SPSite site =new SPSite(SPContext.Current.Site.ID)) {
ServerContext serverContext = ServerContext.GetContext(site);
UserProfileManager userProfileManager =
new UserProfileManager(serverContext);
userProfile = userProfileManager.GetUserProfile(userName);
}
});

