Im currently customising the CoreResultsWebPart and using it to aggregate Blog posts. One of the default fields it returns is the Author field. The author field though, is crawled and displayed as the Display name of the user. Eg:

A users login name is 'mydomain\john.smith'

Their display name is 'John Smith'

Core results returns 'John Smith'.

I need to get the users login name so I can call a custom function in my xsl 'GetUserProfilePicture(string loginName)' to get the user's profile picture to be shown alongside their blog post summary.

This is the xml output from the search result...

<title>What a great post by sp user 1!</title>
<author_multival>S.P. User 1</author_multival>
<author>S.P. User 1</author>
  Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque laudantium, totam rem aperiam, eaque ipsa quae ab illo inventore veritatis et quasi architecto <ddd> </ddd>
  <hhtitle>What a great post by sp user 1!</hhtitle>
  <imageurl imageurldescription="List Item">/_layouts/images/STS_ListItem16.gif</imageurl>

As you can see above, the author is showing the display name. Below is the code I want to run...

<xsl:variable name="user" select="author"/>
<img align="absmiddle" src="{customxsl:GetUserProfilePictureURL($user)}" border="0" alt="Blog" />

public string GetUserProfilePictureURL(string username)
        string Url = string.Empty;

        if (!String.IsNullOrEmpty(username))
            if (upm.UserExists(username))
                UserProfile profile = upm.GetUserProfile(username);
                if (profile != null)
                    Url = profile["PictureURL"].Value.ToString();

        if (string.IsNullOrEmpty(Url))
            Url = "/_layouts/images/O14_person_placeHolder_96.png";

        return Url;

Anyone know how I can get the login name of the author? Any magic managed properties?

  • Have you thought about getting it via an LDAP query? Something like: PrincipalContext ctx = new PrincipalContext(ContextType.Domain); UserPrincipal user = UserPrincipal.FindByIdentity(ctx, displayName); I can expand if needed... – Bunzab Jan 21 '15 at 11:24

This article seems to describe a solution for you. It discusses the limitations of the default "Author" managed property, and then shows you how to create your own managed property that should be what you want.

  1. The XML schema for the Core Results Web Part (http://msdn.microsoft.com/en-us/library/ms560074(v=office.12).aspx). NOTE: There are some errors in this MSDN documentation link but there is a community section that lists out the default column in the core results XML

  2. The Author and Created By Managed Metadata Properties

The author field is mapped to a number of fields, including the metadata of an office document. When you create an Office document, there is certain information that office captures as “metadata” in the properties section of that document. The Author information is part of this information.

So essentially follow these steps to get a unique name into the Created By Managed property:

  1. Map the crawled property (Name: 4; Category: Office (aka Office:4) ) to the CreatedBy Managed property

  2. Remove the “ows_created_0×2400e_by” crawled property mapping from the CreatedBy property mapping. This crawled property is a left over from SP 2003 days and is not crawled anymore, except for SP 2003 content.

  3. Select the “Select the first property from the property list”. This will ensure that a unique author value is mapped to the “Created By” property (and multiple values are not returned in this property).

  4. Make sure to select refinement enabled, so that you can replace the default “Author” refinement filter with the “Created By” refinement filter.

  5. Save the CreatedBy Managed property

  6. Clear the content collection

  7. Reset the index

  8. Do a Full Crawl

  9. Run a Search, and you will see that the Created By field now contains the most current “Author” information and does not contain a long list of authors

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.