Since this is an only-in-Salem type of event, there are no real-world precedents. That said, Adrienne wasn't like an innocent person who was convicted and sent to prison. In such cases, a court order would be needed to free her. Here, however, she's actually a kidnap victim who's been dumped in a prison. Since she wasn't placed in prison by the judicial system, no court order would seem to be needed, just proper identification. Justin should really sue on the grounds that the prison negligently failed to properly identify Adrienne as soon as she told her story, and thereafter denied her civil rights be not allowing her to contact an attorney or family member. (Of course, as others have said, the mighty Victor could have resolved the whole thing with one phone call to the governor. Nobody, except maybe Bonnie, says no the Salem grouch.)