SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am using SharePoint KeywordQuery class to query SharePoints search. When processing the record set which is returned I need the userId/user profile of the user which created the entry.

I tried to use the "Author" property, but that seems to contain only the PreferredName of the user.

Do I need to manually map a new property to do this, or which metadata property do I need to include in the result set?

EDIT: I need a property from the search Index which contains the unique identifier (user id. record id, account name ...) for the user. The Author property seems to contain the preferred name and is not unique.

I am currently mapping AuthorUserId to the search index and adding this to my query, but there should be an easier way

share|improve this question

Select AccountName and use that. This will give you <domain>\<loginName>.

If necessary you can then load the SPUser from that with SPContext.Current.Web.EnsureUser(loginName)

EDIT: Here is how to use XSLT extension functions to retrieve SPUser from Author.

  • Create a public class with a public method called something like RenderUserName(string author) and create logic to fetch user name from accountname (depending on what properties you could go for UserProfile or SPUser)
  • Add a namespace to your XSLT <xsl:stylesheet> element, that matches the classname: xmlns:YourClass="urn:YourNameSpace"
  • In code call the function as any OOB function: <xsl:value-of select="YourClass:RenderUserName(Author)"/>. Note that you can also pass variables to functions using the $myVariablesyntax
share|improve this answer
I am not searching for people but usual list items. AccountName is not available for these kinds of items ... at least it is not included in the index by default. – foobarfoofoo Aug 18 '11 at 20:54
Author is a managed property, but requires that you fill it out (eg Welcome page). Did you actually put data into the Author page property? – Anders Rask Aug 18 '11 at 21:21
I do have data in the Authors field. But this field does not contain the account names or ids but the user name (the display name). And I don't think I can resolve the user profile from that. – foobarfoofoo Aug 18 '11 at 21:57
A ok, didnt read carefully :) you could use XSLT extension functions for this. See . When i get back to work ill throw in a sample – Anders Rask Aug 19 '11 at 5:46
ok sample added. let me know if you have questions – Anders Rask Aug 21 '11 at 16:10

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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