authenticationldapsonarqubesonarqube-ops

User not authenticated against LDAP in Sonar 5.6


I have set the proper LDAP configuration in Sonar 5.6.6 LTS (ldap plugin v2.2.0.608) and I see in logs that the connection is established.

When I first try to login with my LDAP-login, I am able to do so, but my user has of course no permissions - that is okay.

The problem occurs, when I want to first add my user and give him i.e. sonar-administrators group. When it is set and I try to login, Sonar authenticates me not against the external system (LDAP) but uses his own data base.

I am sure it worked with Sonar 4.5 but now I cannot configure it properly.


Solution

  • The problem was that creation of new users adds them by default to the local database of SonarQube. To change this default behavior I found out that the REST API endpoint to create users contains the flag 'local' which defines whether the user should be considered as a local user added to the local database or he should be added as an external user authenticated again an external system like LDAP.

    So final answer is to use the following REST API endpoint:

    private final String CREATE_USER_API = "/api/users/create?login={login}&name={name}&local=false"
    

    Please note the following property:

    local=false
    at the end of the string.