One or both of your rails are broken.
Do a search on repair sunroof and you will find ample info to take it out, replace the rails and put it back.
It is said to be an annoying but entiely doable job.
You will need to remove it. Every piece comes out through the top.
Get some special wax as well.
The parts are about $175 in all, I think.
Semibodacious Transmogrifications a Specialty
1990 300D 2.5 Turbo sedan 171K (Rudolf)
1985 300D Turbo TD Wagon 219K (Remuda)
"Time flies like and arrow, yet fruit flies like a banana"