{"record":{"id":"5ae7c4c3092a20e4","repo":"phacility/phabricator","slug":"ldap-failed-to-retrieve-record-for-user-s-when-5ae7c4","errorCode":null,"errorMessage":"LDAP: Failed to retrieve record for user \"%s\" when searching with both user and anonymous credentials.","messagePattern":"LDAP: Failed to retrieve record for user \"(.+?)\" when searching with both user and anonymous credentials\\.","errorType":"exception","errorClass":"Exception","httpStatus":null,"severity":"error","filePath":"src/applications/auth/adapter/PhutilLDAPAuthAdapter.php","lineNumber":282,"sourceCode":"      // again below. Doing this automatically means things work correctly more\n      // often without requiring additional configuration.\n      if (!$this->shouldBindWithoutIdentity()) {\n        // No anonymous credentials, so we just fail here.\n        throw new Exception(\n          pht(\n            'LDAP: Failed to retrieve record for user \"%s\" when searching. '.\n            'Credentialed users may not be able to search your LDAP server. '.\n            'Try configuring anonymous credentials or fully anonymous binds.',\n            $login_user));\n      } else {\n        // Rebind as anonymous and try the search again.\n        $user = $this->anonymousUsername;\n        $pass = $this->anonymousPassword;\n        $this->bindLDAP($conn, $user, $pass);\n\n        $result = $this->searchLDAPForRecord($search_query);\n        if (!$result) {\n          throw new Exception(\n            pht(\n              'LDAP: Failed to retrieve record for user \"%s\" when searching '.\n              'with both user and anonymous credentials.',\n              $login_user));\n        }\n      }\n    }\n\n    return $result;\n  }\n\n  private function establishConnection() {\n    if (!$this->ldapConnection) {\n      $host = $this->hostname;\n      $port = $this->port;\n\n      $profiler = PhutilServiceProfiler::getInstance();\n      $call_id = $profiler->beginServiceCall(","sourceCodeStart":264,"sourceCodeEnd":300,"githubUrl":"https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/auth/adapter/PhutilLDAPAuthAdapter.php#L264-L300","documentation":"Final failure guard in the LDAP adapter: the user's DN could not be found even after rebinding with anonymous credentials and retrying the search. Both the credentialed and anonymous search paths returned no record, so user data cannot be loaded.","triggerScenarios":"Thrown at src/applications/auth/adapter/PhutilLDAPAuthAdapter.php:282 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Verify the LDAP search base DN and search attribute match where users actually live","Test the same search with ldapsearch to confirm the user is findable","Check the anonymous bind credentials configured in Phabricator"],"exampleFix":null,"handlingStrategy":"fallback","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"5720a38cfe95b00ca4be5016dd0d2f3195f4fa04","analyzedAt":"2026-08-21T05:07:25.672Z","contentChangedAt":"2026-08-21T05:07:25.672Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}