Hi,
Has anyone had to problem using php_ldap where the bind to ldap will work find but will unbind right away so any attempt to search the tree fails?
If so were you able to fix it?
Hello Bram,
I didn't have any problems as far as I can remember, I've wrapped the connection part so it is some time ago I actually coded that part.
I connect to LDAP like this, maybe the protocol version is significant, I vaguely remember something with that.
$this->conn = ldap_connect($ldaphost,$ldapport); ldap_set_option($this->conn,LDAP_OPT_PROTOCOL_VERSION,3); ldap_bind($this->conn,$binddn,$bindpw);
Regards, Gerben van Ek
-----Oorspronkelijk bericht----- Van: openldap-technical-bounces@OpenLDAP.org [mailto:openldap-technical-bounces@OpenLDAP.org] Namens Bram Cymet Verzonden: donderdag 10 maart 2011 18:27 Aan: openldap-technical@openldap.org Onderwerp: php ldap binding problems
Hi,
Has anyone had to problem using php_ldap where the bind to ldap will work find but will unbind right away so any attempt to search the tree fails?
If so were you able to fix it?
Hi,
This is how I connect to LDAP and never had problems (my programming is not professional, but anyway):
$ldap_server = "ldap://ldap.example.com"; $ldap_binddn = "uid=".$_POST['u'].",ou=people,dc=example,dc=com" ; $ldap_pass = $_POST['p'];
$ldaphandle=ldap_connect($ldap_server);
if ($ldaphandle==FALSE) { $message="Could not connect to server"; }
if (ldap_set_option($ldaphandle, LDAP_OPT_PROTOCOL_VERSION, 3)==FALSE){ $message="Could not set correct protocol version"; }
if (ldap_bind($ldaphandle, $ldap_binddn, $ldap_pass)==FALSE){ $message="Login error"; }
It always worked without problems. Note, however, that I always connect to localhost, so I have no experience with remote connections.
It is important to force protocol version 3.
Nick
Has anyone had to problem using php_ldap where the bind to ldap will work find but will unbind right away so any attempt to search the tree fails?
Germ van Eck wrote:
I didn't have any problems as far as I can remember, I've wrapped the connection part so it is some time ago I actually coded that part.
I connect to LDAP like this, maybe the protocol version is significant, I vaguely remember something with that.
$this->conn = ldap_connect($ldaphost,$ldapport); ldap_set_option($this->conn,LDAP_OPT_PROTOCOL_VERSION,3); ldap_bind($this->conn,$binddn,$bindpw);
Yes, setting LDAPv3 as protocol is important! Depending on the server's configuration LDAPv2 is not accepted. Or some LDAP servers return other character set (not UTF-8) for attribute values of syntax DirectoryString.
Ciao, Michael.
openldap-technical@openldap.org