Assuming it's an electric sunroof, I had a 300 V8 a while ago and that had an auto opening front sunroof as well.
Only mine opened on the way to work in the pooring rain and then refused to close using the buttons so I had to manually close it with the allan key (after I got to work!!). :roll:
I never figured out what the cause of mine was as it had a new ECU, a good working motor in the front, new motor in the back and it all worked prior to that night. The auto opening seemed to occure at the same time as I hit a bump in the road so it may have been a bad earth or something like that.
I didn't both with trying to fix it, I just removed the connections from the ECU and left it like that until it was sold.
After all, who needs a sunroof in the Outer Hebrides?