The Prophet ﷺ ruled that any person whose lineage is claimed for him after the death of the father to whom he is attributed, with the heirs claiming him, the ruling is as follows. If he was born of a slave-woman whom the father owned at the time he had relations with her, then he is attached to the one who claimed him, but he has no share of the inheritance that was distributed before his claim was established. Whatever inheritance he reaches that has not yet been distributed, he receives his share of it.He is not attached in lineage if the father to whom he is attributed denied him during his lifetime. If he was born of a slave-woman the father did not own, or of a free woman with whom he committed fornication, then he is not attached to him and does not inherit, even if the one to whom he is attributed claimed him himself. He is a child of fornication, whether his mother was free or a slave.
حدثنا شيبان بن فروخ حدثنا محمد بن راشد ح و حدثنا الحسن بن علي حدثنا يزيد بن هارون أخبرنا محمد بن راشد وهو أشبع عن سليمان بن موسى
إن النبي ﷺ قضى أن كل مستلحق استلحق بعد أبيه الذي يدعى له ادعاه ورثته فقضى أن كل من كان من أمة يملكها يوم أصابها فقد لحق بمن استلحقه وليس له مما قسم قبله من الميراث شيء وما أدرك من ميراث لم يقسم فله نصيبه ولا يلحق إذا كان أبوه الذي يدعى له أنكره وإن كان من أمة لم يملكها أو من حرة عاهر بها فإنه لا يلحق به ولا يرث وإن كان الذي يدعى له هو ادعاه فهو ولد زنية من حرة كان أو أمة
Sourcing, its chain of transmission is hasan. Ibn Majah reported it in the Book of Inheritance Shares, Chapter on Claiming a Child, no. 2746, from the hadith of Muhammad bin Rashid, transmitted with this chain, and Busiri graded it hasan. Ahmad also narrated it, 2/181, from Yazid bin Harun, transmitted with this chain.