حَدَّثَنَا مُحَمَّدُ بْنُ يَحْيَى، حَدَّثَنَا مُحَمَّدُ بْنُ بَكَّارِ بْنِ بِلاَلٍ الدِّمَشْقِيُّ، أَنْبَأَنَا مُحَمَّدُ بْنُ رَاشِدٍ، عَنْ سُلَيْمَانَ بْنِ مُوسَى، عَنْ عَمْرِو بْنِ شُعَيْبٍ، عَنْ أَبِيهِ، عَنْ جَدِّهِ، أَنَّ رَسُولَ اللَّهِ صلى الله عليه وسلم قَالَ ‏"‏ كُلُّ مُسْتَلْحَقٍ اسْتُلْحِقَ بَعْدَ أَبِيهِ الَّذِي يُدْعَى لَهُ ادَّعَاهُ وَرَثَتُهُ مِنْ بَعْدِهِ فَقَضَى أَنَّ مَنْ كَانَ مِنْ أَمَةٍ يَمْلِكُهَا يَوْمَ أَصَابَهَا فَقَدْ لَحِقَ بِمَنِ اسْتَلْحَقَهُ وَلَيْسَ لَهُ فِيمَا قُسِمَ قَبْلَهُ مِنَ الْمِيرَاثِ شَىْءٌ وَمَا أَدْرَكَ مِنْ مِيرَاثٍ لَمْ يُقْسَمْ فَلَهُ نَصِيبُهُ وَلاَ يَلْحَقُ إِذَا كَانَ أَبُوهُ الَّذِي يُدْعَى لَهُ أَنْكَرَهُ وَإِنْ كَانَ مِنْ أَمَةٍ لاَ يَمْلِكُهَا أَوْ مِنْ حُرَّةٍ عَاهَرَ بِهَا فَإِنَّهُ لاَ يَلْحَقُ وَلاَ يُورَثُ وَإِنْ كَانَ الَّذِي يُدْعَى لَهُ هُوَ ادَّعَاهُ فَهُوَ وَلَدُ زِنًا لأَهْلِ أُمِّهِ مَنْ كَانُوا حُرَّةً أَوْ أَمَةً ‏"‏ ‏.‏ قَالَ مُحَمَّدُ بْنُ رَاشِدٍ يَعْنِي بِذَلِكَ مَا قُسِمَ فِي الْجَاهِلِيَّةِ قَبْلَ الإِسْلاَمِ ‏.‏

It wasnarrated from ‘Amr bin Shu’aib, from his father, from hisgrandfather, that the Messenger of Allah (PBUH) said: “Every childwhois attributed to his father after his father to whom he isattributedhas died, and his heirs attributed him to him after hedied, he ruledthat* whoever was born to a slave woman whom he ownedat the time whenhe had intercourse with her, he should be namedafter the one to whomhe was attributed, but he has no share of anyinheritance that wasdistributed previously. Whatever inheritance hefinds has not yet beendistributed, he will have a share of it. Buthe cannot be named afterhis father if the man whom he claimed as hisfather did notacknowledge him. If he as born to a slave woman whomhis father didnot own, or to a free woman with whom he committedadultery, then hecannot be named after him and he does not inheritfrom him, even ifthe one whom he claims as his father acknowledgeshim. So he is anillegitimate child who belongs to his mother’speople, whoever theyare, whether she is a free woman or a slave.” Translation Not Available

Book Ref: Sunan Ibn Majah Book 23 Hadith 2746
Web Ref:  Sunan Ibn Majah Vol 4 Book 23 Hadith 2746