Fix permission query for lecture attachments