Officials have revealed that Micah Johnson, who shot five cops in Dallas, sexually harassed a female soldier in Afghanistan. Before dying, Johnson told the cops he wanted to kill white officers.

Johnson served as a private first class in the Army Reserve for six years. But while serving in Afghanistan in 2014, a female soldier accused him of sexual harassment when he allegedly bought her items from Victoria’s Secret.

She asked her superiors for a restraining order:

“She asked for protection from him and as a result of that they kicked him out of Afghanistan and sent him back to the United States and initiated an involuntary separation action against him,” lawyer Bradford Glendening told the Daily News.

Glendening said he received a scanned copy of the victim’s complaint that was hard to read — but he was able to decipher at least one alleged incident.

“I could distinctly read in there something about purchasing Victoria’s Secret clothing for her,” he said. “I’m sure he created a hostile work environment by being sexually forward with her.”

The army removed him from Afghanistan to get him away from her. Gardening said Johnson’s command did not like him, calling him a “black sheep.” He explained that Johnson “wasn’t overtly disrespectful but he also didn’t carry himself in a respectful way.”

Authorities discovered weapons and bomb-making materials in his home:

During a search of Micah Xavier Johnson’s home, detectives found bomb making materials, ballistic vests, rifles, ammunition, and a personal journal of combat tactics, the Dallas Police Department reported late Friday.

A friend said that he changed when he came back from Afghanistan:

“When he came back from Afghanistan, he got in touch with some bad folks and went all Black Panther,” the man, who asked not to be identified, told FoxNews.com.

Authorities could not find any connection to Black Lives Matter, who staged the protest in Dallas.

Another friend said Johnson would never hurt anyone, while adding, “His shots were terrible.”

As he barricaded himself in a parking garage with the cops, he confirmed that the recent cop shootings had angered him:

“The suspect said he was upset about Black Lives Matter,” Dallas Police Chief David Brown said Friday morning. “He was upset about recent police shootings. He was upset with white people.

“He wanted to kill white people, especially white police officers,” Brown added. “The suspect said he was upset at white people.”