3

How can I get the SPUser object associated to the profile from the SocialProfile in Sharepoint 2010?

Thanks

empz
  • 11,509
  • 16
  • 65
  • 106

2 Answers2

0

Get the login name of the user as specified in the msdn article you linked. Then get the user for the given SPSite, since SharePoint users (and groups) are per site-collection:

SPWeb web = ...;
web.AllUsers["<loginName>"];

or if you want to create the user if it not already exits:

web.EnsureUser("<loginName>");
Stefan
  • 14,530
  • 4
  • 55
  • 62
0

First, get the ID of the required user

UserProfile profile = GetProfile();
string userId = profile .MultiloginAccounts[0];

Second, get user from one of the following collections

web.AllUsers, web.Users or web.SiteUser

This article is about the differences http://social.msdn.microsoft.com/Forums/en-US/sharepointdevelopment/thread/71d1c8e3-de32-4e3d-9f8c-7a9be13197f6/

guchko-gleb
  • 983
  • 1
  • 6
  • 8