The answer to that is: In many circumstances it is legal, but it depends on the purpose for the search, the kind of information obtained and the method of doing the search.