Change display of user search suggestion

Good day,

We are using LDAP authentication and synchonizing XWiki users with the LDAP directory (Active Directory), which works very nicely.

We are mapping LDAP attributes as follows:


Some users have two accounts: A non-administrator account and an administrator account. The sn (last name) and givenName (first name) LDAP attributes are the same for both accounts.

This means that when I look up users in XWiki, I will see two entries for that person: One of the entries is the non-administrator account, and the other is the administrator account. Example:


Since both accounts have the same first and last name, it is not possible to distinguish between them.

Question: How can I change this search display to use display_name (I extended XWikiUsers class and added it) property instead of first and last name?

You could try to modify this line . Look for the uorgsuggest.vm Velocity template in your XWiki WAR. It’s best to overwrite this from the skin if you don’t want to loose the changes when upgrading the XWiki WAR.

1 Like

Great, thank you!

This displays XWiki username (without XWiki. prefix):

#set ($label = $xwiki.getDocument($reference).name)

This displays the full XWiki user name (XWiki.username):

#set ($label = $xwiki.getUser($xwiki.getDocument($reference)).name)

(I am a new user, and there may be more efficient way than the above.)

However, what I am trying, and is not working:

#set ($label = $xwiki.getUserName($xwiki.getUser($xwiki.getDocument($reference)).name, '$display_name', false))

Above line results in Unknown User for each result.

Am I doing this incorrectly?



I’ve resolved this a different way. I replaced:

#set ($label = $xwiki.getPlainUserName($reference))

with the following:

#set ($docref = $xwiki.getDocument($reference))
#if (($docref.last_name != '') && ($docref.first_name != ''))
  #set ($label = $docref.last_name + ', ' + $docref.first_name  + ' [' + $ + ']')
  #set ($label = $xwiki.getPlainUserName($reference))

This produces a display that will work for us (last name first, username at end of string).