If the sunroof on your BMW E39 M5 doesn’t close properly anymore, or maybe it rattles when you hit some bumps, this is a do it yourself page for you.
The parts needed are the left and right control rail kit. You will need a T-25 Torx wrench, screwdriver, pliers and heavy lithium grease. The first step is to retract the sunroof slightly back so that you can remove the front stops on both sides. Close the roof after this and trying pressing the tilt button. More likely, you might have to do this manually.
Remember to place something soft between the glass and the sunroof to keep it tilted. And now you are ready for the actual job.
This site will give you detailed information on how to repair your sunroof. The author is kind enough to provide pictures too.
Check it out at the following site: http://bimmer.roadfly.com/bmw/forums/e39/8023857-4.html