Artificial intelligent assistant

$X=ABA^T$, X, A are matrix and need to solve matrix B by enforcing it as a diagonal matrix. $X=ABA^T$, X is a square matrix and A is rectangular matrix and I need to solve matrix B by enforcing it as a diagonal matrix. For non-singular matrix we can write B as $A^+XA^{+T}$, but B gets to be non-diagonal matrix. How can I get B as diagonal matrix. (Eigen decomposition of X gives different values of A).

If the problem is to find the diagonal matrix $B={\rm Diag}(b)$ which minimizes $$f(B)=\| ABA^T- X \|_F^2$$ then neither of @frank's results will work.

Instead solve for the vector $b$ which zeros the gradient of the function, i.e. $\frac{\partial f}{\partial b}=0$

$$\eqalign{ Y &= ABA^T - X \cr f &= Y:Y \cr \cr df &= 2Y:dY \cr &= 2Y:A\,dB\,A^T \cr &= 2A^TYA:dB \cr &= 2A^TYA:{\rm Diag}(db) \cr &= 2\,{\rm diag}(A^TYA):db \cr \cr \frac{\partial f}{\partial b} &= 2\,{\rm diag}(A^TYA) = 0 \cr \cr {\rm diag}(A^TABA^TA) &= {\rm diag}(A^TXA) \cr \big((A^TA)\circ(A^TA)\big)\,b &= {\rm diag}(A^TXA) \cr \cr b &= \big((A^TA)\circ(A^TA)\big)^+\,{\rm diag}(A^TXA) \cr B &= {\rm Diag}\Big[\big((A^TA)\circ(A^TA)\big)^+\,{\rm diag}(A^TXA)\Big] \cr }$$ where colon denotes the inner/Frobenius product, i.e. $\,A:B={\rm tr}(A^TB)$

xcX3v84RxoQ-4GxG32940ukFUIEgYdPy 8cc300a0976d5cafba8837d73d724b7f