It is completely legal unless there is some legal process--e.g. a warrant executed by the police; a subpoena, written interrogatories, or a document production request in a civil trial--which requires this information. Otherwise, a landlord is not required to disclose the identify of his tenants to anyone (though if he applies for a mortgage, the bank may require such disclosure as a condition of the mortgage; in that case, the landlord chooses to disclose to apply for the loan).