Col. James E. Longhofer, who once ran the Army division responsible for secret operations, yesterday was convicted of disobeying a lawful order, dereliction of duty and conduct unbecoming an officer, the Army announced. Most of the testimony and witnesses' names in the court-martial were secret.

Longhofer was sentenced last night to two years of confinement, forfeiture of $1,000 a month in pay for two years and a reprimand. His lawyer said last night that Longhofer maintains his innocence and that the conviction will be appealed.

The charges stem from a two-year probe by the Army. Prosecutors alleged that some of the Army's special operations units, which Longhofer headed in 1981 and 1982, were spending improperly and using incorrect accounting practices.

None of the charges against Longhofer, an intelligence officer, alleged financial misconduct.

The trial was the second of five stemming from the probe. The first ended in the acquittal of Master Sgt. Ramon Barron.

Longhofer was charged with being derelict for failing to report allegations of financial misconduct by a junior officer, Lt. Col. Dale Duncan, in 1983. Duncan has been convicted of theft and making false statements and was sentenced to a year in prison. He is appealing the conviction.

Longhofer was also alleged to have offered Duncan's secretary a higher-paying job so that she would not talk about the allegations against Duncan.

Supporters argue that the controversial spending investigation is necessary to ensure that soldiers account properly for funds received for clandestine operations. But some opponents have criticized the length of the investigation and have charged that it was prompted by officers uncomfortable with Army involvement in covert activities.

Longhofer's lawyer, Tom Buchanan, said last night that he did not object to the secrecy of the trial but complained that the military jury applied "20/20 hindsight" to Longhofer's work in special operations, which he said was "virgin soil" for which "there were no rules or regulations."

Buchanan expressed the view that the conviction of Longhofer, a helicopter pilot decorated for bravery in Vietnam, would have "a significant deterrent effect on others joining special operations."