directory-api mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Daniel Fisher <>
Subject Reading Binary Attributes
Date Tue, 03 May 2011 19:03:24 GMT
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 )

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 ( {
          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");

ldapsearch returns the value I expect. Is there some special syntax
for binary values I'm missing? Thanks

--Daniel Fisher

View raw message