Hello Yamini,
The cause of the behavior is that an external group doesn't know its members at all. Instead, when a user logs in, the system checks which external groups he or she fits into and assigns them to him or her.
So you have to do it the other way around and ask the users to which external groups they belonged at the last login. (<user>.getExternalGroups())
ATTENTION: the data is of course more or less outdated, depending on when the user last logged into FirstSpirit and what changes have been made to the external user management (LDAP?) since then.
Alternatively, the corresponding information can also be determined in the external user management system by checking there (outside of FirstSpirit) to which users the definition of the external group applies.
Best regards
Holger