I think we can do this from the back end.
PSROLEUSER is the table involved in mapping role to a user.
create a script to insert into the PSROLEUSER.(this table have only 3 fileds to be inserted.)
From Front end, one can add/delete the roles for a user from the below navigation.
People Tools > Security > User profiles > User profiles > Enter the user ID and search > Go to the Roles Tab.
From Back End, PSROLEUSER is the Delivered record where user roles get stored.