Wednesday, April 25, 2007

PHP - LDAP over SSL

I recently had a great deal of difficulty authorizing users over a PHP site using LDAP with SSL.

The server would connect when not using SSL, but as soon as I added the port 636 to the ldap_connect() function as the second argument (ldap_connect("server1", 636)) I would get an error 81 Can't connect to ldap server.

After exhaustive research I tried using ldap_connect("ldaps://server1") and low and behold it connected perfectly.

If you are having similar problems, you may want to try above. If this also doesn't work, try changing your hostname to IP address, but keep the ldaps://

3 comments:

viVe said...

hi do you need to install certificate for the CA somewhere?

Thanks

Richard Drouillard said...

It's been a while, but I don't remember having to do anything explicit with a certificate

Cpt. Ashley said...

I just did this, thanks HEAPS for the advice on "ldaps://".

On a pretty standard linux system with PHP LDAP working just fine, all I had to change was the hostname (as directed here) and the port number.

It then worked beautifully.

Thanks again,

Ash