Tuesday, March 20, 2012

Redirecting User Profile Job Titles to a Term Set

The User Profile SPS-JobTitle property values are, in default User Profile service application configuration, stored in Managed Metadata service application Keywords term set. If your organization does not use the social networking functionalities of SharePoint 2010, you might not even recognize this behavior, but for those who allow and support using of content tagging can be this default behavior a bit irritating.

Why is this happening and what you can do with it? If you look at the SPS-JobTitle property settings, you can see that the check box for the option “Configure a Term Set to be used for this property” is ticked, but the field “Pick a Term Set for this property:” is empty. So this is why all the values are going directly to the Keywords, as it is the default and only term set in the “[System]” term group.

Figure 1: SPS-JobTitle property configuration
Now what to do with it? You may notice, that the check box for the option “Configure a Term Set to be used for this property” is also grayed, which means that you cannot uncheck it and disable use of a term set. I do not recommend to delete the SPS‑JobTitle property and create it again as it might have negative impact on the system stability and functionality in the future. So the only thing you can do is to create new term set, in the Managed Metadata service application, and select it in the “Pick a Term Set for this property:” control.

It looks simple, but isn’t. You should correctly configure the term set, otherwise the SPS-JobTitle property values will again fall into the Keywords. When a new term set is created its “Submission Policy” option is set to “Closed”. You have to select the option “Open” as the farm account under which is running the User Profile synchronization service is not a metadata manager. Your custom term set should be also configured as available for tagging.

Figure 2: Custom term set configuration
So how the term set update process actually looks like. The following snapshot of the ULS log shows that it is the Forefront Identity Manager (FIM) miiserver.exe process, which is creating the terms using the Managed Metadata web service.

Figure 3: ULS log sequence for job title synchronization
It seems that the FIM creates a temporary cache where stores all identified Active Directory Domain Services (AD DS) “title” attribute values. During the first “MOSS_EXPORT_<guid>” synchronization step will happen several things. If there is identified a new job title string, it is just added to the term store, but in case there is a new or updated AD user account with an existing job title, the process tries to create new term item anyway and fails with an exception. Following picture shows the sequence of the records in the ULS log.

Figure 4: Duplicated job title term creation ULS log
The new terms for the SPS-JobTitle property values are also by default created as available for tagging, which means that any user will get the job title strings as suggestions for his tags. This is usually unwanted behavior, as it does not make too much sense to tag content with job titles. Following image shows how the custom term set and included terms look after an incremental User Profile synchronization.

Figure 5: Custom term set after incremental synchronization
You can use a small PowerShell script to get over this issue and automatically change the “Available for Tagging” setting for each new job title term to not allow the term visibility as suggestion for tagging. Here is a little sample of such a script.

$termStoreName = "Main Managed Metadata Service"
$termGroupName = "Labnet General"
$termSetName = "Job Titles"
$caURL = "http://<central.admin.site:port>"

$caSite = Get-SPSite $caURL
$session = new-object Microsoft.SharePoint.Taxonomy.TaxonomySession($caSite, $True)
$termStore = $session.TermStores[$termStoreName]
$termGroup = $termStore.Groups[$termGroupName]
$termSet = $termGroup.TermSets[$termSetName]
foreach ($term in $termSet.Terms) {
    if ($term.IsAvailableForTagging -eq $True) {
        $term.IsAvailableForTagging = $False
        Write-Host "The term: " $term.Name " is set to be unavailable for tagging."

You might need to run such script just after each User Profile synchonization job is completed, as this approch will keep your content tags more consistent and not fouled up with various job titles.

No comments:

Post a Comment