phacility/phabricator · error · Exception

LDAP record query returned more than one result. The query…

Error message

LDAP record query returned more than one result. The query must uniquely identify a record.

What it means

Uniqueness guard in searchLDAPForRecord(): the LDAP search for a single distinguished name matched more than one entry. Because the code must return exactly one record, an ambiguous match is treated as a configuration error (typically a search base that is too broad).

Solutions

  1. Narrow the LDAP search base DN so queries match at most one record
  2. Verify the username search attribute is unique in the directory
  3. Fix duplicated directory entries causing the ambiguity
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at src/applications/auth/adapter/PhutilLDAPAuthAdapter.php:384 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of phacility/phabricator@5720a38cfe (2026-08-21). Data as JSON: /api/errors/acb29abe4aa39425. Report an issue: GitHub.

Appendix: source

Thrown at src/applications/auth/adapter/PhutilLDAPAuthAdapter.php:384

      $this->ldapConnection = $conn;
    }

    return $this->ldapConnection;
  }


  private function searchLDAPForRecord($dn) {
    $conn = $this->establishConnection();

    $results = $this->searchLDAP('%Q', $dn);

    if (!$results) {
      return null;
    }

    if (count($results) > 1) {
      throw new Exception(
        pht(
          'LDAP record query returned more than one result. The query must '.
          'uniquely identify a record.'));
    }

    return head($results);
  }

  public function searchLDAP($pattern /* ... */) {
    $args = func_get_args();
    $query = call_user_func_array('ldap_sprintf', $args);

    $conn = $this->establishConnection();

    $profiler = PhutilServiceProfiler::getInstance();
    $call_id = $profiler->beginServiceCall(
      array(
        'type'  => 'ldap',

View on GitHub (pinned to 5720a38cfe)