We've imported our old mantis project. The users came along with it, but the user names are very random. I want to change all of them to the users email, so they can just come to the portal and do a password reset to get their account up and going again.
I have script runner, and I've seen a few scripts, but I'm not having much luck with it. I have a dev server setup where I can test my scripts. I don't know Java and I'm kind of lost as to what I want to do.
The users have the mantis-import-unused-users group assigned to them so I can use that to select them.
I want to then loop though them and change the username to their email address.
Thanks in advanced.
Kade,
Do you have some code for what you need to do to start with?
Are you using internal directory or some kind of ldap?
thanks!
The users are internal. Employees use LDAP. So I can't mess with that.
This looked promissing and a good start, but it doesn't seem to be quite compatable with my version of JIRA.
import com.atlassian.crowd.embedded.api.CrowdService
import com.atlassian.crowd.embedded.api.User
import com.atlassian.crowd.embedded.api.UserWithAttributes
import com.atlassian.crowd.embedded.impl.ImmutableUser
import com.atlassian.jira.bc.user.UserService
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.user.util.UserUtil
String result = ''
UserUtil userUtil = ComponentAccessor.userUtil
CrowdService crowdService = ComponentAccessor.crowdService
UserService userService = ComponentAccessor.getComponent(UserService.class)
User updateUser
UserWithAttributes user
UserService.UpdateUserValidationResult updateUserValidationResult
def groupNames = [
'mantis-import-disabled-users',
'mantis-import-unused-users'
]
userUtil.getAllUsersInGroupNamesUnsorted(groupNames).findAll{it.isActive()}.each {
user = crowdService.getUserWithAttributes(it.getName())
updateUser = ImmutableUser.newUser(user).active(false).toUser()
updateUserValidationResult = userService.validateUpdateUser(updateUser)
if (updateUserValidationResult.isValid()) {
userService.updateUser(updateUserValidationResult)
result += "Deactivated ${updateUser.name}\r\n"
} else {
result += "Update of ${user.name} failed: ${updateUserValidationResult.getErrorCollection().getErrors().entrySet().join(',')}\r\n"
}
}
return result
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.