Check for free licenses

Starting with version 6.1, it's possible to check the amount of available user licenses before creating a user.


When using SAML Just-In-Time provisioning, this works using a Groovy transformation on the "find User"-attribute, usually the username.

screenshot_51.png



  1. // In this example, it's assumed that the SAML Name ID contains the username.
  2. // Check if the user already exists in the system and just
  3. // return the Name ID in this case
  4. def existingUser = findUserKeyByUsername(mapping.ATTR_NAMEID)
  5. if(existingUser != null) {
  6. return mapping.ATTR_NAMEID
  7. }
  8. int freeLicenses = getAvailableJiraSoftwareUserLicenses(); // Jira Software
  9. //int freeLicenses = getAvailableJSMUserLicenses(); // Jira Service Management
  10. //int freeLicenses = getAvailableJiraCoreUserLicenses(); // Jira Core
  11. //int freeLicenses = getAvailableBitbucketUserLicenses(); // Bitbucket
  12. //int freeLicenses = getAvailableConfluenceUserLicenses(); // Confluence
  13. // If there are less than 5 free license available, drop the user with an appropriate message
  14. // Which will be shown on the error page.
  15. if(freeLicenses < 5 ) {
  16. return dropAll("Not enough Licenses: $freeLicenses")
  17. } else {
  18. return mapping.ATTR_NAMEID
  19. }