Hello all,

Notice: I am pretty new to LDAP.

I currently have a Xampp package installed. With it I create php pages and I would like to be able to communicate to a LDAP database. I have been provided the connection parameters from my administrators. Here is my code in PHP where I try to connect to the LDAP server:

 $ldapserver = "ldap://"; $ldaprdn  = "uid=_username, ou=ServiceAccounts, dc=ls,dc=serverdb"; $ldappass = "superpassword";  $handle = ldap_connect($ldapserver); $bind = ldap_bind($handle, $ldaprdn, $ldappass);                             
1: 2: 3: 4: 5: 6: 

Select allOpen in new window

This code gives me the following error: Warning: ldap_bind() [function.ldap-bind]: Unable to bind to server: Local error

This mean the connection to LDAP was fine, but the bind is not working properly.

What I have discovered recently is that I need to connect in SSL, which mean I will need to connect to a ldaps:// instead of ldap://. To do this, I found the following information on a PHP documentation page:

To use LDAP with SSL, compile OpenLDAP 2.x.x with SSL support, configure PHP with SSL, and set this parameter as ldaps://hostname/.

Now I know PHP is configured with SSL. But I have absolutly no idea how to compile OpenLDAP with SSL support.

Any help is appreciated.

asked 08/30/2011 11:00

Etdashou's gravatar image

Etdashou ♦♦

9 Answers:
If your installed package of OpenLDAP provides SSL support, there is no need to recompile it.

Compiling is the process of translating source code (programming language) into object code and executable files (code processable by a computer's CPU). You only need to do that if you have the source code and want to create the executable files and libraries.

Since you have an SSL-enabled package, you can just skip the compiling step entirely.


svgmuc's gravatar image


Hi svgmuc,

I have verified the openLdap webpage ( but I don't understand what need to be installed exactly so it would work with PHP.

If anyone can help me with the installation process I would greatly appreciate.

answered 2011-08-31 at 08:27:39

Etdashou's gravatar image


You need OpenLDAP and the apache module ldap_mod. The OpenLDAP version must have SSL support, if you have that requirement for your PHP code.

You don't need anything else.

answered 2011-08-31 at 09:36:46

svgmuc's gravatar image


Ok, in my apache httpd.conf file I have "LoadModule ldap_module modules/" enabled OK.

The "The OpenLDAP version must have SSL support, if you have that requirement for your PHP code." part now.

I have Apache on Windows server. So I have found this website:

When I install the package, I don't understand what exactly I need to install. Could you help me with this?

answered 2011-08-31 at 09:50:10

Etdashou's gravatar image


The provided package supports SSL. You don't need to change anything. Just follow the installation instructions and use the BDB backend.

It will just need configuration after you're done installing. If you are not proficient with LDAP, I recommend phpLDAPadmin to fill the database. The initial login credentials are mentioned at the bottom of the installation instruction page.

answered 2011-08-31 at 12:43:43

svgmuc's gravatar image



Perhaps I have not explained myself correctly and I am sorry about that.

But if I understand correctly what you are saying, I will install a LDAP database with that. However I already have a LDAP database somewhere in my network. All I want to do is to connect to it with php in SSL.

I have tried the package and their is a client, a server and more.

I hope I explained myself correctly.

answered 2011-08-31 at 13:31:35

Etdashou's gravatar image


You don't need an OpenLDAP server on your system. But you need the OpenLDAP client libraries which are in the same package and most likely not available separately.

Make sure the php ldap extension is enabled.
According to, make sure that libeay32.dll and ssleay32.dll are located in the search path (%PATH%).

After that, you should be able to connect to your LDAP server without a problem.

answered 2011-09-01 at 07:13:40

svgmuc's gravatar image


Ok, this been a long time.

I have been able to solve my problem. Follow these steps:

And it works very well.

I will also assign points to svgmuc for his time, you did help me.

answered 2011-09-01 at 07:25:21

Etdashou's gravatar image



answered 2011-11-10 at 07:43:43

Etdashou's gravatar image


Your answer
[hide preview]

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here



Answers and Comments



Asked: 08/30/2011 11:00

Seen: 315 times

Last updated: 11/14/2011 05:16