AD groups configuration

Must-share information (formatted with Markdown):

  • which versions are you using (SonarQube, Scanner, Plugin, and any relevant extension) -
  • what are you trying to achieve -
    When a user signs in using LDAP credentials, have sonarqube inherit their AD group membership.
  • what have you tried so far to achieve this -
    Configured LDAP settings in They can log in using LDAP credentials but are added to the sonar-users group.

I have read

I see this caveat: "membership in a group is synched only if a group with the same name exists in SonarQube"

Does this mean i have to manually create the groups first? There are hundreds of groups in this case.


the Sonarqube groups must exist with exactly the same name as the related AD groups.
In the case of hundreds of groups, you should use a script that reads the groups from AD
and creates the Sonarqube groups via web api POST api/user_groups/create


1 Like

Thank you.

I have been able to create the groups using the API.

How can i now use the API to get a list of all the groups?

I’m using /api/user_groups/search but it has limited results. I have over 6000 groups and would like to get a list of them all. Is that possible?


you take the total count of groups from json response and use in a loop.
Here’s an example using Groovy printing the group name.

import groovy.json.*

def sonarRest(url,method) {
  jsonSlurper = new JsonSlurper()
  raw = 'someusertoken:'
  bauth = 'Basic ' + javax.xml.bind.DatatypeConverter.printBase64Binary(raw.getBytes())
  conn = new URL(url).openConnection() as HttpURLConnection
  conn.setRequestProperty("Authorization", bauth)
  httpstatus = conn.responseCode
  object = jsonSlurper.parse(conn.content)

json = sonarRest('https://somesonarhost/api/user_groups/search?&ps=1', 'GET')
total = (

counter = 1

while(counter <= total) {
  json = sonarRest("https://somesonarhost/api/user_groups/search?ps=100&p=$counter", 'GET')
   json.groups.each {


Caught: groovy.lang.MissingPropertyException: No such property: paging for class: groups
groovy.lang.MissingPropertyException: No such property: paging for class: groups

line 16 - total = (

Thanks for the idea. I did the same using Python. It’s working.

Thank you

Has to be
total = (
Fixed this, see edit.