Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Next challenges

Recent achievements

  • Global
  • Personal

Recognition

  • Give kudos
  • Received
  • Given

Leaderboard

  • Global

Trophy case

Kudos (beta program)

Kudos logo

You've been invited into the Kudos (beta program) private group. Chat with others in the program, or give feedback to Atlassian.

View group

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

How to manage/disable user by Java API in Jira/Bitbucket/Confluence server Edited

Hi everyone,

 

I'm developing a  plugin to manage Jira/Confluence/Bitbucket user. I need use related Java APIs to add/remove user into/from group and disable/enable user. 

I've found some Java APIs such as:

  1. com.atlassian.jira.user.util.UserUtil#removeUserFromGroup for jira membership
  2. com.atlassian.user.GroupManager#removeMembership for confluence membership

 

But could anyone help tell Java APIs or examples about below cases? 

Java API For Jira:

  • Enable/disable Jira User

Java API For Confluence: 

  •  Enable/disable Confluence user

Java API For Bitbucket

  • Add/remove user from specific group
  • Enable/disable Bitbucket User

 

Thanks a lot.

 

 

 

 

 

2 answers

2 accepted

1 vote
Answer accepted

Hi @Sooxin I have something for Jira:

ApplicationUser user = ...your active user...

ApplicationUser updatedUser = userService.newUserBuilder(user).active(false).build();// where userService is instance of this - com.atlassian.jira.bc.user.UserService
UserService.UpdateUserValidationResult validationResult = userService.validateUpdateUser(updatedUser);
if (validationResult.isValid()) {
userService.updateUser(validationResult);
} else {
log.error("Deactivation of user failed:" + validationResult.getErrorCollection());
}

 

Wow, thank you @Martin Bayer _MoroSystems_ s_r_o__ . It must be helpful, I'll test it next week. 

@Sooxin ok, let me know if anything is not working or if you find out how to manage it in the Bitbucket :)

0 votes
Answer accepted

Thanks to @Martin Bayer _MoroSystems_ s_r_o__ , after researching and testing, I think below APIs are helpful:

jira

  • com.atlassian.jira.user.util.UserUtil#removeUserFromGroup
  • com.atlassian.jira.user.util.UserUtil#addUserToGroup

Confluence

  • com.atlassian.user.GroupManager#addMembership
  • com.atlassian.user.GroupManager#removeMembership
  • com.atlassian.confluence.user.DisabledUserManager#disableUser
  • com.atlassian.confluence.user.DisabledUserManager#enableUser

Bitbucket

  • com.atlassian.bitbucket.user.UserAdminService#addUserToGroups
  • com.atlassian.bitbucket.user.UserAdminService#removeUserFromGroup

However, it seems Bitbucket APIs listed above requires some "strange" privileges, My cron in plugin cannot call it successfully. Finally, as an alternative, I wrote a API client by retrofit to call the restful APIs.

Thank you @Sooxin for your feedback... good job :)

Suggest an answer

Log in or Sign up to answer
TAGS

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you