We're developing a custom web part that displays information from a list about the user. We need to determine who's profile page we're on to retrieve the appropriate information from the list. The UserProfileManager needs an account to retrieve a specific profile so that won't work.
The query string isn't reliable, it varies depending on how you get to the user's page (eg: clicking "My Profile", browsing from search results, using the pretty url "/personal/username", etc...).
From your web part, you can get the profile the same way that all of the controls on the user's profile get it (using the ProfilePropertyLoader):
var profileLoader = Microsoft.SharePoint.Portal.WebControls.ProfilePropertyLoader.FindLoader(this.Page); var userProfile = profileLoader.ProfileLoaded; var username = userProfile["UserName"].Value;
UserProfileManager has two overloads to get user profile - with GetUserProfile(bool bCreateIfNotExist) - this gets user profile, or creates if it is not exists, and GetUserProfile(string strAccountName).
If you are talking about my site host, then you can determine who's profile page you're on by query string parameter. If you are viewing somebody's account, query string looks like follows:
?accountName=domain\user_name. You can determine user by this query string.