If you’re being sued for shady business practices, it’s probably best not to engage in more of them. That’s a lesson Uber learned the hard way after a federal judge punished the company for hiring a private investigator to attempt to dig up dirt on a man who filed a class-action lawsuit against it.

In a ruling handed down on Monday by Judge Jed Rakoff of the District Court for the Southern District of New York, Uber and Ergo—the private investigation firm hired by the ridesharing company—were found to have likely broken several laws while trying to gather personal information about plaintiff Spencer Meyer and his lawyer Andrew Schmidt of Maine.

Meyer, an environmental researcher at Yale University, filed suit in December against Uber CEO Travis Kalanick, claiming that Kalanick and his company were engaging in illegal price-fixing. The suit cited practices that Uber has regularly come under fire for, including it surge pricing model and the claim that drivers are independent contractors rather than employees.

The same day Meyer filed suit against Uber, the company’s general counsel, Salle Yoo, contacted its chief security officer and asked, “Could we find out a little more about this plaintiff?”

After a brief back and forth between Yoo and Uber chief security officer Joe Sullivan, the tech firm decided to outsource its investigation with Ergo, an investigative firm run by former CIA and State Department employees.

Uber paid $19,500 for the service, which took about a month and included an investigator contacting 28 people with connections with Meyer and his lawyer, including friends, former colleagues, and a former landlord.

However, rather than telling the subjects of interviews why they were being contacted, the Ergo investigator lied to the subjects. He spoke to them under a variety of guises, including attempting to verify the professional record of “up-and-coming researchers” for a “research project,” and “profiling” rising stars practicing labor law.

When another lawyer working on Meyer’s case became aware of the investigator, they raised the issue with Uber. The company continuously denied its involvement until it became clear it would have to own up to the action, especially given the role of the company’s top executives in the decision to attempt to find dirt on Meyer.

Once it was clear the company would have to admit to the investigation, Uber’s lawyers claimed they were concerned Meyer may have been a “safety threat” to Kalanick and other Uber employees.

For all the trouble, Uber didn’t get much of value out of the whole process; Ergo’s investigators reported that “No one really said anything negative about him,” but suggested that they could “extrapolate and say that he is a bit of an ‘idiot savant’ or naive outside the ivory tower of academia.”

Ergo’s report did note Meyer may be “particularly sensitive to any publicity that tarnishes his professional reputation” and suggested that may be used as an angle to attack the plaintiff.

In his ruling, Judge Rakoff called the investigation “blatantly fraudulent and arguably criminal” due to the deceptive practices of the investigators, Ergo’s lack of a private investigator’s license to operate in the state of New York, and the investigator’s recording of calls with subjects based in states where recording others without consent is illegal.

“It is a sad day when, in response to the filing of a commercial lawsuit, a corporate defendant feels compelled to hire unlicensed private investigators to conduct secret personal background investigations of both the plaintiff and his counsel,” Judge Rakoff wrote in his decision. “It is sadder yet when these investigators flagrantly lie to friends and acquaintances of the plaintiff and his counsel in an (ultimately unsuccessful) attempt to obtain derogatory information about them.”

As a result of the ruling, Uber has been barred from using any information gathered by Ergo and prohibited from pursuing further investigation. The company also agreed to cover all litigation relating to the probe.

“Even though the deceptive investigation only highlighted Mr. Meyer’s sterling personal and professional reputation, we are pleased with the Court’s opinion,” Andrew Schmidt, the lawyer involved in Meyer’s class-action suit, told the Daily Dot.

The Daily Dot reached out to both Uber and Ergo with request for comment on the ruling. Neither responded at the time of publication.

H/T Gothamist