Its a silly question </br>
How to extract list of read names and their corresponding aligned fasta sequence name as table from the reference provided based on alignment.bam file
Probably I don't understand the question, but what about this?

    samtools view alignment.bam | cut -f1,3

Unless fasta identifier != "fasta sequence name"