How to programmatically get the Profile of the user from the MySite profile page

When we visit the MySite,there are two types of pages ,one is default page of the current user and other is the person.aspx which points to the profile of the user .This person.aspx can be of current logged in user or can be of any visited user.
So to get the profile of the user (current logged or visited user) programmatically ,we use “ProfilePropertyLoader sharepoint object .This works only on profile of the user and not on the home page.

This is the code below to load the profile
——————————————-

ProfilePropertyLoader loader = ProfilePropertyLoader.FindLoader(this.Page);

if (loader != null)

{

Microsoft.Office.Server.UserProfiles.UserProfile profile = loader.ProfileLoaded;

if (profile != null)

{

String AccName = Convert.ToString(profile["AccountName"].Value, CultureInfo.InvariantCulture);

}

}

—————————————–

Thus u can get the all the properties from the profile loader

Enjoy!!!

Advertisement

~ by Saurabh Mittal on September 13, 2009.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s

 
Follow

Get every new post delivered to your Inbox.