Hi Jess!

The problem here is that that Groovy LDAP uses JNDI under the hood. The same probem would occur with JNDI.
See: http://docs.oracle.com/javase/jndi/tutorial/ldap/misc/attrs.html (to be more precise: "Specifying Additional Nonstring Attributes")

Groovy LDAP works fine with binary attributes which are binary for JNDI by default (e.g. jpegphoto). "image" is not in the list, you have to add it manually.
In JNDI, you would set a property to specify which attributes are binary:

env.put("java.naming.ldap.attributes.binary", "image");
Later create JNDI InitialContext with env

The problem is that LDAP Groovy hides the creation of both the env and InitialContexts.

I see two (fast) options:
a) change Groovy LDAP source by yourself and add the env property in class LDAP (file LDAP.java, method createEnvironment())
b) add a jndi.properties file to the classpath, which would be mixed with the env Groovy LDAP uses

content of the file for b) only one line:


Please let me know if workaround b) works for you, or if you need more help.
We can add a feature to Groovy LDAP for that, which would make perfect sense to me.

Greetings from Hamburg,

Am 29.03.2013 06:19, schrieb Jess Johnson:
I'm having difficulty retrieving binary data from an OpenLDAP server and was hoping someone could point me in the right direction. I read on the message board that binary data comes back as incomplete or corrupted unless the client specifies what attribute is binary.

I wrote similar functionality in another language to test and everything worked as expected. I'm able to retrieve all other values (Strings) except binary data.

def ldap = org.apache.directory.groovyldap.LDAP.newInstance('ldap://some.server.com/ou=People,o=Acme')
ldap.eachEntry (filter: 'id=1234567') { entry ->
  def image = entry.image.getBytes()
new File('/var/dir/something.jpg').withOutputStream {
it.write image

Where would I specify the attribute "image" is binary?