You must read your lease. Hopefully, your lease has a clause that states something like:
"This Lease is binding upon Landlord and Tenant and their respective assignees and/or successors in interest."
and not something to the contrary.
Additionally, if your landlord is foreclosed on, the new owner is required by law, with a few exceptions, to honor your existing lease or to give you 90 days to move (see http://vaughnweberlaw.com/2010/05/17/tenants-foreclosure/)
Law Firm of Vaughn & Weber, PLLC
217 Willis Ave.
Mineola, NY 11501