Is there is a way set a callback function to determine the user's role after logging in?

Description

I am using Rocket Chat inside of an iFrame in my website. Some users do use phone app to chat as well. I am also using LDAP authentication and all users are treated the same in AD. Nothing there indicates their role. I am hoping for a way that rocket chat can be configured to call a third party service that would determine their role.

For example, after the user XYZ login, rocket chat will authenticate them and then make a call to https://some_custom_comain.com/api/user/get-roles/XYZ where that API will return something like the following to determine what should the user’s role be

{
    "result": "success",
    "roles": [
         "user",
         "admin"
    ]
}

I have a Is there is a way set a callback function to determine the user’s role after logging in?

If a callback is not an option, is there a way that I can override how the users are authenticated in rocket chat and what roles they should have? In other words, I would create an API that would authenticate the user against LDAP and determine what role they should have. The logic on what role they would have would be determined by my application outside of rocket chat and LDAP.