sharepoint-2010user-profileobject-modelspuser

How to get SPUser object from SocialProfile in Sharepoint 2010?


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

Thanks


Solution

  • 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>");