Wednesday, December 12, 2012

Sharepoint 2010: Stop Re-direction to Mysite person.aspx page

Scenario: On a multi-auth enabled SAML webapp, If you click under welcome sign-in control "About Me" it will re-direct user to My-Site person.aspx page. Its all good as long as, that logged in user has a mysite. But, in scenario were the users doesn't have a mysite created, It will prompt for user credentials, which might be annoying. But this is OOB SharePoint behavior.How can you stop this re-direction?

Solution: Actually, as soon as a user profile gets created for that logged in user, it will start re-directing user to person.aspx page. But, instead clients want to get re-directed to "userdisp.aspx" page.

Well,This can be done by deleting the user profile so that it will always gets re-directed to "userdisp.aspx". But, the profile gets re-created again. And in a scenario were there are thousands of user this solution is not viable.

Actually, behind the scenes, there is a OOB user control called "MySiteRedirection.ascx" that is tied to a delegate control "DelctlProfileRedirection" on userdisp.aspx page that does this re-direction. That control is tied to this userdip.aspx page via OOB feature named "MySite".

So the custom solution to stop the mysite re-direction will be to create your own custom user control, with no code (just empty default usercontrol) and place it under "_controltemplates" . Then create a feature.xml and elements.xml file to load your custom user control inside the "ProfileRedirection" delegate control, with a sequence number less than "100". If the sequence number is not set to less than 100, your custom control will not be loaded.

For more info about understanding OOB delegate controls refer to:-
http://www.helpmeonsharepoint.com/2012/04/sharepoint-delegate-controls.html

And to know how to customize and load your own controls refer to:-
http://panvega.wordpress.com/2008/10/12/sharepoint-delegate-controls/
http://sharepointmagazine.net/articles/custom-page-security-using-sharepoint-delegate-controls
http://blogs.msdn.com/b/sowmyancs/archive/2009/02/01/how-to-create-a-custom-delegate-control-with-vsewss-1-3.aspx