Re: Newbie ldaplib questions

Jochen Keutel (
Wed, 25 Sep 1996 09:31:52 +0200 (MESZ)


> 1, binary data
> ldap_get_values returns a char ** which means that essentially all values
> are regular null terminated strings, but a jpeg photo (or audio or whatever
> kind of binary data) is certainly not. (or is it?) How can I retrieve such
> data and present it correctly? Is it stored as several values, or is it
> just one value. max.500 does it nicely, but I haven't been able to trace
> where it all happens...

For binary data you shouldn't use ldap_get_values() - use ldap_get_values_len()
instead. See the man page for ldap_get_values():

If the attribute values are binary in nature, and thus not suitable
to be returned as an array of char *'s, the ldap_get_values_len()
routine can be used instead. It takes the same parameters as
ldap_get_values() , but returns a NULL-terminated array of pointers
to berval structures, each containing the length of and a pointer
to a value.

> 2, charsets
> How do I know which charset a string is encoded in when I fetch it from the
> server? OK, values are encoded as IA5Strings, ASCII, but certainly I should
> be able to store and retrieve values such as P=E4r =D6sbr=E5ng, right! Could
> anybody steer me towards the relevant URL/RFC, please!

(Sorry - I return your characters coded (quoted-printable) ...)
A LDAP string is defined as an octet string - so you are able to store
arbitrary octets in a (single) LDAP server.
If you are using LDAP to access a X.500 server: X.500 stores directory strings
as either Printable or T.61 (X.500 (88)). When you retrieve an attribute
(for example, surname) from the server via LDAP you'll get it as an
octet string - coded as T.61. You can switch on translation into
ISO8859-x (latin1, ...) with either:
- setting appropriate definitions in ldap-3.3/Make-common when compiling
the LDAP source
- calling routines like ldap_enable_translation(),
ldap_set_string_translators(), ldap_translate_from_t61(), ...

The file in the LDAP distribution doing this convertion is

Hope this helps.

Dr. Jochen Keutel currently at: Deutsche Telekom
duerr com-soft IZ Darmstadt

Phone: +49 6151 818 579

X.400 : /C=de/A=dbp/P=telekom400/O=dmst03/OU1=08/S=osys-02