Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

How can I programmatically create a new jira user, but set it to inactive by default?

Kristīne Graudiņa October 3, 2024

Hi.

In one of my projects the client would like the ability to, when creating a new Jira user, to set them as inactive by default, and I'd like to know if that is possible and how.

Checking UserService and ApplicationUser, I can see that I can check if a user is active, but not actually manipulate the user's activity status.

 

Please advise, thank you!

2 answers

0 votes
Jim Knepley - ReleaseTEAM
Atlassian Partner
October 3, 2024

If you're creating a new user via the API, you can set them as active, or not, when the record is created.

If you're talking about disabling users that are created via any mechanism (like a directory sync), what might be easiest is to create the user as usual, but don't give them application access by default.

Kristīne Graudiņa October 4, 2024

It's the latter. Client has their internal employee system, where, when a new employee is added, they want the synchronizer plugin to automatically create a new Jira user. Which is currently implemented and works.

They just want to make it now that, when that new user is created, it is set to inactive.

User creation is handled through a service class that makes use of UserManager and UserService,

I can see that you can use method withNoApplicationAccess() to deny application access on user creation, but that wouldn't necessarily make the user inactive, right?

I suppose in that case implementing an update user API call is the most straightforward way?

I was hoping for something roundabout.

0 votes
Sergei Troshin
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
October 3, 2024 edited

Hi @Kristīne Graudiņa

You can refer to Adaptavist Libaray and their complete code examples: Deactivate Users.
I will try to provide you with some examples of creating users with inactive status by default later.

Sergei Troshin
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
October 3, 2024 edited

Here some extended code by Adaptavist:

final Long directoryId = 1

Users.create('bob', 'bob@mail.com', 'Mr Bob') {
    setDirectoryId(directoryId)
    setPassword('secret')
    withNoApplicationAccess()
}.deactivate()

 

Suggest an answer

Log in or Sign up to answer
TAGS
atlassian, atlassian government cloud, fedramp, webinar, register for webinar, atlassian cloud webinar, fedramp moderate offering, work faster with cloud

Unlocking the future with Atlassian Government Cloud ☁️

Atlassian Government Cloud has achieved FedRAMP Authorization at the Moderate level! Join our webinar to learn how you can accelerate mission success and move work forward faster in cloud, all while ensuring your critical data is secure.

Register Now
AUG Leaders

Atlassian Community Events