I do something very similar on my site - a user can select which modules they want displayed on the front page (a bit like a web parts catalog). Depending on which modules they chose I am amend their roles.
In order for this to work without logging out I use these commands to add/delete roles:
Add
DotNetNuke.Security.Roles.RoleController.AddUserRole(dnnUserInfo, RI, PS, DateAdd(DateInterval.Minute, -10, Date.UtcNow), Date.MaxValue, UserId, False)
DotNetNuke.Entities.Users.UserController.UpdateUser(PortalId, dnnUserInfo)
Delete
Dim RC As New DotNetNuke.Security.Roles.RoleController
RC.DeleteUserRole(PortalId, UserId, RI.RoleID)
DotNetNuke.Entities.Users.UserController.UpdateUser(PortalId, dnnUserInfo)
I then do a post back to my site using Response.Redirect(NavigateURL())
Then when redisplaying my roles I use the following:
'Clear Cache
DataCache.ClearUserCache(PortalId, UserId)
DotNetNuke.Security.PortalSecurity.ClearRoles()
Dim lstUserRoles As String()
lstUserRoles = objRoles.GetRolesByUser(UserId, PortalId)
This does work!
As a side note I am sure that I have read that dynamic role modifiications is supported in DNN v5.0 - maybe someone from the Core team can confirm this?