- PR -

LDAPに日本語の属性値を登録することができない

1
投稿者投稿内容
xyz
会議室デビュー日: 2002/12/26
投稿数: 9
投稿日時: 2003-05-16 11:57
LDAPに個人情報を登録するプログラムを作っていますが、
属性地に日本語を登録することができません。

コード:
    String s = "ほげ";
    byte[] buf = s.getBytes("UTF8");

    ByteArrayInputStream bis = new ByteArrayInputStream(buf);
    ByteArrayOutputStream bos = new ByteArrayOutputStream();
    BASE64Encoder encoder = new BASE64Encoder();
    encoder.encode(bis, bos);

    byte[] buf2 =  bos.toByteArray();
    bis.close();
    bos.close();

    Attribute cn = new BasicAttribute("cn");
    cn.add(buf2);


LDAP Browser/Editorで見ると"ほげ"ではなく"44G744GS"と表示されてしまいます。
日本語を登録する方法を教えてください。
よろしくお願いします。
ぽん
大ベテラン
会議室デビュー日: 2003/05/13
投稿数: 157
投稿日時: 2003-05-16 13:23
  String s = "ほげ";

  Attribute cn = new BasicAttribute("cn");
  cn.add(s);
--------------------------------------------
で良いんじゃないでしょうか?

後、日本語で値を入れるなら「cn」より「cn;lang-ja」の方が良いと思います。

[ メッセージ編集済み 編集者: ぽん 編集日時 2003-05-16 13:25 ]
xyz
会議室デビュー日: 2002/12/26
投稿数: 9
投稿日時: 2003-05-16 14:09
String s = "ほげ";
Attribute cn = new BasicAttribute("cn;lang-ja");
cn.add(s.getBytes("UTF8"));
--------------------------------------------
で登録できました。
ぽんさんありがとうございました。

[ メッセージ編集済み 編集者: xyz 編集日時 2003-05-16 14:10 ]

[ メッセージ編集済み 編集者: xyz 編集日時 2003-05-16 14:12 ]
1

スキルアップ/キャリアアップ(JOB@IT)