Use LDAP for login but map with different database for Groups?

I’m trying to extend the LdapIdentityProviderPlugin for the users, but I want the group queries to be done to another separate database. How would I do this?