Skip Ribbon Commands
Skip to main content

Anders Rask on SharePoint


Anders Rask on SharePoint > Posts > Redirect to User Info instead of My Site Public Profile
September 11
Redirect to User Info instead of My Site Public Profile

We had a request by a customer that external users should not be able to view My Site Public Profile pages. This proves a challenge because SharePoint links to _LAYOUTS/UserDisp.aspx?id=123 all over the site (for example in Modified By columns on list views). Out of box SharePoint have delegate controls that check if you have a My Site Host running or not, or if the user id you requested is a group or a user. Clicking on these links for users without access to My Site Host would simply give them a prompt to a site they would't have access to, so not optimal!

Instead I wanted to link them to the view that you get if you *dont* have a My Site Host: The item view in the user info list instead. As a plus that would make it possible for me to decide what info these limited access users should see using the "replicable" checkbox in Edit User Profile Properties:


There are alot of info out there on SharePoints Hidden User List, for example check my buddy Tobias Zimmergrens blog post on this topic.

So to short-wire this logic I created a new delegate control with same ControlId "Redirect ProfileRedirection" just with a lower squence (40) (shout-out to Keith Dahlby for putting me on the right track with this post).

The check could have been done in many ways, but since I knew that the users who didn't have access to My Site Host was in a specific security group in AD, I chose to use an audience for "internal" and "external" users that I was already using for other purposes.

I use the IFormDelegateControlSource interface in my delegate control as this gives me the proper hook and object (in this case the relevant users SPListItem from user information list).

The code also includes the original code that I override (Microsoft.SharePoint.ApplicationPages.UserDisplayPage) that checks if a user is a person or group. To make sure that the user info list item view is used instead of the profile, I add a Force=true parameter to the query string. This is the OOB way of enforcing this view is used no matter if a User Profile Service is running on the farm.


    /// <summary>
    /// This class is called by a delegate control in AdditionalPageHead before the UserDisplayPage delegate control
    /// that takes care of redirection to My Site public profile.
    /// We want to short wire this redirection for users with no access to My Site Host
    /// </summary>
    public class RedirectToUserList : UserControl, IFormDelegateControlSource
        public void OnFormInit(object objOfInterest)


            CancelRedirect(objOfInterest as SPListItem);
        public void OnFormSave(object objOfInterest)
        protected void CancelRedirect(SPListItem item)
            if (item == null)
                // check if user is really a group
                var contentTypeId = (SPContentTypeId)item["ContentTypeId"];
                if (SPBuiltInContentTypeId.SharePointGroup.IsParentOf(contentTypeId))
                    string url = "people.aspx?MembershipGroupId=" + item.ID.ToString(CultureInfo.InvariantCulture);
                    string keyOrValueToEncode = base.Request.QueryString["Source"];
                    if (keyOrValueToEncode != null)
                        url = url + "&Source=" + SPHttpUtility.UrlKeyValueEncode(keyOrValueToEncode);
                    SPUtility.Redirect(url, SPRedirectFlags.Static | SPRedirectFlags.RelativeToLayoutsPage, HttpContext.Current);
                int id;
                // if user is member of "internal" audience redirect to MySite
                if (IsMember("internal"))
                    var context = SPServiceContext.Current;
                    var userProfileManager = new UserProfileManager(context);
                    if (userProfileManager == null)
                    if (userProfileManager != null && !string.IsNullOrEmpty(userProfileManager.MySiteHostUrl) && userProfileManager.UserExists(item.Name) )
                        if (int.TryParse(Request.QueryString["id"], out id))
                            SPUtility.Redirect(string.Format("{0}/Person.aspx?accountname={1}", userProfileManager.MySiteHostUrl, item.Name), SPRedirectFlags.Trusted, HttpContext.Current);
                // else force redirect to user list
                    bool force = false;
                    if (!bool.TryParse(Request.QueryString["force"], out force) || !force)
                        if (int.TryParse(Request.QueryString["id"], out id))
                            // force SharePoint to redirect to "hidden user list" instead of redirecting to My Site profile
                            SPUtility.Redirect(string.Format("userdisp.aspx?Force=True&ID={0}", id), SPRedirectFlags.Static | SPRedirectFlags.RelativeToLayoutsPage, HttpContext.Current);
            catch (SPException)
                // TODO: log
        private static bool IsMember(string audience)
            AudienceManager audienceManager = new AudienceManager(SPServiceContext.Current);
                // we dont use
                // audienceManager.GetAudience(audience);
                // since this requires elevation (calling index directly doesnt! )
                Audience internalAudience = audienceManager.Audiences[audience];
                return internalAudience.IsMember(SPContext.Current.Web.CurrentUser.LoginName);
            catch (AudienceArgumentException)
                // audience does not exist
                return false;




After creating this class, we need to include it in a feature using a delegate control (I use the Delegate Control Visual Studio item template from from CKSDev, but you can also use an Empty Element template):

<?xml version="1.0" encoding="utf-8"?>
<Elements xmlns="">
    ControlAssembly="Demo.SharePoint.Intranet.Controls, Version=, Culture=neutral, PublicKeyToken=ca4699af43726411"
    ControlClass="Demo.SharePoint.Intranet.Controls.CustomControls.RedirectToUserList" />

Also remember to set the safe controls on the delegate control so that the class is registered as safe. You do this on the properties panel of the delegate control:


Now we only need to add the SharePoint item to a feature (i made mine farm scoped) and deploy it to the farm!

Happy coding :)


Re: Redirect to User Info instead of My Site Public Profile

5. This post has several smart concepts. I actually liked the method you ready this post. A piece of writing is standard technique to verbal communication. It needed a talent to specific the thought clearly to the readers. Thanks again! I actually have some sensible work expertise with write my essay ( )and my words are clearly supported what I felt through such processes within the past
 on 5/28/2018 1:25 AM

nice one

I am going to trip with my family to the USA and I have always played sports. I like a roller skate, ice skate. I tried snowboarding and I fell more times because it was hard to learn to control both side edges
 on 7/3/2018 2:55 AM

great one

Impressive concepts about henry or dyson asked clients to recommend the better rugged as good old henry. Thanks for improving better information,you can get better help for others people decide.
 on 7/18/2018 5:48 AM


I love all the posts, I really enjoyed, I would like more information about this, because it is very nice., Thanks for sharing.
 on 1/11/2019 9:32 PM


I know you need status related to love, romance etc. I'm here to help you. I try to found the best WhatsApp status from the internet I hope you will shared them with your friends and family.
 on 1/26/2019 12:03 PM

Re: Redirect to User Info instead of My Site Public Profile

 on 2/7/2019 7:49 AM


 on 2/7/2019 7:51 AM

Add Comment


Body *

Migrated Source URL

Commentator Name

Commentator Email

BotCheck *

Are you human? What is the sum of fifty-two minus ten?