This user does not exist please select a user from the user browser.

Hi, I'm trying to disable a user in my plugin but for some reason I am getting the following error message "This user does not exist please select a user from the user browser." I am getting this issue on JIRA 6.4. Can any one suggest? 

jiraUser = userUtil.getUserByName(user.getSamAccountName()).getDirectoryUser();
ImmutableUser.Builder builder = ImmutableUser.newUser(jiraUser);
builder.active(false);
ApplicationUser updatedUser = new DelegatingApplicationUser(jiraUser.getName(), builder.toUser());
UserService.UpdateUserValidationResult updateUserValidationResult = userService.validateUpdateUser(updatedUser);

Iterator iterator = updateUserValidationResult.getErrorCollection().getErrorMessages().iterator();
while (iterator.hasNext()) {
log.debug("Error Message :: "+ iterator.next().toString());
}

2 answers

1 accepted

1 vote
Accepted answer
Daniel Wester Community Champion Oct 06, 2017

I think the issue is that jiraUser is a User object and not an ApplicationUser. You'll need the userKey from the ApplicationUser object to be passed into the DelegatingApplicationUser constructor instead the username.

So something like:

jirarAppUser = userUtil.getUserByName(user.getSamAccountName());
ImmutableUser.Builder builder = ImmutableUser.newUser(jiraAppUser.getUser());
builder.active(false);
ApplicationUser updatedUser = new DelegatingApplicationUser(jiraAppUser.getKey(), builder.toUser());
UserService.UpdateUserValidationResult updateUserValidationResult = userService.validateUpdateUser(updatedUser);

Iterator iterator = updateUserValidationResult.getErrorCollection().getErrorMessages().iterator();
while (iterator.hasNext()) {
log.debug("Error Message :: "+ iterator.next().toString());
}

That should do it. If it doesn't, you may want to ask this question over at community.developer.atlassian.com .

Hi Daniel,

Tested with getKey() method of ApplicationUser instead of getUser() and it worked. Thank you for help.

0 votes

I don't think there's anything wrong with your code, I suspect the object "user" does not contain what you think it does.

I checked jiraUser object loaded successfully using the string it got from "user" object. The same code is working from groovy console but it is not working when we deploy as a plugin.  

Suggest an answer

Log in or Sign up to answer
Community showcase
Asked Thursday in Jira Ops

I'm John Allspaw, Ask Me Anything about incident analysis and postmortems

I'm John Allspaw, co-founder of   Adaptive Capacity Labs, where we help teams use their incidents to learn and improve. We bring research-driven methods and approaches to drive effective inciden...

452 views 2 5
View question

Atlassian User Groups

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

Find a group

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

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you