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

Srinivas Patruni October 5, 2017

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
Answer accepted
Daniel Wester
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 6, 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 .

Srinivas Patruni October 13, 2017

Hi Daniel,

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

0 votes
Nic Brough -Adaptavist-
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
October 5, 2017

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

Srinivas Patruni October 5, 2017

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
TAGS
AUG Leaders

Atlassian Community Events