随 Sun Java System Communications Services 一起发行的所有客户端产品都允许用户搜索企业目录及其各自的通讯录。虽然这项功能发挥了作用,但可能仍需做一些 LDAP 调整来改善用户体验。
此部分将介绍:
无论您使用的是 Communications Express 还是 Connector for Microsoft Outlook,在您的个人联系人或公共通讯录中搜索某个字符串都是一个语言环境特定的操作。例如,搜索 "Gaelle" 的法文用户不但希望获得包含字符串 "Gaelle" 的返回条目,而且还希望获得包含字符串 "Ga?lle" 的任何条目。
用于控制基于语言环境向用户显示条目的方式的各种规则称为排序规则或排序顺序。排序顺序用于提供有关对给定语言的字符如何排序的语言和文化特定的信息。它可以确定字母在字母表中的顺序、如何比较有重音符的字母与没有重音符的字母以及比较字符串时是否存在可以忽略的字符。排序顺序还考虑到了与语言有关的文化特定的信息,例如阅读语言的方向(从左到右、从右到左或者从下到上和从上到下)。
Sun Java System Directory Server 支持各种语言环境和排序规则(请参见《Sun Java System Directory Server 5 2005Q1 Administration Reference》中的 "Identifying Supported Locales")。根据用户库的不同,您首先需要选择在环境中最有意义的语言环境。下面我们将使用英文(美国)语言环境 (OID = 1.3.6.1.4.1.42.2.27.9.4.34.1) 来举例说明。
要指定执行搜索时使用的语言环境,请使用匹配的规则过滤器语法,如《Sun Java System Directory Server 5 2005Q1 Administration Reference》中的 "Searching an Internationalized Directory" 所述。此语法使您可以指定语言环境以及搜索类型(等同、子字符串等等)。
例如,以下过滤器使用英文(美国)排序规则 (1.3.6.1.4.1.42.2.27.9.4.34.1) 对 CN 属性执行子字符串比较 (.6)。过滤器将在 CN 中查找以 "Gae" 为开头的字符串
cn:1.3.6.1.4.1.42.2.27.9.4.34.1.6:=Gae*
执行 LDAP 搜索时,大多数性能问题都是由没有索引或未正确配置索引造成的。在默认情况下,Directory Server 已配置,以便为 Communications Express 或 Connector for Microsoft Outlook 发出的查找编制索引并能够在合理的时间范围内返回索引结果。然而,Directory Server 没有设置国际化搜索。因此,用户必须改变现有索引才能使用选定的排序规则。《Sun Java System Directory Server 5 2005Q1 Administration Guide》中的 "Managing Indexes" 部分中介绍这一操作过程。
例如,CN 属性在默认情况下按 userRoot 后缀编制索引:
# ldapsearch -D "cn=Directory manager" -b "cn=cn,cn=index,cn=userRoot,cn=ldbm database,cn=plugins,cn=config" "objectclass=*" cn=cn,cn=index,cn=userRoot,cn=ldbm database,cn=plugins,cn=config objectClass=top objectClass=nsIndex cn=cn nsSystemIndex=false nsIndexType=pres nsIndexType=eq nsIndexType=sub
要使其能够应用英文(美国)排序规则进行国际化搜索,请添加一个具有英文(美国)OID 的 nsMatchingRule 属性。客户端将执行子字符串搜索,因此必须向 OID 中添加子字符串后缀 (".6"):
#ldapmodify -D "cn=Directory manager" dn: cn=cn,cn=index,cn=userRoot,cn=ldbm database, cn=plugins,cn=config changetype: modify add: nsMatchingRule nsMatchingRule: 1.3.6.1.4.1.42.2.27.9.4.34.1.6
请不要在该值的开头或结尾处添加任何空格、制表符或其他非可见字符。
nsMatchingRule 是一个多值属性。可以添加对同一个 OID 或不同 OID 的各种类型的搜索。
然后用户必须运行位于 serverroot/slapd-instance 中的 db2index.pl 脚本:
# perl db2index.pl -D "cn=Directory Manager" -w \ secret -n userRoot -t cn
此操作是联机运行的,可能要花费一段时间才能完成。另外,可以重新初始化后缀。请参见《Sun Java System Directory Server 5 2005Q1 Administration Guide》中的 "Reinitializing a Suffix"。
控制台还可用于添加 nsMatchingRule(请参见《Sun Java System Directory Server 5 2005Q1 Administration Guide》中的 "Managing Indexes" 部分)。
在以下各节中,提供了需要修改的索引列表。请确保未执行任何非索引搜索。您可以通过查看 Directory Server 访问日志文件(并在搜索结果条目中查找 =U 的注释)来进行监控。
Communications Express 所使用的搜索过滤器需要更改才能应用匹配的规则语法。通过启用在 db_config.properties 文件(对于个人存储,该文件位于 deployed-path/WEB-INF/ldappstore 中;对于企业目录,该文件位于 deployed-path/WEB-INF/corp-dir 中)中指定的排序规则参数可以实现此过程。
参数如下:
# Collation Rule # Uncomment below to apply collation rule # collation_rule=en-US # Search Fields for which collation rule should be applied. # The fields provided here should be disambiguator formatted fields # e.g. entry/displayname, person/givenname etc. # Uncomment below to supply the comma-separated fields # search_fields=entry/displayname
取消 collation_rule 和 search_fields 参数的注释即可启用排序规则。要在搜索中指定一组单独的字段或字段集,请将 search_fields 的值更改为所需值。collation_rule 可以在后缀没有指明搜索类型的情况下包含对应于该语言的语言标记与 OID(例如 1.3.6.1.4.1.42.2.27.9.4.34.1)。必须在做出更改后启动 Web 容器实例。
必须为 LDAP 服务器上的以下属性编制索引才能对 Communications Express 执行国际化搜索:
cn(使用 ou=people/ou=groups 后缀)
displayname(使用 o=piServerDb 后缀)
Connector for Microsoft Outlook 可以配置为使用 DN 和密码的绑定,也可以配置为匿名绑定。要启用对企业目录的匿名访问,请在 ou=people/ou=group 子树的根级别上添加 ACL。
例如,如果根级别为 dc=red,dc=sesta,dc=com,请做出以下设置:
#ldapmodify -D "cn=Directory manager" dn: dc=red,dc=sesta,dc=com changetype: modify add: aci aci: (targetattr != "userPassword") (version 3.0;acl "Anonymous access"; allow (read,compare,search) (userdn = "ldap:///anyone");)
本 7 2005Q4 发行版中的新增功能,Connector for Microsoft Outlook 现已允许最终用户浏览目录。当打开通讯录页面时,将显示目录中的前 10 个条目。然后,用户可以向上和向下滚动查看,也可以键入一些字符以查看自动刷新的结果。这是与先前版本的 Connector for Microsoft Outlook 的不同之处,用户使用那些先前版本时只能搜索一个特定的用户。
要启用此功能,同时还要保持良好的性能,连接器需要使用两种 LDAP 控制扩展功能:虚拟列表视图 (Virtual List View, VLV) 和服务器端搜索结果排序 (Server Side Sorting of Search Results) (RFC 2891)。以下 ldapsearch 示例将返回支持的控制列表:
# ldapsearch -s base "objectclass=*" supportedControl supportedControl=2.16.840.1.113730.3.4.2 supportedControl=2.16.840.1.113730.3.4.3 supportedControl=2.16.840.1.113730.3.4.4 supportedControl=2.16.840.1.113730.3.4.5 supportedControl=1.2.840.113556.1.4.473 ------> Server Side Sort Control supportedControl=2.16.840.1.113730.3.4.9 ------> VLV Control supportedControl=2.16.840.1.113730.3.4.16 supportedControl=2.16.840.1.113730.3.4.15 supportedControl=2.16.840.1.113730.3.4.17 supportedControl=2.16.840.1.113730.3.4.19 supportedControl=1.3.6.1.4.1.42.2.27.9.5.2 supportedControl=1.3.6.1.4.1.42.2.27.9.5.6 supportedControl=2.16.840.1.113730.3.4.14 supportedControl=1.3.6.1.4.1.1466.29539.12 supportedControl=2.16.840.1.113730.3.4.12 supportedControl=2.16.840.1.113730.3.4.18 supportedControl=2.16.840.1.113730.3.4.13
Sun Java System Directory Server 支持使用这两种控制机制。不过,在默认情况下,VLV 控制仅适用于通过验证的客户:
ldapsearch -D "cn=Directory Manager" -b \ "oid=2.16.840.1.113730.3.4.9,cn=features,cn=config" \ "objectclass=*" aci oid=2.16.840.1.113730.3.4.9,cn=features,cn=config \ aci=(targetattr != "aci")(version 3.0; acl "VLV Request Control"; \ allow( read, search, compare, proxy ) userdn = "ldap:///all";)
要允许匿名访问 VLV 控制,请添加相应的 ACI:
#ldapmodify -D "cn=Directory Manager" \ dn: oid=2.16.840.1.113730.3.4.9,cn=features,cn=config \ changetype: modify add: aci aci: (targetattr !="aci")\ (version 3.0; acl "VLV Request Control"; allow (compare,read,search) \ userdn = "ldap:///anyone"; )
要提高要求同时使用 VLV 和排序的搜索性能,请在 Directory Server 中建立浏览索引(如《Sun Java System Directory Server 5 2005Q1 Administration Guide》中的 "Managing Browsing Indexing" 所述)。每个浏览索引均特定于一个基本 DN、搜索过滤器、范围以及排序属性。可以在客户端使用部署配置工具调整 VLV 设置。
在特殊情况下,如果基本 DN 为 dc=red,dc=iplanet,dc=com、过滤器为 (&(mail=*)(cn=*)),并对 cn 属性进行排序,则需要建立浏览索引。浏览索引信息将被添加到包含基本 DN(在本例中为 userRoot)的配置中:
#ldapmodify -D "cn=Directory Manager" dn: cn=Browsing red.sesta.com,cn=userRoot, cn=ldbm database,cn=plugins,cn=config changetype: add objectClass: top objectClass: vlvSearch cn: Browsing red.sesta.com vlvbase: dc=red,dc=sesta,dc=com vlvscope: 2 vlvfilter: (&(mail=*)(cn=*)) aci: (targetattr="*") (version 3.0; acl "VLV for Anonymous"; allow (read,search,compare) userdn="ldap:///anyone";) dn: cn=Sort by cn, cn=Browsing red.sesta.com,cn=userRoot, cn=ldbm database,cn=plugins,cn=config changetype: add objectClass: top objectClass: vlvIndex cn: Sort by cn vlvSort: cn
接下来运行位于 serverroot/slapd-instance 中的 vlvindex 命令:
# ./vlvindex -n userRoot -T "Sort by cn"