The answer is that both of these have an impact. Although most people believe that only the moon has an impact on the tides of the Earth's oceans, the sun actually does have some amount of an impact. Here is a quote from the NOAA website that tells us this:
The word "tides" is a generic term used to define the alternating rise and fall in sea level with respect to the land, produced by the gravitational attraction of the moon and the sun.
The effects of the sun and the moon on tides are slightly different. The moon is more responsible for the daily changes in tide. By contrast, the sun is more responsible for the cycles in the height of tides. These cycles occur over longer periods of time (I refer here to the monthly cycle of neap and spring tides).
The gravitational force between the Earth and the Sun, and the gravitational force between the Earth and Moon lead to the formation of tides. But as the Moon is closer to the Earth, it has a larger influence on the formation of tides. The gravitational pull of the Moon creates two bulges of water, one on the side of the Earth facing the Moon, called the sub-lunar point, as the effect of the water getting pulled towards it more than the effect of the land getting pulled. The reverse is true on the other end called the anti-podal point, and again leads to the formation of a bulge. This is the reason behind the occurrence of the high tides. The areas between the sub-lunar points and the anti-podal points experience a low tide. Tides occur in a cycle of approximately 12 hours 30 minutes.
The effects of the Sun on the tides are apparent from the higher high tides and lower low tides once every two weeks when the sun and the moon are aligned. These are called the Spring tides. When the Sun and the Moon are at positions right angled to each other, it results in lower high tides and higher low tides. These are called the Neap tides and occur at intervals of 2 weeks between the spring tides.