Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am working on a integrating LDAP authentication with my PHP Project deployed on a Linux platform. I successfully completed the ldapsearch from command line and from php code for NON SSL connection.

When it comes to SSL connection, I am not able to make it work. I am thinking if I can make the ldapsearch work from commandline, dealing with php side won't be a problem. I am using CentOS and below is my search result query pattern - which works for non-SSL request on port 3268 but fails for port 3269 with two errors ldap_start_tls: Can't contact LDAP server (-1) and ldap_bind: Can't contact LDAP server (-1). I have searched for this query and it lead me to pages which talk about Kerboros authentication, which I don't want. Any help would be greatly appreciated.


    [Test]$ ldapsearch -x -h -D "CN=personName,OU=EUS,
            DC=company,DC=com" -p 3269 -b "dc=company,dc=com" 
            samaccountname=personName -Z "/etc/openldap/cacerts/test.cer" 
             -w "<<MyPassword>>"
        ldap_start_tls: Can't contact LDAP server (-1)
        ldap_bind: Can't contact LDAP server (-1)


       [Test]$ ldapsearch -x -h -D "CN=personName,
      OU=EUS, DC=company,DC=com" -p 3268 -b "dc=company,dc=com"            
       samaccountname=personName -Z "/etc/openldap/cacerts/test.cer" -w 
         //Gives valid output
share|improve this question
-Z is not followed by your trusted CA. In fact, the trusted CA(s) cannot be set as part of the command. Use either ldap.conf,.ldaprc or environmental variables – 84104 May 9 '13 at 22:56
up vote 2 down vote accepted

A few things you could try:

in ldap.conf add this:


And in your ldapsearch string:

-H ldaps://

Instead of:

-h -p 3269
share|improve this answer
Thanks Danila! I did have the ldap.conf setting right but the changing the ldapsearch string did the trick. – prashantsunkari May 9 '13 at 22:08
I am glad it helped. – Danila Ladner May 9 '13 at 22:10

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.