IANAL, I'm a libertarian and against all forms of ad-hoc searches, but I think the government has a point here. As I understand this the goal is to control contraband and weapons entering the prison system. I don't see any way you could get around having to to search all those entering.
But that's a different situation than being searched for a crime. If I understood this correctly, this is simply an administrative search, not a search in search of evidence. Or put another way, if you get arrested for a joint and during the search the cops find cocaine, I'm not sure that would mean much of anything. (except you lose your cocaine)
But I'm probably completely off-base.