Nov29

SharePoint redirecting user link to MySite page - solution

 Categories:

Udated Code: See http://www.wssdemo.com/Blog/archive/2008/12/23/Update-to-SharePoint-My-Site-redirect.aspx

SharePoint provides rich integration between content and users (Office Communicator presence information and a hyperlink to display user details). This can be seen everywhere a user name is assigned to a piece of content which can be:

  • Created/Modified By details for any item display page or view that includes these columns
  • Site group membership from settings page or web part
  • People & Group column added to any list/library
  • Workflow and version details

For Microsoft Office SharePoint Server 2007, some customers find that clicking on a user name takes them to the My Site persondetails.aspx page while others only see the simple WSS userdisp.aspx page. Why is that?

All people links go to http://SiteCollectionURL/SiteURL/_layouts/userdisp.aspx?ID=17&Source=... And this page decides whether to redirect to the My Site provider defined in the SSP that the Web Application containing the content site collection is assigned to based on one of the following rules:

  1. Host name of the My Site web application matches the site from where userdisp.aspx is called (i.e. both web applications are running on different port numbers)
  2. The site collection where userdisp.aspx is called from has a Portal Connection setting which is set to the My Site url (this would add the My Site to the start of the breadcrumb navigation for OOTB master pages which most customers don't want)

Figure 1: WSS simple user details page (happy Adam?)

I found many references to this problem searching on the web and several proposed solutions that were flawed so, here is a solution that works and has been tested in a medium farm environment of 3 WFE's and 14,000 users in the profile db(thanks to my colleague Craig for refining my solution down to the 4 lines of code).

The solution would be for Microsoft to fix this. It is obvious based on the Intranet Web Application -> SSP -> MySite relationship that they are trusted.

My solution involves modifying the userdisp.aspx page in the 12\templates\layouts directory so you should review this article first http://support.microsoft.com/kb/944105

This solution doesn’t even require users to have a physical My Site or even permissions to create a My Site. All you have to do is verify that the public page has the correct permissions by browsing to the permissions page on the My Site Host.

Add the following line to the start of the first line in userdisp.aspx

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

Add the rest of this code just before the final </asp:Content> tag at the bottom of the page

<%

// Changes to redirect User Display to My Site if the user has a profile in the SSP

try

{             

       UserProfileManager profileManager = new UserProfileManager(ServerContext.Default);

       bool userExists = profileManager.UserExists(this.UserListForm.Item["Account"].ToString());

       if (userExists)

       {

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

       }

}    

catch

{

    // do nothing, original userdisp content will be displayed

}

%>

 

There is a scenario not covered by this customization or the OOTB userdisp page and that is when the user has been deleted from AD, removed from the SPS User Profile and deleted from the Site Collection. The OOTB userdisp.aspx page just shows an error but in some customer environments there may be historical information about people who have left for auditing purposes (like their job title, cost center, termination date or manager were) which would be useful to display.

 
 

Links to this post

Comments

On 30 Nov 2008 12:40, Dissing // Ameq said:

The way I would fix this, is make a page adapter and setup to "adaped" Microsoft.SharePoint.ApplicationPages.UserDisplayPage. In the OnInti metode, I would use the same code as your. The nice thing with the page adapter is it only hits the site collection (web apps) that your setup on and your don't change in the standard files

On 03 Dec 2008 11:29, Kevin said:

So how do you get in a situation where it doesn't forward to MySite in the first place? I am confused by the blog post above what causes this. It seems like if the web app is hooked up to the SSP with a profile service, you're fine. Are you saying if you're on a different web app than where the MySite template is it doesn't work? That seems unlikely.

On 07 Dec 2008 01:42, Ian Morrish said:

Unlikely, but true. Rumour has it that this may be fixed in SP2.

On 11 Dec 2008 05:08, Mike said:

Hi, firstly thanks for your article, I have the problem you describe and did try your solution but get a unknown error now when I click on the user. The client is using SSL for thier mysite and I note that in SSP the personal site provider always defaults to the port 80. This could be irrelevant but was the clue when fixing a search related issue. Has anyone else had issues with userdisp and mysite using SSL ? thanks Mike

On 11 Dec 2008 05:09, Mike said:

Hi, firstly thanks for your article, I have the problem you describe and did try your solution but get a unknown error now when I click on the user. The client is using SSL for thier mysite and I note that in SSP the personal site provider always defaults to the port 80. This could be irrelevant but was the clue when fixing a search related issue. Has anyone else had issues with userdisp and mysite using SSL ? thanks Mike

On 19 Dec 2008 09:34, Sam said:

Hi, I have the same issues, I saw your post and try to make changes to userdisp.aspx page, But for some reason its failling at creating new objects. I am getting error at UserProfileManager profileManager = new UserProfileManager(ServerContext.Default); Am I missing any thing?. Thank You

On 13 Feb 2009 01:44, Tim Eggleston said:

Fantastic solution but there's a couple of things missing which will be why people are getting the oh-so-helpful "Unmknown Error"; I found that you need to provide the UserProfileManager class with the full namespace. Follow the instructions above but replace Ian's block of code with this: Microsoft.Office.Server.UserProfiles.UserProfileManager profileManager = new Microsoft.Office.Server.UserProfiles.UserProfileManager(ctx) <% // Changes to redirect User Display to My Site if the user has a profile in the SSP try { Microsoft.Office.Server.ServerContext ctx = Microsoft.Office.Server.ServerContext.GetContext(HttpContext.Current); Microsoft.Office.Server.UserProfiles.UserProfileManager profileManager = new Microsoft.Office.Server.UserProfiles.UserProfileManager(ctx); bool userExists = profileManager.UserExists(this.UserListForm.Item["Account"].ToString()); if (userExists) { Response.Redirect(profileManager.MySiteHostUrl + "/Person.aspx?accountname=" + this.UserListForm.Item["Account"].ToString()); } } catch { // do nothing, original userdisp content will be displayed } %>

On 11 Jun 2009 11:54, Umakanth Nelige said:

Mike, solution for changing the URL in the search results: http://umakanthn.blogspot.com/2008/02/modifying-search-results-url-in.html Umakanth Nelige

Leave a comment





CAPTCHA Image Validation