Using Profile Properties to redirect users

By Michael Doyle posted 09-21-2011 14:16


There are many cases where you want to redirect users to a particular home page based upon who they are. An excellent example is if you have extranet users that fall into different categories or need to be directed to different sites. There are several ways to accomplish this but I think one of the most straight forward and easiest to implement for small or medium sized installations is to use User Profile properties and a little bit of JavaScript and some aspx. The gist of this solution is create and populate a user profile property, create a redirect page, and add some JavaScript to redirect page. We will go ahead and outline these steps in a little more detail. This solution requires you to have the Enterprise version of SharePoint but will work with 2007 or 2010 (even 2003 if that is still around).

Step 1. Create the User Profile property

  1. Navigate to the Central Administration site
  2. Go to the User Profile Management page. This can be found under the Manage Service Applications link and then clicking on User Profile Service (it is possible it is named something else but this is the default)
  3. Then click on Manage User Properties
  4. Then click on New Property
  5. Name the property something that makes sense like Home, leave the rest of the defaults, and click OK

For this solution the Home field will contain the part of the URL that is below the redirect page. For example if you wanted the user to go to http://sharepoint/engineeringyou would put the word engineering in the field and the redirect page would be at the http://sharepointlevel.

Step 2. Create or user a redirect page.

You have a couple of choices here. You can use the default home page. In this case users who don’t have anything in their Home property will simply stay on the home page. The other option is to create a page that is purely for redirection in which case nobody will stay on the page. It is just there for redirection, but you will need to set it to be the welcome page (this requires publishing to be turned on). It will work either way.

Step 3. Add the ASPX to the redirect page

Place the following ASPX code on the redirect page (doesn’t matter which way it was done in Step 2.) under the PlaceHolderMain content place holder.

<SPSWC:ProfilePropertyLoader id="m_objLoader" LoadFullProfileOfCurrentUser="true" runat="server"/>
               <span id="spanName">
 <SPSWC:ProfilePropertyValue PropertyName="Home" runat="server"/>

This will load the value from the Home property and make it available for JavaScript.

Step 4. Add the JavaScript

The final step is to use some JavaScript to redirect the user. We take the inner text of the span tag, remove the spaces and redirect the user to the site indicated in the Home property. If there isn’t a value then we just stay there. If you are using the dedicated redirect page you will want to have a default location to redirect to.


    s = spanName.innerText;

    //remove the trailing spaces

    s = s.replace(/\s+/g,'');

    // redirect the user to

    if(s != "")


     location.href = "../" + s;




#SharePoint #user #profiles