Use the Source, Luke.

How do you set LDAP protocol version 3?

LDAP* ld;
int protocol;

ld=ldap_init("host", LDAP_PORT);
protocol=LDAP_VERSION3;
ldap_set_option(ld, LDAP_OPT_PROTOCOL_VERSION, &protocol);

that's how. I had to dig through the ldapsearch code to find that one out. Not that it's hard to do that, but please.

wouter@rock:~$ man ldap_set_option
No manual entry for ldap_set_option

You can do better. I know you can. Yes, you, the one who wrote the libldap2 manpages.

wouter@rock:~$ man ldap
Reformatting ldap(3), please wait...
[...]
CONTROLS
       This  library supports both LDAP Version 2 and Version 3, with the Ver-
       sion 2 protocol selected by default.  LDAP Version 3 operations can  be
       extended  through the use of controls. Controls can be sent to a server
[...]

And no further mention of protocol version 3. That's helpful. Right.