Check every xyz seconds of the game if a unit has the aura buff. if so, add magic immunity item ability to the unit and add it to a unit group.
this group should be excluded from the previous check.
Now a 2nd trigger detects every xyz seconds of the game if a unit has that buff not anymore. if so, remove the magic imunity ability from that unit.
for adding and removing, I'd suggest a custom named ability that renders magic immunity and to remove that one so you won't have any issues interfering with other abilities that might give mgic immunity as well.