{"record":{"id":"3422c573b89fd560","repo":"phacility/phabricator","slug":"ldap-failed-to-retrieve-record-for-user-s-when","errorCode":null,"errorMessage":"LDAP: Failed to retrieve record for user \"%s\" when searching. Credentialed users may not be able to search your LDAP server. Try configuring anonymous credentials or fully anonymous binds.","messagePattern":"LDAP: Failed to retrieve record for user \"(.+?)\" when searching\\. Credentialed users may not be able to search your LDAP server\\. Try configuring anonymous credentials or fully anonymous binds\\.","errorType":"exception","errorClass":"Exception","httpStatus":null,"severity":"error","filePath":"src/applications/auth/adapter/PhutilLDAPAuthAdapter.php","lineNumber":268,"sourceCode":"\n    $this->bindLDAP($conn, $distinguished_name, $login_pass);\n\n    $result = $this->searchLDAPForRecord($search_query);\n    if (!$result) {\n      // This is unusual (since the bind succeeded) but we've seen it at least\n      // once in the wild, where the anonymous user is allowed to search but\n      // the credentialed user is not.\n\n      // If we don't have anonymous credentials, raise an explicit exception\n      // here since we'll fail a typehint if we don't return an array anyway\n      // and this is a more useful error.\n\n      // If we do have anonymous credentials, we'll rebind and try the search\n      // 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));","sourceCodeStart":250,"sourceCodeEnd":286,"githubUrl":"https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/auth/adapter/PhutilLDAPAuthAdapter.php#L250-L286","documentation":"Error \"LDAP: Failed to retrieve record for user \"%s\" when searching. Credentialed users may not be able to search your LDAP server. Try configuring anonymous credentials or fully anonymous binds.\" thrown in phacility/phabricator.","triggerScenarios":"Thrown at src/applications/auth/adapter/PhutilLDAPAuthAdapter.php:268 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"5720a38cfe95b00ca4be5016dd0d2f3195f4fa04","analyzedAt":"2026-08-21T05:07:25.672Z","schemaVersion":2},"datasetVersion":"2026-08-21T11:28:35.574Z"}