"Soria Moria Castle" is a Norwegian fairy tale, probably the most culturally important fairy tale in Norway itself, despite not being as world-famous as "East of the Sun and West of the Moon". It tells the tale of a talentless and good-for-nothing lad, Halvor. His fortunes change when he decides to go to sea (notably a life he can't easily run back home from); a storm drives him to strange shores, where he walks until he sees in the distance a castle shining in the sun. Inside he finds a princess at the spinning wheel, who warns him that it is no place for Christian folk, as the castle belongs to a troll with three heads. The princess schemes to have Halvor kill the three-headed troll, and then convinces him to rescue her three sisters, held by trolls in other castles. Then Halvor and the three princesses live happily together in Soria Moria Castle, but it almost comes to ruin when Halvor becomes homesick. The princesses give him a magic wishing ring that can take him home, and he really impresses everyone with his fine clothes, but he fails to follow their instructions in using it, so he loses it and the princesses as well, and has no idea where Soria Moria Castle is. He sets out to try to find it again, asking the advice of the Moon and the West Wind, and finally returns to discover that the youngest princess, the one he likes most, is having her wedding. But seeing Halvor, the princesses agree that he is more worthy to wed her, so the youngest princess throws the unfortunate bridegroom out the window and marries Halvor instead.
The story generally tends to be a symbol of the search for happiness and gives its name to one of the most famous paintings in Norway:
Theodor Kittelson, Soria Moria
It also gives the symbolism of Sissel's song, "Soria Moria":
Outside of Norway, it is much less known, but it has its occasional influence. "Soria Moria Castle" is the source of the name for Tolkien's Mines of Moria (Tolkien himself explicitly notes this in a letter somewhere). Most of the other associations that Tolkien's Moria has arise from what the name 'Moria' suggests in the context of his languages, but it's possible that the tones of longing and the Fellowship's finding that the Orcs have a troll with them might also be due to the fairytale.