You need to set the cred pointer to an empty struct berval instead of NULL for an anoynmous bind:
cred.bv_val = NULL; cred.bv_len = 0; ldap_sasl_bind_s(ldapConn, NULL, LDAP_SASL_SIMPLE, &cred, NULL, NULL, NULL);
Ah, ok. That works. I was confused by this in sasl.c:
113 | } else if ( cred == NULL || cred->bv_val == NULL ) { 114 | | /* SASL bind w/o credentials */ 115 | | rc = ber_printf( ber, "{it{ist{sN}N}" /*}*/, 116 | | | id, LDAP_REQ_BIND, 117 | | | ld->ld_version, dn, LDAP_AUTH_SASL, 118 | | | mechanism );
But I shouldn't be looking at the lib internals I guess, but the above isn't doing a LDAP_SASL_SIMPLE then.
Thanks.