.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
 
Sign In
Register
 
Win Surprise Gifts!!!
Congratulations!!!


Top 5 Contributors of the Month
david stephan

Home >> Code Snippets >> SharePoint >> Post New Resource Bookmark and Share   

 Subscribe to Code Snippets

Get the properties from user profile information using sharepoint object model

Posted By:abhays       Posted Date: November 08, 2014    Points: 40    Category: SharePoint    URL: http://www.dotnetspark.com  

Get the properties from user profile information using sharepoint object model
 

Below is the code snnipet for retrieving the user profile properties using SharePoint object model 

 SPSite Osite = SpContext.Current.Site;
                   SPWeb web = Osite.OpenWeb();
                   var strCurrentUser = web.CurrentUser.Name;

                   SPServiceContext serviceContext = SPServiceContext.GetContext(Osite);
                   UserProfileManager userProfileManager = new UserProfileManager(serviceContext);

                   if (!userProfileManager .UserExists(strCurrentUser))
                   {
                       UserProfile userProfile  = userProfileManager.GetUserProfile(strCurrentUser);
string uemail = userProfile[PropertyConstants.WorkEmail].ToString(); string ufirstname = userProfile[PropertyConstants.FirstName].ToString(); string ulastname = userProfile[PropertyConstants.LastName].ToString(); }



     

Further Readings:

Responses

No response found. Be the first to respond this post

Post Comment

You must Sign In To post reply
Find More code samples in C#, ASP.Net, Vb.Net and more Here

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend