{"record":{"id":"89227d7cd825c71f","repo":"SonarSource/sonarqube","slug":"unable-to-retrieve-details-for-user-username-in","errorCode":null,"errorMessage":"Unable to retrieve details for user <username> in <serverKey>","messagePattern":"Unable to retrieve details for user <username> in <serverKey>","errorType":"exception","errorClass":"LdapException","httpStatus":null,"severity":"error","filePath":"server/sonar-auth-ldap/src/main/java/org/sonar/auth/ldap/DefaultLdapUsersProvider.java","lineNumber":89,"sourceCode":"      LOG.debug(errorMessage);\n      throw new LdapException(errorMessage);\n    }\n    SearchResult searchResult;\n    try {\n      searchResult = ldapUserMapping.createSearch(contextFactories.get(serverKey), username)\n        .returns(ldapUserMapping.getEmailAttribute(), ldapUserMapping.getRealNameAttribute())\n        .findUnique();\n\n      if (searchResult != null) {\n        return mapUserDetails(ldapUserMapping, searchResult);\n      } else {\n        LOG.debug(\"User {} not found in {}\", username, serverKey);\n        return null;\n      }\n    } catch (NamingException e) {\n      // just in case if Sonar silently swallowed exception\n      LOG.debug(e.getMessage(), e);\n      throw new LdapException(\"Unable to retrieve details for user \" + username + \" in \" + serverKey, e);\n    }\n  }\n\n  private static LdapUserDetails mapUserDetails(LdapUserMapping ldapUserMapping, SearchResult searchResult) throws NamingException {\n    Attributes attributes = searchResult.getAttributes();\n    LdapUserDetails details;\n    details = new LdapUserDetails();\n    details.setName(getAttributeValue(attributes.get(ldapUserMapping.getRealNameAttribute())));\n    details.setEmail(getAttributeValue(attributes.get(ldapUserMapping.getEmailAttribute())));\n    return details;\n  }\n\n}\n","sourceCodeStart":71,"sourceCodeEnd":103,"githubUrl":"https://github.com/SonarSource/sonarqube/blob/184c821202192afc1c599fc912d0889b69fffa53/server/sonar-auth-ldap/src/main/java/org/sonar/auth/ldap/DefaultLdapUsersProvider.java#L71-L103","documentation":"getUserDetails wraps any NamingException from the user detail search (findUnique) in this LdapException. It means the LDAP operation to fetch email/realName attributes for the user failed at the directory level. A user simply not found returns null instead — this error means an actual directory/protocol failure. The cause is attached and logged at debug.","triggerScenarios":"getUserDetails with a findUnique() search that throws NamingException — invalid bind credentials, wrong user.baseDn, connection refused to ldap.url, communication exception (timeout), or attribute-read ACL denial.","commonSituations":"Expired bind password; firewall/network changes blocking port 389/636; certificate trust failure on ldaps://; AD domain controller outage; baseDn pointing at a nonexistent OU.","solutions":["Enable debug logging to inspect the wrapped NamingException for the exact failure (CommunicationException, AuthenticationException, NameNotFoundException...).","Test connectivity and bind with ldapsearch -H <ldap.url> -D <bindDn> -w <password>.","Fix sonar.authenticator.ldap.url / user.baseDn configuration as indicated by the cause.","Check SSL certificate trust for ldaps:// endpoints."],"exampleFix":"// before: unreachable server\nsonar.authenticator.ldap.url: ldap://old-dc.example.com:389\n// after: reachable controller\nsonar.authenticator.ldap.url: ldap://dc1.example.com:389","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n  details = provider.getUserDetails(username, serverKey);\n} catch (LdapException e) {\n  LOG.error(\"LDAP lookup failure for {} on {}: cause={}\", username, serverKey, e.getCause(), e);\n  throw e; // authentication should fail closed on directory outage\n}","preventionTips":["Test bind credentials and URL with ldapsearch before each SonarQube upgrade.","Import ldaps certificates into the JVM truststore proactively.","Watch for expired service-account passwords; rotate with monitoring."],"tags":["ldap","user-details","naming-exception","connection"],"backgroundTag":"http-request-failed","analyzedSha":"184c821202192afc1c599fc912d0889b69fffa53","analyzedAt":"2026-09-09T12:23:51.573Z","contentChangedAt":"2026-09-09T12:23:51.573Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}