How to determine an unitary operator involved in an unitary transformation?

Let two real matrices $A$ and $B$ be unitarily equivalent. How to determine (computationally or theoretically) the unitary operator $U$ s.t. $A = UBU^\dagger$? Is it possible for some special class of matrices? Please give me some references.