It is narrated from Sayyiduna Amr bin Kharijah (may Allah be pleased with him); he said: I was beneath the she-camel of the Prophet (peace and blessings be upon him) while she was chewing her cud, and her saliva was dripping between my shoulders. In that state I heard him (peace and blessings be upon him) say: "Indeed, Allah, the Mighty and Majestic, has given every rightful claimant his due right, so no (separate) bequest is permissible for an heir. The child belongs to the (lawful) bed, and for the fornicator is the stone (that is, deprivation). Whoever attributes himself to someone other than his father, or attributes himself to someone other than his true patrons out of aversion to them, upon him is the curse of Allah, the angels and all people; neither a voluntary nor an obligatory deed will be accepted from him."
Hadith Referenceالمعجم الكبير للطبراني / باب العين / 14132