{"record":{"id":"253ec076ad548ba5","repo":"SonarSource/sonarqube","slug":"unable-to-retrieve-details-for-user-s-and-server","errorCode":null,"errorMessage":"Unable to retrieve details for user %s and server key %s: No user mapping found.","messagePattern":"Unable to retrieve details for user (.+?) and server key (.+?): No user mapping found\\.","errorType":"exception","errorClass":"LdapException","httpStatus":null,"severity":"error","filePath":"server/sonar-auth-ldap/src/main/java/org/sonar/auth/ldap/DefaultLdapUsersProvider.java","lineNumber":72,"sourceCode":"  }\n\n  @Override\n  public LdapUserDetails doGetUserDetails(Context context) {\n    return getUserDetails(context.serverKey(), context.username());\n  }\n\n  /**\n   * @return details for specified user, or null if such user doesn't exist\n   * @throws LdapException if unable to retrieve details\n   */\n  private LdapUserDetails getUserDetails(String serverKey, String username) {\n    LOG.debug(\"Requesting details for user {}\", username);\n    // If there are no userMappings available, we can not retrieve user details.\n    LdapUserMapping ldapUserMapping = userMappings.get(serverKey);\n    if (ldapUserMapping == null) {\n      String errorMessage = format(\"Unable to retrieve details for user %s and server key %s: No user mapping found.\", username, serverKey);\n      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    }","sourceCodeStart":54,"sourceCodeEnd":90,"githubUrl":"https://github.com/SonarSource/sonarqube/blob/184c821202192afc1c599fc912d0889b69fffa53/server/sonar-auth-ldap/src/main/java/org/sonar/auth/ldap/DefaultLdapUsersProvider.java#L54-L90","documentation":"getUserDetails looks up the LdapUserMapping for the requested server key; if none exists it throws this LdapException. It guards the case where multi-LDAP configuration defines servers but the given serverKey has no sonar.authenticator.ldap.<serverKey>.user.* mapping. This is a configuration error thrown before any LDAP call.","triggerScenarios":"Calling getUserDetails (via doGetUserDetails) with a serverKey (e.g. from a multi-server setup) for which userMappings.get(serverKey) returns null — the server has no user mapping configured.","commonSituations":"Multi-LDAP setups where sonar.authenticator.ldap.servers lists a key but corresponding sonar.authenticator.ldap.<key>.user.baseDn etc. were never set; server key typo (case-sensitive mismatch); partially migrated single-server configs.","solutions":["Add user mapping properties for every server key listed in sonar.authenticator.ldap.servers: sonar.authenticator.ldap.<key>.user.baseDn, .request, .emailAttribute, .realNameAttribute.","Verify the serverKey spelling matches exactly the key used in sonar.authenticator.ldap.servers.","If single-server, drop the multi-server config and use the plain sonar.authenticator.ldap.* prefix."],"exampleFix":"// before: servers lists two keys but only one has user mapping\nsonar.authenticator.ldap.servers: server1,server2\nsonar.authenticator.ldap.server1.user.baseDn: ou=users,dc=example,dc=org\n// after: map both\nsonar.authenticator.ldap.server2.user.baseDn: ou=people,dc=other,dc=org","handlingStrategy":"validation","validationCode":"// every server in servers must have a user mapping\nString[] keys = config.get(\"sonar.authenticator.ldap.servers\").split(\",\");\nfor (String key : keys) {\n  if (!config.hasKey(\"sonar.authenticator.ldap.\" + key + \".user.baseDn\")) {\n    throw new IllegalStateException(\"Missing user mapping for server key: \" + key);\n  }\n}","typeGuard":null,"tryCatchPattern":"try {\n  details = provider.getUserDetails(username, serverKey);\n} catch (LdapException e) {\n  if (e.getMessage().contains(\"No user mapping found\")) {\n    throw new IllegalStateException(\"Fix config: add sonar.authenticator.ldap.\" + serverKey + \".user.*\", e);\n  }\n  throw e;\n}","preventionTips":["Maintain a symmetric config: every key in ldap.servers must have full url + user.* (+ group.*) settings.","Keep server keys lowercase and consistent; they are matched literally."],"tags":["ldap","configuration","missing-mapping","multi-server"],"backgroundTag":"missing-required-config-field","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"}