Retrieving Azure AD security groups assigned to users


We are trying to retrieve groups assigned to users in Azure AD. Below is the rule that we have added to check if we can see what groups are assigned to a user.

function(user, context, callback) {
console.log(“mapGroupClaimToUserProfile start”);
context.idToken[‘group.names’] = user.groups;
console.log(‘hasgroups -->’ + user.hasgroups);
console.log(‘group.names’ + “–>” + user.groups);
console.log(‘context.groups’ + “–>” + context.groups);
console.log(“mapGroupClaimToUserProfile end”);
callback(null, user, context);