It is narrated from Sayyiduna Kharijah bin Amr al-Jumahi (may Allah be pleased with him); he said: The Messenger of Allah (peace and blessings be upon him) said on the day of the Conquest of Makkah, while I was beside his she-camel: "There is no bequest for an heir; Allah, the Mighty and Majestic, has given everyone who has a right his right. And for the fornicator is the stone. Whoever attributes himself to someone other than his father, or claims allegiance to other than his freeing masters, upon him is the curse of Allah, of the angels and of all the people. On the Day of Resurrection Allah will not accept from him any obligatory or voluntary act of worship."
Hadith Referenceالمعجم الكبير للطبراني / باب الخاء / 4125