Set User Role at runtime

Hi Guys!
I’m using a AD/Database Hybrid User Source, I require to set the User Role based on the AD Group the user belongs to. I could get the User data from AD using the system.security.getUserRoles() script function, but I didn’t found how to set the user role at runtime, I mean, after login. Is it possible?

Thank you in advance!

Claudio

And what about to refresh the current user profile once the User data get updated after he/she is already logged in?