LDAP and PHP connection failure -


I am trying to connect to a secure LDAP server (using LDAP) via PHP, but me There is a problem with this. I get the following error

WARNING: ldap_bind () [function.ldap-bind]: Unable to bind to server: at /var/www/test.php Not contacting LDAP server Line 16

I work while trying to connect without LDAP, but it is necessary that I use LDAP because I'm dealing with sensitive information.

I'm using the following code with LDAP

   LDAP query exam "; Echo "connecting ..."; $ Ds = ldap_connect ("ldaps: // server"); // should be a valid LDAP server! Print $ ds; If ($ ds) {echo "br>  
binding ..."; $ R = ldap_bind ($ ds); // This is an "anonymous" tie, usually use only access to read // "the result of the bind is" $ R "
"; Looking for echo "(sn = S *) ..."; // search nickname entry $ sr = ldap_search ($ ds, "ou = people, o = server.ca, o = server", "uid = user name *"); Echo "is the search result" $ Sr "
"; The echo "The number of times returned" is Ldap_count_entries ($ ds, $ sr). "& Lt; br / & gt;"; Echo "Receiving Entries ..."

"; $ Info = ldap_get_entries ($ ds, $ sr); "Data for" echo $ Info ["count"] "items returned:

"; Print_r ($ info); // for ($ i = 0; $ i & lt; $ info ["count"]; $ i ++) {// Resonance is "DN:" $ info [$ i] ["DN"] "& Lt ; Br / & gt; "; // resonance "First CN entry is:" $ Info [$ i] ["cn"] [0] "& lt; br / & gt;"; // resonance is the "first email entry:". $ Info [$ i] ["Mail"] [0] "

& gt;"; //} "closed connection" echo; Ldap_close ($ DS); } Else {Echo "& lt; h4> Unable to connect to LDAP server "; }? & Gt;

The problem is not related to the actual binding process (invalid certificate) as a warning One would be different if the LDAP server could not authenticate your credentials. But the use of ldap_set_option ($ ds, LDAP_OPT_PROTOCOL_VERSION, 3) should be required - though I do not think this is the cause of your problems.

  • Which LDAP server type are you connecting to? OpenLDAP, Active Directory or something else?
  • What is the operating system of a computer running your PHP program?
  • Are you using self-signed SSL certificates on the LDAP server and the certificate authority certificate for the certificate given by the machine running your PHP program?
  • Which port is running on the LDAP server? The "official" port for 636 LDAPs may be that you can explicitly add the port to the server address: ldaps: // >: 636 .

There are some problems with the ext / Ldap SSL / TLS secure connection. You can always add ldap.conf ( /etc/ldap.conf) to

  anytime  

anytime Try or /etc/ldap/ldap.conf on Nix-based systems) or ldap.conf for Windows machines with the above content < Code> C: \ OpenLDAP \ sysconf / ldap.conf (path must be an exact match because it is hard work with extensions).


Comments

Popular posts from this blog

c++ - Linux and clipboard -

What is expire header and how to achive them in ASP.NET and PHP? -

sql server - How can I determine which of my SQL 2005 statistics are unused? -