Having installed MANY different types, models, and versions of sunroofs for a few years, I can give u a pretty good idea of what is wrong.
If u have a factory sunroof, (Full power model) then there is several things to check. First of all understand that the rubber gasket around the glass is NOT designed to seal up and not leak. It is more of a wind/road noise preventer and to slow down but not stop water. This is why the basket, (the main framework of the roof, trackwork, etc.) are smaller than the hole in the roof of the car, as well as having four draintubes at the corners. If the rubber seal does not touch all the way around, you have two options: 1. cut a SMALL hole in the seal, and slide in thin gauge wire. This can help fill out the seal. 2. replace it. More expensive than the earlier, but probably better.
There are several things to check, most of which are easy to do. Keep in mind this is all easier to do with the headliner out of the vehicle, but can be accomplished with the headliner in the car. You can pop off the draintubes and pour some water down them. I used a pressure spray bottle when I installed sunroofs professionally. What happens is junk can clog up the tubes (leaves, rocks, etc.) as well as algae, mildew, bugs can decided to start growing in there. If you pour water and it does not drain as fast as you pour the water in, check for kinking in the hoses, and/or replace them.
The basket of the sunroof should rest slong the underside of the roof of the car all the way around the car. If it doesn't bust out some silicon and make it so. Thinking back on my Wabasto sunroof training, it was actually standard procedure to use butyl instead of making the basket taller, reason being of tweaking the metal of the roof. If the car was wreaked, it it is possible that it does not sit right.
If you need to adjust it, the glass has metal brackets mounted on the sides which line up to holes on brackets on the trackwork. If u loosen up the screws, u can slide the sunroof glass up and down accordingly, just line it up to the roof, tighten them down, and be done!
If the sunroof is a "slider" or "pop-up" they only leak in one or both of two places. The seal where the glass meets the seal. Or the seal where the plastic housing meets the roof. Either way with either of those two roofs, and I wouldn't recommend a rookie trying to tackle either of those jobs without someone experienced helping them out. I'd give u all the guidance I can though!
Hope this helps you out and gives u direction with your roof!