{"record":{"id":"35cad9fb2203a921","repo":"SonarSource/sonarqube","slug":"unable-to-retrieve-details-for-user-s-no-user-or","errorCode":null,"errorMessage":"Unable to retrieve details for user %s: No user or group mapping found.","messagePattern":"Unable to retrieve details for user (.+?): No user or group mapping found\\.","errorType":"exception","errorClass":"LdapException","httpStatus":null,"severity":"error","filePath":"server/sonar-auth-ldap/src/main/java/org/sonar/auth/ldap/DefaultLdapGroupsProvider.java","lineNumber":84,"sourceCode":"      SearchResult searchResult = searchUserGroups(username, serverKey);\n      if (searchResult != null) {\n        try {\n          NamingEnumeration<SearchResult> result = groupMappings\n            .get(serverKey)\n            .createSearch(contextFactories.get(serverKey), searchResult).find();\n          groups.addAll(mapGroups(serverKey, result));\n        } catch (NamingException e) {\n          LOG.debug(e.getMessage(), e);\n          throw new LdapException(format(\"Unable to retrieve groups for user %s in server with key <%s>\", username, serverKey), e);\n        }\n      }\n    }\n    return groups;\n  }\n\n  private void checkPrerequisites(String username) {\n    if (userMappings.isEmpty() || groupMappings.isEmpty()) {\n      throw new LdapException(format(\"Unable to retrieve details for user %s: No user or group mapping found.\", username));\n    }\n  }\n\n  private SearchResult searchUserGroups(String username, String serverKey) {\n    try {\n      LOG.debug(\"Requesting groups for user {}\", username);\n      return userMappings.get(serverKey).createSearch(contextFactories.get(serverKey), username)\n        .returns(groupMappings.get(serverKey).getRequiredUserAttributes())\n        .findUnique();\n    } catch (NamingException e) {\n      // just in case if Sonar silently swallowed exception\n      LOG.debug(e.getMessage(), e);\n      throw new LdapException(format(\"Unable to retrieve groups for user %s in server with key <%s>\", username, serverKey), e);\n    }\n  }\n\n  /**\n   * Map all the groups.","sourceCodeStart":66,"sourceCodeEnd":102,"githubUrl":"https://github.com/SonarSource/sonarqube/blob/184c821202192afc1c599fc912d0889b69fffa53/server/sonar-auth-ldap/src/main/java/org/sonar/auth/ldap/DefaultLdapGroupsProvider.java#L66-L102","documentation":"Before performing any group lookup, checkPrerequisites verifies that at least one user mapping and one group mapping were configured. If either sonar.authenticator.ldap.user.* or group.* mappings are empty, it throws this LdapException because group retrieval is impossible without mappings. This is a configuration-validation error, not a directory error.","triggerScenarios":"Calling getGroups (via doGetGroups) when the LdapSettingsManager produced empty userMappings or groupMappings — i.e. no sonar.authenticator.ldap.user.* or sonar.authenticator.ldap.group.* properties were set in configuration.","commonSituations":"sonar.authenticator.ldap set to a value other than 'sonarqube' causing mapping initialization to be skipped; fresh install where only ldap.url was configured without group settings; mis-typed property prefixes (e.g. sonar.authenticator.ldao.group.baseDn).","solutions":["Configure the group mapping properties: sonar.authenticator.ldap.group.baseDn, group.objectClass, group.idAttribute (and user.* mappings).","Check the sonar.authenticator.ldap value: 'sonarqube' enables both user and group mappings.","Verify property spellings against sonar-auth-ldap documentation."],"exampleFix":"// before: only URL configured, no group mapping\nsonar.authenticator.ldap.url: ldap://ldap.example.com\n// after: add user+group mappings\nsonar.authenticator.ldap.user.baseDn: ou=users,dc=example,dc=org\nsonar.authenticator.ldap.group.baseDn: ou=groups,dc=example,dc=org\nsonar.authenticator.ldap.group.objectClass: groupOfNames\nsonar.authenticator.ldap.group.idAttribute: cn","handlingStrategy":"validation","validationCode":"// validate mapping config before relying on group retrieval\nif (!config.hasKey(\"sonar.authenticator.ldap.user.baseDn\") ||\n    !config.hasKey(\"sonar.authenticator.ldap.group.baseDn\")) {\n  throw new IllegalStateException(\"LDAP user and group mappings must both be configured\");\n}","typeGuard":null,"tryCatchPattern":"try {\n  groups = provider.getGroups(username);\n} catch (LdapException e) {\n  if (e.getMessage().contains(\"No user or group mapping found\")) {\n    LOG.error(\"LDAP group mapping not configured — check sonar.authenticator.ldap.group.* properties\");\n  }\n  throw e;\n}","preventionTips":["Use sonar.authenticator.ldap=sonarqube so both user and group mappings initialize.","Keep a config checklist: url, user.*, group.* for each environment.","Run SonarQube with debug logging once after config changes."],"tags":["ldap","configuration","missing-mapping","precondition"],"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"}