It all depends on how the company handles it. Yes it is illegal, but some companies will find "other reasons" to not hire you.

Less than a year out of bk, my husband applied for a job that we really figured he wouldn't get because of our credit history/bk. He would be turned loose with a company van, computer, cell phone & credit card with the nearest boss 600 miles away. We were thinking with that much at stake they wouldn't allow someone with bad credit to be trusted, but he got the job. The bankruptcy was never an issue.