I have this problem, after 6th april update.

Warning: ldap_search() [function.ldap-search]: Search: No such object en LdapServer->search()
(line 271 .../ldap/ldap_servers/LdapServer.class.php).

Sorry, unrecognized username or password.

Comments

johnbarclay’s picture

Assigned: Unassigned » johnbarclay
Priority: Normal » Major
johnbarclay’s picture

Status: Active » Needs review

I could replicate this by putting a bad base dn in the server settings. With the following code, the error went away, but was watchdogged. I also gave the user a generic error message so they wouldn't think they were entering a bad account name or password. This is in head:

function search($filter, $basedn = NULL, $attributes = array()) {
    if ($basedn == NULL) {
      if (count($this->basedn) == 1) {
        $basedn = $this->basedn[0];
      }
      else {
        return FALSE;
      }
    }

 -   $result = ldap_search($this->connection, $basedn, $filter, $attributes);
 +   $result = @ldap_search($this->connection, $basedn, $filter, $attributes);

    if ($result && ldap_count_entries($this->connection, $result)) {
      return ldap_get_entries($this->connection, $result);
    } elseif ($this->ldapErrorNumber()) {
      $watchdog_tokens =  array('%basedn' => $basedn, '%filter' => $filter,
        '%attributes' => print_r($attributes, TRUE), '%errmsg' => $this->errorMsg('ldap'),
        '%errno' => $this->ldapErrorNumber());
      watchdog('ldap', "LDAP ldap_search error. basedn: %basedn, filter: %filter, attributes:
        %attributes, errmsg: %errmsg, ldap err no: %errno,", $watchdog_tokens);
      return array();
    } else {
      return array();
    }
  }
johnbarclay’s picture

Status: Needs review » Fixed

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.