Amanda Bennett is a journalist and a co-founder of the Bloomberg Women’s Project.

Not long ago, I was part of a small group vetting candidates for a once-in-a-lifetime kind of job. Our research turned up example after example of one contender’s dismissiveness toward his female subordinates. Talented women had fled his command. His top management team was exclusively male.

The candidate entered the field a favorite yet never made the cut.

Both men and women talk a lot — too much — these days about why women can’t have it all.

We don’t talk enough about why some men think they can.

The Post reported last month on military commanders’ misconduct after reviewing recent inspector general investigations it received in response to Freedom of Information Act requests to the Army, Air Force, Navy and Marines. The documents, and other reporting, revealed more than garden-variety affairs. There was Brig. Gen. Bryan T. Roberts , who pledged zero tolerance for sexual harassment while he himself was being investigated for allegations of assaulting a girlfriend. There was Martin P. Schweitzer, an 82nd Airborne Division commander who, after meeting with a female member of Congress, e-mailed a colleague that the lawmaker was not only knowledgeable but also so “smoking hot” that he masturbated three times after the meeting.

On one level, it’s not surprising that these guys thought they could have it all. For the most part, they could. They could be powerful, respected, well paid, influential — and never had to outgrow their frat-boy behavior. There was never any real blowback.

Even as public displays of bias or crudeness became unacceptable, these men figured out how to show two faces. Many learned that it paid to mouth platitudes about “zero tolerance” and “equal opportunity” but that there was no real incentive to walk the walk. After all, they could check off the human resources training, give the “respect for all” speech and still tell crude jokes — or worse — on the golf course.

But little by little, we are seeing that, as we might tell 5-year-olds, choices have consequences.

In recent years, “bad boy” antics have cost governors (Eliot Spitzer), other politicians (Anthony Weiner) and the head of a major U.S. government agency (David Petraeus) their jobs. A star hangs in the balance for Schweitzer, who sent what, according to the investigative report, even he later agreed were “childish” and “truly stupid” e-mails. The question is, how do we, as a society, help speed the realization that there are genuine, and significant, political, social, moral and national security consequences to crudeness in one’s dealings with women?

If you are guarding the president on a foreign trip and consorting with prostitutes in your off-hours, those actions pose a risk — not just to you and not just of bringing home an STD. If you are in charge of a lot of spies, relying on a Gmail account for your clandestine affair could put an important government agency in harm’s way.

Joking with peers about masturbating at the thought of a congresswoman who helps look after funding for military assets not only helps create the harmful it’s-just-us-guys cover for bad behavior that you have been charged with stamping out but also subtly undermines the effectiveness of someone whose effectiveness you, and the rest of the military, count on.

Yet knowing the potential consequences clearly hasn’t been enough to persuade everyone to keep in line. And even the jocular commander, when caught, passed off his behavior the way clowns always do: Hey, it was a joke! That’s what people could do when the consequences were remote and theoretical.

Now the consequences are becoming personal. The realization that this type of nonsense might actually harm one’s career will help speed the shift in behavior in ways that mere concerns about fairness, or even national security, did not.

To me, the sad thing about the job-vetting experience is that the candidate we were so interested in never knew what could have been his — or why it wasn’t. He never knew that many women were willing to provide examples of his behavior — and many men, too. The backslapping code didn’t cover for him the way it might have in the past. The closed doors aren’t quite so closed any more.

Those trying to guess the candidate should stand down — it’s not who you’re thinking — but I wouldn’t totally discourage the guessing game if it causes some people to wonder: Could this have been me? Unfortunately, for all the changes brewing, too many people out there still haven’t been convinced that they cannot have it all, and probably shouldn’t.