[Date Prev][Date Next] [Chronological] [Thread] [Top]

Re: Get binary with JNDI - maybe OT



In JNDI, you often need to add something to the environment you use to initialize the JNDI context in order to tell JNDI which attributes to treat as strings and which attributes are binary. This is very important since if you don't list a binary attribute in this environment variable and it is now a commonly known binary attribute (jpegPhoto for instance), you will likely get the value back in a corrupted or truncated way because JNDI will translate the bytes into UCS-2 encoded Java Strings.

Add something like:

env.put("java.naming.ldap.attributes.binary", "binattr1,binattr2,binattr3");

Clayton

On Dec 18, 2003, at 8:47 AM, Rudi Verago [[vlain]] wrote:

I have a directory where are save file in different formats.
In the beginning I use datahandler, after convert to byte[] and save on LDAP.
When I try to get with:
answer = ctx.getAttributes(rni,attr).get("dataBinary");
byte[] resultByte = ((byte[])answer.get());


I obtain cast exception, why?
If data are text file and I made a string cast I see it correctly.
Sorry for my English,
Thanks,

~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~