It seems that you are trying to add active users in your tenant to a dynamic user security group in Azure B2C <sup>1</sup>. You have tried a query to add the users, but it is not working as you are trying to exclude “Sign-in blocked” and unlicensed users and guest users from being added to the dynamic user security group <sup>1</sup>. You are wondering what the membership rule should be to exclude these users.
To exclude “Sign-in blocked” and unlicensed users and guest users from being added to the dynamic user security group, you can use the following membership rule:
(user.accountEnabled -eq true) and (user.userType -ne "Guest") and (user.assignedLicenses -any (assignedLicense.servicePlans -any (servicePlan.serviceName -eq "SHAREPOINT") -and assignedLicense.disabledPlans -notContains "SHAREPOINT")) and (user.signInNames -notContains "blockedsigninname")
This membership rule will add only active users who are not “Sign-in blocked” and unlicensed users and guest users to the dynamic user security group <sup>2</sup>.
I hope this helps you!