That two-year total ranked as the highest among the state’s sheriffs and district attorneys, a Globe survey of campaign ­records from 2008 through 2012 found.

But McDonald was far from alone in receiving sizable sums from his subordinates.

The sheriff in Essex County, Frank G. Cousins
Jr., had ­received close to $200,000 since 2008 until he ended the practice last year amid allegations that he pressured subordinates to donate. Among district attorneys, Timothy J. Cruz in Plymouth County has ­received about $61,000 in gifts from office employees since 2008.

At the same time, however, seven elected officials have chosen not to take contributions from their staffs.

Employee contributions are legal, and elected law enforcement officials have long looked to their own staff to build up campaign funds. But under the state’s conflict-of-interest law, public employees are prohibited from “using their authority to solicit campaign contributions or services, or anything else of substantial value from subordinate employees.”

Many elected county officials sidestep the practice to avoid any appearance of professional pressure, and some say employee fund-raising, no matter how passive, is inherently coercive.

“It clearly raises red flags,” said Craig Holman, government affairs lobbyist for Public Citizen, a Washington, D.C., ­advocacy group. “People can certainly feel compelled to donate, and people who don’t participate can easily feel shunned. It essentially creates a hostile work environment.”

Pam Wilmot, who directs Common Cause Massachusetts, said the scope of the contributions in some cases suggests a “culture where contributions are expected.”

“There are clear ethical standards,” she said. “There can’t be direct or implied pressure to give, and any consequences are unacceptable.”

Officials who accept donations from their workers staunchly defended the practice, saying that the money plays no role in personnel decisions and that employees are under no obligation to contribute.

Cruz defended the decision whether to donate as a personal one that has no influence on how the office is run.

“Employees of the office are not expected or required to participate in political campaigns,” he said in a statement. “In fact, employees are free to participate in the political process in any manner they choose. Such personal political decisions by employees have no impact upon their employment status or the mission of this office.”

Michael W. Morrissey, the Norfolk district attorney who was elected in 2010, has raised $20,000 in the past two years.

Morrissey said he does not solicit donations, but is open to accepting them. A former state senator, Morrissey has long held an annual fund-raiser to which employees are welcome, but they are not urged to ­attend.

“I don’t discourage or ­encourage,” he said.

McDonald, of Plymouth County, said he takes a neutral stance on donations, yet worries that some employees may believe that donations could help their standing in the ­office.

“It bothers me, and it’s an unfortunate perception, ­because in this office it’s only a perception,” he said, adding that hirings and promotions are based on competitive ­exams.

Bristol County Sheriff Thomas Hodgson, who has ­received $91,000 in donations from his 560 employees over the past five years, said he makes it clear that promotions are based on merit, to avoid creating a climate where ­employees feel obliged to ­donate.

“You don’t want to create an environment where people who support you, who contribute to you, have an advantage over anyone else,” he said.

Cousins,
the sheriff in Essex County, collected far more ­gifts from his 515 employees than his counterparts over the past five years. He said he never pressured workers to donate, but last year, amid allegations that he was pressuring them, he pledged to stop accepting employee contributions. “I thought it was the right thing to do,” he said. “I made a decision, and I think it was a good thing.”

Others said they have set policies against the practice for the sake of their employees.

“I’d rather not have any employees feeling in any way, shape, or form that they have to contribute,” said Michael O’Keefe, district attorney of Cape Cod and the islands. “They make precious little money as it is.”

During campaigns, O’Keefe said he sends out a note reminding employees of his policy. He added that he “finds no fault” with those who accept donations from employees and said workers have a right to contribute if they wish.

Gerard T. Leone Jr.,
district attorney in Middlesex County, said he steers clear of the issue altogether, to the point of returning contributions from ­employees. “The standard in our business is to avoid the very appearance of conflicts of interest or impropriety,” he said.

Lewis Evangelidis, the sheriff in Worcester County since 2011, said he made it clear from the outset that he would not accept donations from employees.

“When I ran for office, there was kind of a culture of patronage, and I felt the cleanest way to break that was to start a policy of not accepting contributions from employees or their families,” he said. “I didn’t want anyone to believe that anyone is going to get preferential treatment or not be held accountable because of a perceived perception they gave to a campaign.”

The Globe’s tally of employee contributions is approximate. Totals include contributions from donors who identified themselves as employees and donors whose employment could be determined by payroll records.

When it was uncertain whether a donor worked for the office, the contribution was not counted, meaning the estimates could undercount the actual totals.

David Capeless, the district attorney in Berkshire County, does not track who contributes and said many longtime staff members decide on their own to make donations.

“I don’t deny them the oppor­tunity,” he said. “It’s their right as citizens.”