Did you know ... Search Documentation:
Predicate ldap_initialize/2
 ldap_initialize(-LDAP, +URI) is semidet
Initialize the LDAP library and open a connection to an LDAP server.

Use ldap_get_ld_errno/1 to get last error.