MySite How to find account name of users profile that is currently being displayed
-
Sunday, July 29, 2012 4:09 PM
I am working on a webpart that will sit on the profile page of mysite.
This web part needs the accountname of the user being looked at.
The displayed url is mysite/person.aspx. To my understanding the actual url is
mysite/person.aspx?accountname=DOMAIN\Username
It appears when you look at another profile it is in this format.
Currently to solve this the only thing I can think of something like this.
string url; string urlformat = "{0}/person.aspx?accountname={1}"; if(Request.QueryString["accountname"]==null) { url=string.format(urlformat,SPContext.Current.Web.Url,SPContext.Current.Web.CurrentUser.LoginName); } else { url = string.format(urlformat, SPContext.Current.Web.Url, Request.QueryString["accountname"]; }
Is there a better way to get this same data or should I just stick with the above?
All Replies
-
Sunday, July 29, 2012 5:02 PMModerator
An example how it is done in MOSS, should work well for 2010: http://sharepoint.stackexchange.com/questions/30854/how-do-i-get-the-mysite-images-and-full-name-of-the-mysite-owner-in-moss-2007-in
Kind Regards Bjoern
Blog -
Sunday, July 29, 2012 5:58 PM
I think this is a little different from what I am asking. It looks like this gets user info the current user.
What I am wanting is user info for the mysite page I am looking at. The end goal here is to add a social comment to the users page (I am making a custom web part to replace the default note board).
To do this I need a Uri for that users profile page that I am looking at. Currently the only way that I see to do this is to look for the accountname parameter.
-
Tuesday, July 31, 2012 9:32 AMModerator
Hi Jaccs,
Your above code is a solution, also you can achieve this just using Javascript by the same way.
Here is a link about how to use Javascript get current user in SharePoint(Use Client Object Model):
http://spdailytips.blogspot.com/2011/09/get-current-users-group.html
Thanks,
Lhan Han
- Edited by Lhan HanModerator Tuesday, July 31, 2012 9:32 AM
- Marked As Answer by Jaccs Tuesday, July 31, 2012 2:00 PM
-
Tuesday, July 31, 2012 2:00 PMThanks Lhan Han.

