openldap 自定義schema解決無法導入中文問題

報錯問題:


ldap_add: Invalid syntax (21)


在ldapadd的時候報錯了,如果你連英文都導入報這個錯的話,就是你ldif文件格式不對,網上有很多資料,自行查閱。


錯誤的schema:


attributetype (1.2.156.10197.6.1.2.301.2.1  NAME 'RMS-account'  DESC '賬號' EQUALITY caseIgnoreIA5Match SUBSTR caseIgnoreIA5SubstringsMatch SYNTAX 1.3.6.1.4.1.1466.115.121.1.26)


正確的schema:


attributetype (1.2.156.10197.6.1.2.301.2.1  NAME 'RMS-account'  DESC '賬號' EQUALITY caseIgnoreMatch SUBSTR caseIgnoreIA5SubstringsMatch SYNTAX 1.3.6.1.4.1.1466.115.121.1.15{128})




有沒有發現哪裏不對?


SYNTAX 符號類型不一樣是吧,那我們來看看這兩種符號代表的是什麼。


   IA5 String                      Y      1.3.6.1.4.1.1466.115.121.1.26


   Directory String             Y      1.3.6.1.4.1.1466.115.121.1.15




 IA5 String:


   ( 1.3.6.1.4.1.1466.115.121.1.26 DESC 'IA5 String' )



   The encoding of a value in this syntax is the string value itself.




Directory String:

   ( 1.3.6.1.4.1.1466.115.121.1.15 DESC 'Directory String' )

A string in this syntax is encoded in the UTF-8 form of ISO 10646 (a superset of Unicode).  Servers and clients MUST be prepared to receive encodings of arbitrary Unicode characters, including characters not presently assigned to any character set.

For characters in the PrintableString form, the value is encoded as the string value itself.

If it is of the TeletexString form, then the characters are transliterated to their equivalents in UniversalString, and encoded  in UTF-8


對比一下這兩個是不是發現了問題的所在呢?


還有一個要注意的地方就是1.15要使用caseIgnoreMatch,不能使用IA5的。不然編譯schema文件的時候就會報錯。


最後送一條簡單粗暴的命令:rm -rf /etc/openldap/slapd.d/* && slaptest -f /etc/openldap/slapd.conf -F /etc/openldap/slapd.d/  &&  chown -R ldap.ldap /etc/openldap/slapd.d/ && /etc/init.d/slapd restart


免得每次改一次schema測試就那麼麻煩做那麼多操作。


然後再導入中文就OK了。

--------------------- 

作者:newlife_ninetonine 

來源:CSDN 

原文:https://blog.csdn.net/newlife_ninetonine/article/details/80507885 

版權聲明:本文爲博主原創文章,轉載請附上博文鏈接!


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章