2
votes

I try to connect to LDAP in PHP with this code :

$ds = ldap_connect("122.134.124.2", 389);
$login = "[email protected]";
$password = "password";

if ($ds) 
{
    $r = ldap_bind($ds, $login, $password);
    $sr = ldap_search($ds, "dc=domain,dc=local", "cn=m*");    
}
else
    echo "Impossible to connect to the LDAP server.";

And I get this error : ldap_search(): Search: Operations error in test.php on line 8 (the line with the ldap_search function).

Yet the connection works and I put all the parameters of the function ldap_search.

1
Did you see this answer?George
Thank you. So the solution was to add these lines to the code : ldap_set_option($ldap, LDAP_OPT_REFERRALS, 0); ldap_set_option($ldap, LDAP_OPT_PROTOCOL_VERSION, 3);mkfahmi
Noting that these lines must go BEFORE the bind call.Paul Coldrey

1 Answers

2
votes

The solution was to add these lines to the code : ldap_set_option($ldap, LDAP_OPT_REFERRALS, 0); ldap_set_option($ldap, LDAP_OPT_PROTOCOL_VERSION, 3);