ISO-LWS observations of Herbig Ae/Be stars. II. Molecular lines