SDI: Extract ISO country code from $dn

SDI: Extract ISO country code from $dn

Hi all,

last week a customer wanted IBM Connections metrics to display the country (region) where users come from that are using the system.

Okay I did that (also with help of the great metrics guide from Michael Urspringer). This worked quite well. The customer is not using the attribute “countryCode” to display country values. An extension attribute was created for that and this does not hold the countryCode but rather the full country name (e.g. Germany instead of DE). So we mapped that one but the LDAP quality that showed up was rather “bad”.

For example there are several different ways the country Australia is stored in the LDAP:

Australia / australia / AUSTRALIA /  …

Which leads us to the geographic metrics report:

Metrics 1


Cognos does interpret those values as “unique” counties. So that I see “53% others”. So 53 percent users from other countries. It is really hard to compute a real pattern out of this!

I wrote a small javascript function to compute the ISO country code from the users $dn value.

Function – to be inserted into profiles_functions.js:

//Extracting countrycode from dn
function func_gis_country(fieldname) {
var result = null;
var field = work.getString("$dn");
var re = /ou=(w+?),O=customer/i;
var country = null;
   if (field != null)
      var match = re.exec(field);
      if(match != null)
         country =  match[1];
task.logmsg("field " + field);
task.logmsg("country: " + country);
return country;

So we look at $dn of the user that is in form:


This means the “ou=DE” is stored for each user and the quality of this field is excellent because this attribute is written / stored always the same way.

Last step is to update the file to map the countryCode attribute to the generated js function:

Bildschirmfoto 2015-03-27 um 16.33.40

Leave a Reply

Your email address will not be published. Required fields are marked *