If the tenants are residential renters they are protected if they are stores, in the building they can be evicted.
The basic rule for commercial leases in foreclosure is called "first in time, first in right." If the mortgage was recorded before the lease was signed, the general rule is that the lease is wiped out.
This allows the new owner of the property to do with it as they please -- typically sell it, lease it to the current occupants or lease it to someone else. The new owner can evict the current tenant (even if the tenant has fully complied with their lease), but typically must get court permission to do so.
Some leases (or agreements accompanying leases) contain subordination, non-disturbance and attornment clauses. Attornment means agreement to remain as a tenant with a new landlord
Title VII of the Helping Families Act (the “Act”) is entitled “Protecting Tenants at Foreclosure” and generally requires the immediate successor-in-interest on foreclosed property to recognize the lease rights of existing tenants on the property.
The Act applies to any property where there has been a foreclosure on a “federally-related mortgage loan or on any dwelling or residential real property” after May 20. “Federally-related mortgage loan” is defined in RESPA as being limited to mortgages on property “designed principally for the occupancy of from one to four families.” Therefore, the Act’s requirements apply only to residential, and not commercial, property.