Quantcast
Channel: SharePoint 2010 - Development and Programming forum
Viewing all articles
Browse latest Browse all 11571

Get firstname and lastname using profileManager from SharePoint picker

$
0
0

I created a sharepoint picker and when user enter an ID and click on submit, then the following code should get me their firstname and lastname from active directory. Right now it is working for only my username. Can someone please help me out with this.

PickerEntity pickEntity = (PickerEntity)peoplePicker.ResolvedEntities[0];
 string username = pickEntity.Key;
            SPSite siteCollection = new SPSite(SPContext.Current.Web.Url.ToString());
            SPServiceContext serverContext = SPServiceContext.GetContext(siteCollection); 
            UserProfileManager profileManager = new UserProfileManager(serverContext);


            UserProfile profile = profileManager.GetUserProfile(username);

            string FirstName = profile["FirstName"].Value.ToString();
            string LastName = profile["LastName"].Value.ToString();
            


                      

Viewing all articles
Browse latest Browse all 11571

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>