Last + First name searches in Lync/Skype4B Address Book (GalContacts.db)

In a previous post in Joe Calev's WebLog, we were shown how to enable Last + First name searches in Lync Server:

How to enable last name, first searches in Lync Address Book
http://blogs.msdn.com/b/jcalev/archive/2012/06/06/how-to-enable-last-name-first-searches-in-lync-address-book.aspx

That workaround works for WebSearchAndFileDownload and FileDownloadOnly — what we basically need is the GalContacts.db file.

Recently, Joe Calev's workaround was introduced in Lync Server 2013 (October 2014 Cumulative Update) and it is also present in the Skype for Business Server 2015 RTM version. For the Lync Server 2010 pools, we need to follow Joe Calev's post.

The RtcAbAttributeIndexRules.xml file is located — in a default Lync/Skype4B Server installation — in the following folders:

Lync Server 2010
C:\Program Files\Microsoft Lync Server 2010\Server\Core

Lync Server 2013
C:\Program Files\Microsoft Lync Server 2013\Server\Core

Skype for Business Server 2015
C:\Program Files\Skype for Business Server 2015\Server\Core

In Joe Calev's post, we are proposed to use the following:

[code language="xml"]
<attribute name="displayName">
  <indexRules>
    <indexRule id="displayName_rule_01">
      <description>
        <![CDATA[
          Index displayName as-is
        ]]>
      </description>
      <valuePattern>
        <![CDATA[^.*$]]>
      </valuePattern>
      <indexValues>
        <indexValue>
          <![CDATA[$0]]>
        </indexValue>
      </indexValues>
    </indexRule>
    <indexRule id="displayName_rule_02">
    <description>
      <![CDATA[
          Handle last name first name searches
      ]]>
    </description>
    <valuePattern>
        <![CDATA[(.+)(\s+)(.+)]]>
      </valuePattern>
      <indexValues>
        <indexValue>
          <![CDATA[$3 $1]]>
        </indexValue>
      </indexValues>
    </indexRule>
  </indexRules>
</attribute>
[/code]

However, the final version is:

[code language="xml"]
 <attribute name="displayName">
      <indexRules>
        <indexRule id="displayName_rule_01">
          <description>
            <![CDATA[
              Index displayName as-is
            ]]>
          </description>
          <valuePattern>
            <![CDATA[^.*$]]>
          </valuePattern>
          <indexValues>
            <indexValue>
              <![CDATA[$0]]>
            </indexValue>
          </indexValues>
        </indexRule>
        <indexRule id="displayName_rule_02">
          <description>
            <![CDATA[
              Allow search without middle name
            ]]>
          </description>
          <valuePattern>
            <![CDATA[^([^\s]+).*\s([^\s]+)$]]>
          </valuePattern>
          <indexValues>
            <indexValue>
              <![CDATA[$1 $2]]>
            </indexValue>
          </indexValues>
        </indexRule>
        <indexRule id="displayName_rule_03">
          <description>
            <![CDATA[
              Handle last name first name searches
            ]]>
          </description>
          <valuePattern>
            <![CDATA[(.+)(,+)(.+)]]>
          </valuePattern>
          <indexValues>
            <indexValue>
              <![CDATA[$3 $1]]>
            </indexValue>
          </indexValues>
        </indexRule>
      </indexRules>
    </attribute>
 [/code]

The main difference is that we have an additional rule to allow search without a middle name:

[code language="xml"]
<indexRule id="displayName_rule_02">
          <description>
            <![CDATA[
              Allow search without middle name
            ]]>
          </description>
          <valuePattern>
            <![CDATA[^([^\s]+).*\s([^\s]+)$]]>
          </valuePattern>
          <indexValues>
            <indexValue>
              <![CDATA[$1 $2]]>
            </indexValue>
          </indexValues>
        </indexRule>
 [/code]

This will work wherever you have a Display Name like 'Paulino', 'David' or 'David Paulino' in the Active Directory.

Here are some examples:

Display Name: Augustus Cole

AddressBookFLN01

AddressBookFLN02

Display Name: High Priest Skorge

AddressBookFLN03

AddressBookFLN04

Display Name: Carmine, Benjamin

AddressBookFLN07

AddressBookFLN08

Display Name: Carmine, Anthony (COG)

AddressBookFLN05

AddressBookFLN06