All perfect praise be to Allaah, The Lord of the Worlds. I testify that there is none worthy of worship except Allaah and that Muhammad is His slave and Messenger.
This hadeeth was reported by Ibn Hibbaan in his Saheeh, and it was reported by others with some variation in its wording from what you have mentioned in the question. Ibn Hibbaan reported from ‘Abdullaah ibn ‘Amr that the Prophet said:
“Sulaymaan ibn Daawood (Solomon, the son of David) asked Allaah to grant him three things. Allaah gave him two, and I hope that the third one has also been granted to him. He asked Him for a kingdom the like of which no one after him would have, and Allaah granted him his wish. The second was to enable him to judge with the truth, i.e. with a judgment that is in conformity with Allaah’s judgment, and He granted this to him. The third thing was that he asked Allaah that any person who comes to this House (i.e. Al-Aqsa Mosque) wanting nothing but to pray in it, that he leaves it as if he has just been born (i.e. with all his sins forgiven) ... I hope that Allaah granted him the third one as well.” [Al-Albaani classified it as saheeh (sound), and Shu'ayb al-Arna’oot said, “Its chain of narrators is saheeh.”]
Allaah knows best.