What I am trying to do is execute code to integrate with an external system and retrieve logged in user's information and add him to appropriate roles in Alfresco based on that information.
One option that I can think of is - check if you can customize login web script itself to achieve this. In login web script, if authentication is successful then do your custom processing and then return response back. See if this work or not.