Tuesday, November 5, 2013

Lync 2010 Skill Search Configuration with SharePoint 2010 People Search

In this post I want to show you how to configure the skill search in Lync 2010. Lync uses the SharePoint Search Web Service to search after user skills.The skills are stored in the SharePoint User Profile Store.

Requirements

  • Lync Server (min. Standard)
  • SharePoint Server 2007 or later (No WSS or SharePoint Foundation)
  • Lync Client (No OCS)

Result

The final result looks like that:

Enter a skill you want to search, here "SharePoint".


Now click on Skill tab.

You'll get a list of users who entered SharePoint as skill in their profile.

1. How to edit your skills.

The skills are stored in the SharePoint User Profile Store. For that you have to enable and configure MySite in SharePoint. If MySite is enabled you can enter your profile page and edit your skills field.

First open your MySite. Then go to the top right corner on a SharePoint page and open the personal menu. Click on "My Profile"

Open My Profile Page
Now you enter the "My Profile" page in the MySite web application.

Click on "Edit My Profile" to edit your profile properties.



When you scroll down you'll see the "Skills" field. Here you can enter your skills for the skill search in Lync. Save your new skills and exit the page.

As the SharePoint 2010 search service is used. Your skills are not displayed immediately. You have to wait until the SharePoint search crawls your properties. The schedule for that is set individually by the SharePoint administrator.

2. Check if People Search is working

The next step is to test if the people search is working properly. For that open an existing search site in SharePoint or create a new search site with the Enterprise Search Template. You'll need the url of the search result site later for Lync. In my case the search result page has the url:

  • http://sharepoint-st/sites/search/pages/peopleresults.aspx. 

Please do not mix up the search page with the search result page. These are two pages with 2 different urls.

Search result page


Normally people search is a standard feature in SharePoint and don't need to be configured specially. If your  SharePoint people search is unlikely corrupt you only need the following settings:

  • A content source which crawls the user profiles. It must have a start address with the sps3 protocol: e.g. sps3://mysharepoint
  • A scope called "People" in your scopes with the rule "contentclass = urn:content-class:SPSPeople"

Now check also if the SharePoint Search Service can be called without problems. Type http://{yourwebbapp}/_vti_bin/search.asmx to display the service methods. If you see a list of service methods the service application is running.

3. Configure Lync 

Now we have to tell the Lync client where he can search for skill. Therefore it needs to know the url of the search service. For this Lync has client policies. 

In a client policy you can define what a Lync client can do and where he can find his connection stuff. You can see the client policy settings if you right click + CTRL on the Lync taskbar icon.





The best way to test skill search is to create a temporary Client Policy. Go to your Lync Server and open the "Lync Server Management Shell". To create a client policy type:

C:\>New-CSClientPolicy -Identity TempClientPolicy

To list all policy properties type:

C:\>Get-CSClientPolicy -Identity TempClientPolicy 

The important properties here are:
  • SPSearchInternalURL: The url of the search service
  • SPSearchExternalURL: The url of the search service for external users. Maybe you have a SharePoint in the DMZ for external users, then you have to enter this url here.
  • SPSearchCenterInternalURL: The URL of the search result page for people search. Lync needs this to create a link which opens the SharePoint Site. Usually in the SharePoint search results there are more information displayed.

  • SPSearchCenterExternalURL: The same for external Lync.

If not configured the SPSearch properies are empty


Now edit the properties with the SharePoint Search Service and People Result Page Infos. To edit a property open the Lync Management Console on the Lync Server and type (You have to be a Lync Administrator): 


C:\>Set-CSClientPolicy -Identity TempClientPolicy -SPSearchInternalUrl "http://sharepoint-st/_vti_bin/search.asmx"

C:\>Set-CSClientPolicy -Identity TempClientPolicy -SPSearchExternalUrl "http://sharepoint-st/_vti_bin/search.asmx"

C:\>Set-CSClientPolicy -Identity TempClientPolicy -SPSearchCenterInternalUrl "http://sharepoint-st/sites/search/pages/peopleresults.aspx"

C:\>Set-CSClientPolicy -Identity TempClientPolicy -SPSearchCenterExternalUrl "http://sharepoint-st/sites/search/pages/peopleresults.aspx"

The final result must be:

C:\>Get-CSClientPolicy -Identity TempClientPolicy 



Now assign the policy to a test user. You can do that with PowerShell or over the Lync Control Panel.

C:\> $user = Get-CSUser "domain\login"  
C:\> $user  
C:\> Grant-CsClientPolicy -Identity "domain\login" -PolicyName TempClientPolicy
C:\> $user 

Check on the displayed properties of the user if the client policy is assigned. You have to logout and login again to retrieve the new policy. Check the Lync configuration settings (CTRL + Right click on icon)  if the SharePoint properties are filled.



Things to pay attention to:
  1. There is a problem when calling the SharePoint 2010 Search Service and anonymous authentication is enabled. If the web application http://sharepoint-st has anonymous authentication enabled you would see "SharePoint people search failed. Please try again later. If the problem continues, contact the sysadmin". The best way to solve this issue may to create a seperate web application which uses the same search service application.
  2. As the url of the web service is http://sharepoint-st/_vti_bin/search.asmx you should grant all user at least read rights on the site collection (In this case the main site collection)
  3. Lync is calling the SharePoint Web Service with a predefined search query. In WireShark you can see the following xml:
    <QueryText language='en-US' type='string'>SharePoint scope:People</QueryText>
    That means you'll need the scope "People". Don't delete or rename the scope it if you want to use skill search.
  4. All 4 SPSearch client policy properties should be set. Sometimes if not all properties are set Lync throws an error that people search has failed.

5. Migrate the policy

In the last step you have to define which persons should have the ability to search after skills. You can edit the global client policy, create a site policy for a special Lync site or a single policy and assign the policy each user.

  1. Edit the global policy to assign every user this policy

    C:\>Set-CSClientPolicy -Identity global -SPSearchExternalUrl "http://sharepoint-st/_vti_bin/search.asmx"
    .
  2. Create a or edit site policy:

    C:\>New-CSClientPolicy -Identity site:IstanbulC:\>Set-CSClientPolicy -Identity site:Istanbul -SPSearchExternalUrl "http://sharepoint-st/_vti_bin/search.asmx"
    .
  3. The client policy for the skill search can also be configure on a user level

    C:\>New-CSClientPolicy Tag:Messi -SPSearchExternalUrl "http://sharepoint-st/_vti_bin/search.asmx"
    .
  4. Create a user policy: You have to create a new client policy like we did it in the example above. The next step is to create a script which loops through all the users assigns them the policy. This is the most complicated way because you have to assign the policy each time your company gets a new employee.

How does it work internally

Lync creates a search request for the SharePoint Search Web Service. The web service s attending a request in form of XML. Lync picks up the entered search word e.g. "Finance Controller" and creates the XML for the query:

<QueryPacket xmlns='urn:Microsoft.Search.Query'>
  <Query>
    <SupportedFormats>
      <Format>urn:Microsoft.Search.Response.Document:Document</Format>
    </SupportedFormats>
    <Context>
      <QueryText language='en-US' type='string'>Finance Controller scope:People</QueryText>
    </Context>
    <ResultProvider>SHAREPOINTSEARCH</ResultProvider>
    <Range>
      <StartAt>1</StartAt>
      <Count>21</Count>
    </Range>
    <Properties>      
     ....
   </Properties>
  </Query>
</QueryPacket>

In the request there is a xml section for properties. This section contains all the properties the requester wants to see in his results.

<Properties>
      <Property name="preferredname" HitHighLight="true"/>
      <Property name="jobtitle" HitHighLight="true"/>
      <Property name="department" HitHighLight="true"/>
      <Property name="officenumber" HitHighLight="true"/>
      <Property name="workemail" HitHighLight="true"/>
      <Property name="responsibility" HitHighLight="true"/>
      <Property name="sipaddress" HitHighLight="true"/>
      <Property name="pastprojects" HitHighLight="true"/>
      <Property name="interests" HitHighLight="true"/>
      <Property name="memberships" HitHighLight="true"/>
      <Property name="aboutme" HitHighLight="true"/>
      <Property name="hithighlightedsummary"/>
      <Property name="hithighlightedproperties"/>
      <Property name="path"/>
      <Property name="description"/>
      <Property name="write"/>
      <Property name="rank"/>
      <Property name="size"/>
      <Property name="yomidisplayname" HitHighLight="true"/>
      <Property name="orgnames" HitHighLight="true"/>
      <Property name="orgparentnames" HitHighLight="true"/>
      <Property name="baseofficelocation" HitHighLight="true"/>
</Properties>

We see that the request contains "SipAddress" and "WorkEmail". Lync uses this properties to create a relation the corresponding Lync user. If the SipAddress does not exist Lync uses the WorkEmail property to create a relation between the result and the Lync user.

Lync sends the request to configured (in the client policy) the SharePoint search service. The service response is also in XML format.

As there is only a restriction in scope this means that if you want you can create custom properties in SharePoint which could be also searched.

Error Handling

The error handling in Lync 2010 provides meaningful explanations about errors that are thrown from SharePoint. The following  illustrates the error messages that are displayed by Lync 2010 when the corresponding SharePoint error code is returned.



SharePoint Error Code
Corresponding Lync 2010 Error Message
ERROR_ALL_NOISE
Your query did not contain any words that can be searched. No results are available. Please enter a new query.
ERROR_NO_RESPONSE
Unable to connect to the server. Please try again later.
If the problem continues, contact your system administrator
ERROR_BAD_QUERY
SharePoint people search failed due to a malformed query.
ERROR_BAD_SCOPE
SharePoint people search failed due to a malformed query.
ERROR_BAD_REQUEST
SharePoint people search failed due to a malformed query.
ERROR_NO_RESULTS_FOUND
No results found.
ERROR_NO_QUERY
SharePoint people search failed due to a malformed query.
ERROR_NO_AUTHORIZATION
You do not have permissions to connect to the search server. Please contact your system administrator.

If Lync is unable to connect to SharePoint, one of the following error messages is displayed:
  • “Unable to connect to the server. Please try again later. If the problem continues, contact your system administrator.” This is a general error that is displayed when Lync 2010 cannot make a connection to SharePoint
  • “Skill Search is not available. Your system administrator might not have configured Skill Search to work using your current network, or there may be a problem accessing the SharePoint server.” This error message is displayed when one of the two in-band provisioning settings is not configured. If one of the two settings (SPSearchInternalURL or SPSearchExternalURL) is not configured properly, Lync 2010 cannot determine if the problem is related to network connectivity or to an improperly configured URL.

All other SharePoint error codes display the following error message: “SharePoint people search failed. Please try again later. If the problem continues, contact the system administrator.”


 Resources: