When using SSL connections ot an ldap server (active directory) the ldap functions worked with non-SSL connections but not with ldaps connections. I believe this is because I was using the hostname of the LDAP server rather than the service name and thus the SSL certificate did not match the server name I was using. To resolve this I editied:
/etc/ldap/ldap.conf
or
/etc/openldap/ldap.conf
and added the following line (to ignore the SSL certificate warning):
TLS_REQCERT never
Restart Apache for the setting to take effect.