I'm using the code pretty much exactly as you posted above, with the only changes being the custom fields being set, and I only populate the identityData structure with the username. Does the identity data need to have both username and emailAddress?

Who ran the server extension?This sample code is used for updating the user who executed this server extension.params.username would be the new username.if you set the existing username as params.username, USER_ALREADY_EXISTS error will occur.