WASHINGTON — President Barack Obama, after months of sitting on the sidelines of the rancorous contest to succeed him, is now ready to aggressively campaign for Hillary Clinton, starting with a formal endorsement of her candidacy as early as this week.

The White House is in active conversations with Clinton's campaign about how and where the president would be useful to her, according to senior aides to Obama.

Advisers say that the president, who sees a Democratic successor as critical to his legacy, is impatient to begin campaigning. They say he is taking nothing for granted.

It has been decades since a second-term president enjoyed the popularity to make him a potent force on the campaign trail and also an invitation from the candidate running to succeed him to be a major presence there.

Obama's approval rating was at 50 percent in this month's New York Times/CBS poll, and strategists close to Clinton said they would be eager to have his participation as the general election unfolds. (In contrast, President George W. Bush's approval rating was at 20 percent in a Gallup poll just before the November 2008 election, and he rarely appeared that year with Sen. John McCain of Arizona, the Republican nominee.)

Obama is particularly enthusiastic, aides said, about taking on Donald Trump. The Republican candidate has personally offended the president with his conduct on the campaign trail — Trump referred to a black supporter on Friday in one of his crowds as "my African-American" — and as the most visible champion of the "birther" conspiracy theories that falsely hold that Obama was born in Kenya rather than Hawaii.

Should Clinton do well enough in the primaries on Tuesday to give her sufficient delegates to claim the Democratic nomination, Obama is likely to move swiftly to make a case for her.

"He has indicated he wants to spend a lot of time on the campaign trail, so when it's time to do that, we'll go out guns ablazing," Jennifer Psaki, Obama's communications director, said in an interview. "We are actively thinking through how to use the president on the campaign trail — what works for the nominee, what works for him, and how to utilize his strengths and his appeal."