A onetime Lakeville middle school principal pleaded guilty Monday to numerous crimes including stalking, burglary and identity theft.

Christopher J. Endicott, 51, of Apple Valley, admitted in Dakota County District Court to two counts of gross-misdemeanor stalking, two counts of felony burglary and one count of felony identity theft. The crimes were committed over a five-year span until June 2018.

Endicott is scheduled to be sentenced on June 17, when defense and prosecuting attorneys will argue over the length of his term — as little as probation or as much as 13 ½ years. As part of the plea deal, one count each of gross-misdemeanor burglary and felony transaction card fraud will be dismissed.

Apple Valley police began investigating Endicott, then principal of Century Middle School in Lakeville, in January 2018 after receiving reports that the school district’s information technology system had been hacked. Officers said that led them to search Endicott’s home and office as well as the office of his wife, a counselor at Scott Highlands Middle School in Apple Valley.

Electronic devices and a paper notebook that investigators found held the key to many of Endicott’s alleged hacking activities, according to the charges. The notebook, found in a drawer in his school office, was filled with password hints, account numbers, login information and other personal information associated with at least 15 victims.

Endicott cracked security measures and got access to bank accounts, credit cards, airline rewards programs and store memberships to such places as Sam’s Club.

Many of those hacked had connections to Endicott’s former school district as fellow employees, court documents showed. Police say he used the victims’ credit card information to make purchases, including charges on pornography websites, a gold and silver dealer and an online bookstore.

While authorities were investigating the identity theft allegations, they contacted a woman who said she had been harassed by Endicott for years and feared him, the charges said.

She told investigators that she worked with Endicott in 2012 and had been in a relationship with him. The woman reported that Endicott became upset when she tried to end the affair, according to the complaint.

Police say Endicott then began stalking the woman, hacking her electronic accounts, getting access to her personal information and contacting a person she was dating at the time.

The detective who started the initial investigation also reported being stalked by Endicott. On two occasions, Endicott crossed the electronic barrier placed around the detective’s home, according to authorities.

Still pending against Endicott are burglary and theft charges in North Dakota, where he allegedly stole rare coins from his in-laws’ home in Grand Forks.