Hello,
i have a field, which is populated by a behaviour.
The result shows all roles with members of the underlying project. The result is OK for any project administrators, but not for standard users (error in log for getting roles and members).
Is it possible to run the behviour under an admin user?
Best regards,
Harald
No, because that would mean the client (the user's browser) would have to log in as an administrator.
@Harald Hiebl you could try setting the authenticated user to a service account user with the correct permissions.
You would need to make sure to set the authentication context back, whatever the outcome.
I haven't tried this with Behaviours specifically, but I have made use of this in workflows and other automations.
import com.atlassian.jira.component.ComponentAccessor
// get the Service Account user
def serviceAccount = ComponentAccessor.userManager.getUserByName('serviceaccount')
// get the currently logged in user
def currentUser = ComponentAccessor.jiraAuthenticationContext.loggedInUser
// set the current user to the service account user
ComponentAccessor.jiraAuthenticationContext.setLoggedInUser(serviceAccount)
try {
// perform your processing as user with elevated permissions
} finally {
// make sure to reset the authentication context
ComponentAccessor.jiraAuthenticationContext.setLoggedInUser(currentUser)
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello Gareth,
thank you very much - it works as expected
Harald
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.