Tuesday Jan 27, 2009

Internationalized Searches in OpenDS

Those who are interested in running internationalized searches (collation rules) against OpenDS may want to note that this feature is now available in the Trunk. For those who are unaware of what I am talking about, I will explain what is a collation rule and how does it work with OpenDS. For more information, kindly look at : https://www.opends.org/wiki/page/I18NCollationRules.


What is a Collation rule:


Collation rule is a kinda matching rule which allows one to do the equality, substring and other order-based searches. Each collation rule is based upon a Locale. Going by a simple calculation, the number of collation rules = number of supported locales \* 6 ( equality,substring,less than, less than or equal to, greater than, greater than or equal to).


Note that the supported locales vary from one JVM implementation to the other. If you look at the config.ldif, you would notice that some of the locales have commented out:



dn: cn=Collation Matching Rule,cn=Matching Rules,cn=config
objectClass: top
objectClass: ds-cfg-matching-rule
objectClass: ds-cfg-collation-matching-rule
cn: Collation Matching Rule
ds-cfg-java-class: org.opends.server.schema.CollationMatchingRuleFactory
ds-cfg-enabled: true
ds-cfg-matching-rule-type: equality
ds-cfg-matching-rule-type: less-than
ds-cfg-matching-rule-type: less-than-or-equal-to
ds-cfg-matching-rule-type: greater-than
ds-cfg-matching-rule-type: greater-than-or-equal-to
ds-cfg-matching-rule-type: substring
#ds-cfg-collation: af:1.3.6.1.4.1.42.2.27.9.4.1.1
#ds-cfg-collation: am:1.3.6.1.4.1.42.2.27.9.4.2.1
ds-cfg-collation: ar:1.3.6.1.4.1.42.2.27.9.4.3.1
ds-cfg-collation: ar-AE:1.3.6.1.4.1.42.2.27.9.4.4.1

For example, the Locale "af" is not supported by the Sun's JVM. The above configuration shows that the Collation matching rules are enabled
and all 6 types of rules are requested by the administrator.

How it works?

OpenDS uses Java-based Collator APIs for supporting this functionality. See an example below:

//Creates a Collator for the specified Locale.
private Collator createCollator(Locale locale)
{
Collator collator = Collator.getInstance(locale);
collator.setStrength(Collator.PRIMARY);
collator.setDecomposition(Collator.FULL_DECOMPOSITION);
return collator;
}

A Collator object is obtained per Locale and it is used in the PRIMARY and FULL_DECOMPOSITION mode.

Usage
=====


Usage and Examples


As described above, an international search filter may contain
Locale OID (ex. 1.3.6.1.4.1.42.2.27.9.4.34.1), Locale name (en or
en-US) or an exact matching rule type with suffix ( ex.
1.3.6.1.4.1.42.2.27.9.4.34.1.3 or en.eq). Note that a Locale name or
Locale OID without any suffix is treated as an equality type. For
example, a filter such as "cn:en-US:=sanchez" will use an equality
matching rule type.



Some examples below demonstrate how to use this feature.


Equality Search



The following search uses a filter with the en (en-US) Locale OID to perform an equality search:


ldapsearch -D "cn=directory manager" -w password -b "o=test" "cn:1.3.6.1.4.1.42.2.27.9.4.34.1:=sanchez"


Above search should return the entry which has a cn value of SÃnchez.


Alternatively, you can use the following filters:



  • "cn:en:=sanchez"



  • "cn:en.3:=sanchez"



  • "cn:en.eq:=sanchez"



  • "cn:1.3.6.1.4.1.42.2.27.9.4.34.1.3:=sanchez"



Less Than Search



The following search uses a filter with the es (es-ES) Locale and performs a Less-than search:


ldapsearch -D "cn=directory manager" -w password -b "o=test"
"departmentnumber:1.3.6.1.4.1.42.2.27.9.4.49.1.1:=abc120"


Above search should return the entry which has a departmentnumber value as Ãbc119.


Alternatively, you can use the following filters:



  • "departmentnumber:es.1:=abc120"



  • "departmentnumber:es.lt:=abc120"



Less Than or Equal To Search



The following search uses a filter with the es (es-ES) Locale and performs a Less-than-or-equal-to search:


ldapsearch -D "cn=directory manager" -w password -b "o=test"
"departmentnumber:1.3.6.1.4.1.42.2.27.9.4.49.1.2:=abc119"


Above search should return the entry which has a departmentnumber value as Ãbc119.


Alternatively, you can use the following filters:



  • "departmentnumber:es.2:=abc119"



  • "departmentnumber:es.lte:=abc119"



Greater Than or Equal To Search



The following search uses a filter with the fr (fr-FR) Locale and performs a Greater-than-or-Equal-To search:


ldapsearch -D "cn=directory manager" -w password -b "o=test"
"departmentnumber:fr.4:=abc119"


Above search should return an entry which has a departmentnumber value as Ãbc119.


Alternatively, you can use the following filters:



  • "departmentnumber:1.3.6.1.4.1.42.2.27.9.4.76.1.4:=abc119"



  • "departmentnumber:fr.gte:=abc119"



Greater Than Search



The following search uses a filter with the fr (fr-FR) Locale and performs a Greater-than search:


ldapsearch -D "cn=directory manager" -w password -b "o=test"
"departmentnumber:fr.5:=abc119"


Above search should not return an entry which has a departmentnumber value as Ãbc119.


Alternatively, you can use the following filter:



  • "departmentnumber:1.3.6.1.4.1.42.2.27.9.4.76.1.5:=abc119"



  • "departmentnumber:fr.gt:=abc119"



Substring Search



The following search uses a filter with the en (en-US) Locale and performs a substring search:


ldapsearch -D "cn=directory manager" -w password -b "o=test" "sn:en.6:=\*u\*bec"


Above search should return an entry which as an sn value as Québec.


Alternatively, you can use the following filter:



  • "sn:1.3.6.1.4.1.42.2.27.9.4.34.1.6:=\*u\*bec"



  • "sn:en.sub:=\*u\*bec"



I will provide more information about the indexing in the next post.

About

This is the blog of a software engineer, specialized in identity management. Kunal Sinha works in Directory Services Engineering (OpenDS) team from Austin,Texas.

Search

Archives
« April 2014
SunMonTueWedThuFriSat
  
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
   
       
Today
Bookmarks