Hi all.
on a Jira Core server instance, I'm trying to set a user as inactive programmatically (using Java, no scripts) .
But the
UpdateUserValidationResult updateUserValidationResult = userService.validateUpdateUser(updateUser);
checks the jira authenticated user. But I'm trying to do this using a cron service.
How can I set a user inactive programmatically ?
Is this allowed ?
Thank you in advance
Francesco
If the underlying API uses the logged-in user, you can workaround this using: https://docs.atlassian.com/software/jira/docs/api/9.4.17/com/atlassian/jira/security/JiraAuthenticationContext.html#setLoggedInUser-com.atlassian.jira.user.ApplicationUser-
I.e. get the "automation user" via usermanager, set it via JiraAuthenticationContext, continue with rest of the code.
Assuming the cron job is using any of Jira's threadpools, you'll probably want to set the logged in user back just in case it could leak to other jobs/tasks. Not really a problem with standalone runnables but theoretically might be if the underlying thread will be re-used by something else, so I'd probably just store whatever current user there is, run the code, then switch it back in finally block.
That's perfect, it works. Thank you very much. My problem was the null authenticatedUser. Now I set it to a service user allowed to do the operation and then, just for cleanliness, I put the null back.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.