Add this, it's barely documented and will save you hours of debugging: `ldap_set_option(NULL, LDAP_OPT_DEBUG_LEVEL, 7);`