Geeks With Blogs
SharePoint & SQL Thoughts

One of my clients wanted to have the user profile on SharePoint to be redirected to a custom page that they have created showing the user's picture and other detailed information that would not basically appear on the out of the box user details page.

With this task in hand I have to explain the mechanism behind user profiles details page. When a user is clicked on SharePoint, userdisp.aspx page is called which determines the destination of the page. This page can ge found at 12hive\Templates\Layouts.

To allow the details page to be directed somewhere else, add the following code to your userdisp.aspx

<%@ Assembly Name="Microsoft.Office.Server, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>

Then just before the closer of your content tag </asp:content> add the following code

<%
// Changes to redirect User Display to Details pageas per the requirements
try

Microsoft.Office.Server.ServerContext cntx =   Microsoft.Office.Server.ServerContext.GetContext(HttpContext.Current);
Microsoft.Office.Server.UserProfiles.UserProfileManager profileManager = new Microsoft.Office.Server.UserProfiles.UserProfileManager(cntx);
bool userExists = profileManager.UserExists(this.UserListForm.Item["Account"].ToString());

if (userExists)
{

// to redirect to a custom page
Response.Redirect("/<your custom page url>.aspx?=accountname:" + this.UserListForm.Item["Account"].ToString

// to redirect to my site page
Response.Redirect(profileManager.MySiteHostUrl + "/Person.aspx?accountname=" + this.UserListForm.Item["Account"].ToString());

());
}  

}    

catch

{
// do nothing, will use the original userdisp.aspx
}

%>

Hopefully this helps someone!

Posted on Wednesday, April 1, 2009 5:23 PM | Back to top


Comments on this post: User Profile redirect on SharePoint

# re: User Profile redirect on SharePoint
Requesting Gravatar...
Hi

I have the same requirement but I can't get it to work. I am using wss3.

Even simply placing a redirect such as

<%
Response.Redirect("http:\\www.google.com");
%>

I get all sorts of errors from File not found to other weird and wonderful stuff.

What am I missing
Left by Dan on Nov 07, 2010 11:08 PM

# re: User Profile redirect on SharePoint
Requesting Gravatar...
A built in way to do this would be with delegate controls. This would be supported by Microsoft as a long term solution. Here is my blog post about how to use the delegate control in SharePoint 2007. http://blogs.sharepointguys.com/brendon/sharepoint-2007/programming/redirect-to-your-own-mysite-landing-page/
Left by Brendon on May 13, 2011 11:06 AM

# re: User Profile redirect on SharePoint
Requesting Gravatar...
It works for me. Thanks!
Left by jcpenney coupons on Jun 04, 2011 8:56 AM

# re: User Profile redirect on SharePoint
Requesting Gravatar...
hi this is really a nice post on a nice topic. you have urged me to bookmark your page for further readings and to send this link to my all friends. Thanks
Left by build muscles on Jul 01, 2011 12:21 PM

Comments have been closed on this topic.
Copyright © Leonard Mwangi | Powered by: GeeksWithBlogs.net