Charset for ldap Attributes ? unicode ?
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Michael_Kloss
Posted On:   Wednesday, July 24, 2002 07:02 AM

After a ldap request i display all Attributes of a request. The Problem is that some Attributes only displayed from the beginning up to the first spezial chars (no ascii). And the chars behind are "deleted". No Exception! And all Atribute are instanceof String. Who I can get the complete String or Byte[] ? Why or Where I loose my Chars ? Do I get Unicode from JNDI ? Can I switch to a other charset ? Thanks Michael Kloß private void show(Attribute oneAttr) { try { for (NamingEnumeration e = oneAttr.getAll(); e.hasMore();) { Object o=e.nextElement(); if (o instanceof String) { System.out.println("String...&   More>>

After a ldap request i display all
Attributes of a request. The Problem is that
some Attributes only displayed from the beginning
up to the first spezial chars (no ascii).
And the chars behind are "deleted".
No Exception! And all Atribute are instanceof String.
Who I can get the complete String or Byte[] ?

Why or Where I loose my Chars ? Do I get Unicode
from JNDI ? Can I switch to a other charset ?

Thanks
Michael Kloß

			
private void show(Attribute oneAttr) {
try {
for (NamingEnumeration e = oneAttr.getAll(); e.hasMore();) {
Object o=e.nextElement();
if (o instanceof String) { System.out.println("String..."); }
System.out.println("A:"+oneAttr.getID()+"="+o);
}
}catch(NamingException e) { System.out.println("NamingException Err:"+e);}
}
   <<Less

Re: Charset for ldap Attributes ? unicode ?

Posted By:   Michael_Kloss  
Posted On:   Thursday, July 25, 2002 08:25 AM

I found myself a way, but not the answer.

Some Attributes are predefined as binary, such as "photo".
Use this to add own Attributes:

env.put("java.naming.ldap.attributes.binary", "ATTRIBUTENAMES");

ATTRIBUTESNAMES (space splitted) as binary.
Now tis attributes are interpreted as binary and
you get a class byte[] and create a
Unicode String with

Object o=e.nextElement();
Byte[] b=(byte[])o;
String name=new String(b);


Fount this at:

http://java.sun.com/products/jndi/tutorial/ldap/misc/attrs.html


But why cut the JNDI my String and I get no exception ?
About | Sitemap | Contact