Both sides in the continuing legal war over random drug testing of federal employes scoured Tuesday's court decision on drug testing of D.C. school system employes for clues about the eventual constitutional fate of the federal plan.

Both sides declared victory, of sorts.

Assistant Attorney General Richard K. Willard, head of the Justice Department's Civil Division, said the ruling -- although "narrowly written" -- should bolster the government's argument that random testing does not violate the Fourth Amendment's prohibition against unreasonable searches and seizures.

Lawyers for the American Civil Liberties Union and a number of federal employe unions seized on language in the opinion holding that urine tests, which measure only recent drug use, do not show whether employes are impaired on the job and therefore do not provide the required link between the employer's safety concern and the testing program.

The ruling, by a three-judge panel of the federal appeals court here, involved Juanita Jones, an attendant on a D.C. school bus for handicapped children, who was fired after urinalysis indicated that she had used marijuana. The school system agreed to a lower court's order reinstating Jones with back pay, but appealed a broad ban against testing employes without probable cause to believe they are using illegal drugs.

The panel overruled that prohibition and permitted the school system to test employes with safety-related jobs during routine medical exams. Writing for the panel, Judge Harry T. Ewards said the employes' "strong privacy interests" are outweighed by "serious safety concerns."

However, the panel, which also included Judges Douglas H. Ginsburg and Kenneth Starr, stressed that the school system did not assert power to test employes without any reason to suspect drug use outside the context of regular physical examinations -- and thereby ducked the larger question of the constitutionality of random testing.

The decision was the latest to deal with a controversial legal issue that appears destined ultimately for resolution by the Supreme Court. Although lower federal courts initially appeared disposed to strike down drug-testing plans as unconstitutional, recent decisions from federal appeals courts across the country suggest a more accepting attitude toward such programs.

The 5th U.S. Circuit Court of Appeals in April upheld the Customs Service's testing of employes seeking promotions into certain "sensitive positions," noting that "use of controlled substances by employes of the Customs Service may seriously frustrate the agency's efforts to enforce the drug laws." The National Treasury Employees Union has asked the Supreme Court to review the case.

Another appeals court this year upheld Iowa's random testing of prison guards who regularly come into contact with inmates in medium- or maximum-security facilities, saying that drug use by such guards "poses a real threat to the security of the prison." Last year, a federal appeals court upheld New Jersey's random testing of jockeys.

"We haven't fared so well on the appeals level," said Arthur B. Spitzer of the ACLU's Washington office, who represented the bus attendant in the D.C. case. "I certainly don't put this case in the ruled-against category. I really think it's unfortunately a much more narrow decision than either side had anticipated."

President Reagan, in an executive order last September, required all federal agencies to establish programs to test employes holding "sensitive positions" for drug use. The Transportation Department in September became the first civilian agency to launch random testing, and a handful of other agencies have been testing job applicants and employes in certain situations.

The Justice Department had filed a friend of the court brief in the D.C. case, Jones v. McKenzie, asserting that urine tests do not constitute a search under the Fourth Amendment -- an argument rejected by the court -- and that in any case the drug testing plan in this case was reasonable.

"This opinion joins a whole series of other legal opinions by other courts of appeals that if the government's interest is strong enough . . . you can test without having to have some probable cause," Willard said. He noted, however, that "the court did point out that what they were talking about there was the routine medical examination" and that random testing is "a different issue."

Union lawyers, for their part, were encouraged by the court's statement that the urine tests lack sufficient connection to the school system's "legitimate concern" about preventing drug use on the job.

Elaine Kaplan, assistant counsel of the National Treasury Employees Union, said that "under the court's decision in this McKenzie case, the federal government couldn't conduct tests of employes if it has no legitimate interest in whether they use drugs off-duty."

Willard argued that while the D.C. policy at issue prohibited only on-the-job drug use, the executive order establishes a federal policy against using illegal drugs on or off duty. "In our view if someone in a sensitive job -- an FBI agent or an air traffic controller or a surgeon who works for the government -- is using cocaine or other drugs off-duty, then that's a matter of legitimate concern," he said.