With the Sun, it's reasonably straight forward to identify the lines as it's predominantly Hydrogen and Helium. The hard part is that you can only do what I've done at a total solar eclipse as it uses the moon to block out the bright bit and just leave a thin sliver of solar atmosphere. That's an emission spectra, like your lamp.
If you do a solar spectra at any other time, you'll have a continuous rainbow with some dark absorption lines in it and they correspond to the different elements in the same way.
To identify which is which, you pretty much do what you've done with a lamp with a known gas in it. Many spectrophotometers have a neon lamp built into them for that reason.
As long as you use the same lens and grating in the way that you've done it, you just need one calibrating image that shows both the spectrum and the light source (called the zero order image). If you can identify two lines and measure the distance (in pixels) from the zero order image to the lines, you can work out the wavelength of any of the other lines and then look them up.
The software does all that for you.
A simple way to get a solar spectrum is to use a needle on a bit of black card. The needle reflects a thin line of sunlight and when you photograph that through your diffraction grating, you see the spectrum with the black background. If your needle is smooth, you should be able to resolve some of the wider absorption bands.
Steve.