directory-api mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Kiran Ayyagari <kayyag...@apache.org>
Subject Re: Reading Binary Attributes
Date Wed, 04 May 2011 15:13:18 GMT
On Wed, May 4, 2011 at 8:24 PM, Daniel Fisher <dfisher@vt.edu> wrote:
> On Tue, May 3, 2011 at 4:07 PM, Kiran Ayyagari <kayyagari@apache.org> wrote:
>> Hi Daniel,
>>
>> On Wed, May 4, 2011 at 12:33 AM, Daniel Fisher <dfisher@vt.edu> wrote:
>>> Hello,
>>> I'm doing some testing with 1.0.0-M3 and I'm having trouble reading
>>> binary attributes.
>>> Specifically for jpegPhoto in OpenLDAP 2.4.23:
>>>
>>> # jpegPhoto
>>> # Used to store one or more images of a person using the JPEG File
>>> # Interchange Format [JFIF].
>>> attributetype ( 0.9.2342.19200300.100.1.60
>>>    NAME 'jpegPhoto'
>>>    DESC 'RFC2798: a JPEG image'
>>>    SYNTAX 1.3.6.1.4.1.1466.115.121.1.28 )
>>>
>>> the byte[] I get from Attribute#get()#getBytes() is about twice as big
>>> as I expect. Attribute#isHumanReadable() also returns true. Which
>>> makes me think the value has been encoded.
>>> Code snippet of what I'm doing:
>>>        while (cursor.next()) {
>>>          SearchResultEntry result = (SearchResultEntry) cursor.get();
>>>          Entry e = result.getEntry();
>>>          Attribute photo = e.get("jpegPhoto");
>>>          if (photo != null) {
>>>            byte[] bytes = photo.get().getBytes();
>>>            FileOutputStream fos = new FileOutputStream("photo.jpg");
>>>            fos.write(bytes);
>>>            fos.close();
>>>          }
>>>        }
>>>
>>> ldapsearch returns the value I expect. Is there some special syntax
>>> for binary values I'm missing? Thanks
>>>
>> this is due to the fact that by default the client connection is not
>> schema aware, to make it schema aware call loadSchema() method
>> of the connection before performing any operations.
>> Let us know if you still have any issues.
>> Thank you for testing.
>
> Thanks. After reviewing the source it appears that binary attributes
> are only supported with a schema aware connection. If you expose the
> BinaryAttributeDetector (maybe on LdapConnection) then clients could
> have some control without dealing with schemas. This would afford the
> same functionality that JNDI provides via the
> 'java.naming.ldap.attributes.binary' property. Just a thought.
>
don't know how JNDI detects the binary attributes, but in our case it is
done completely with the help of schema manager
> I also looked at the NetwokSchemaLoader and it uses a hard coded
> baseDn and filter. With a litte refactoring that class could also work
> against OpenLDAP, but currently it looks ApacheDS specific.
>
yes it is completely tied to the ApacheDS, the idea behind this loader is to
have the same schema elements that the server currently uses instead
of loading a
set of default schemas.

Another schema loader based on the data returned after querying
cn=subschema (this is the technique
which Apache Directory Studio uses) is ideal to make the client schema
aware while working with other servers.

May be we can port that code from Studio to API, studio folks wdyt? :)

-- 
Kiran Ayyagari

Mime
View raw message