隨 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」)。依據您的使用者基底,首先需要選擇在您的環境中有效的語言環境。在下面,我們將使用英文 (US) 語言環境 (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」所述。此語法讓您指定語言環境及搜尋類型 (完全對等、子字串等)。
例如,以下篩選器將使用英文 (US) 比較規則 (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
若要使用英文 (US) 比較規則的國際搜尋使用它,請增加一個具有英文 (US) OID 的 nsMatchingRule 屬性。由於是用戶端執行子字串搜尋,因此需要將子字串字尾 (「.6」) 增加至 OID:
#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 存取記錄檔 (並在搜尋結果項目中查找 notes=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 Server 上為以下屬性建立索引以用於搜尋 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 版本的變更,在該版本中使用者僅能搜尋一個特定使用者。
若要在保持良好效能的同時啟用此功能,連接器依靠兩個名為 Virtual List View (VLV) 和 Server Side Sorting of Search Results (RFC 2891) 的 LDAP 控制延伸。以下 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 plus Sort 之搜尋的效能,請在 Directory Server 中建立瀏覽索引 (如「Sun Java System Directory Server 5 2005Q1 Administration Guide」的「Managing Browsing Indexing」中所述)。每個瀏覽索引特定於一個基底 DN、搜尋篩選器、範圍和排序屬性。可以使用部署配置工具在用戶端方調校 VLV。
在此特殊情況下,需要使用 cn 屬性上的排序為等價於 dc=red,dc=iplanet,dc=com 的基底 DN、等價於 (&(mail=*)(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"