This is a question that has been touched on here and there, and yet I can't find a good answer.

Suppose I am writing a story set in the Star Wars universe. I don't want to dodge copyrights and trademarks by renaming everything and everyone. I want it to be well recognizable.

I have two options, if I understand it correctly:

1. Go to Lucasfilm and secure the rights. This may be the proper way to start, but I just don't know if they are going to talk to me at all, or ask me for a lot of money.
2. Write it as a fan fiction. I know I have to worry much less about copyright issues if I am not publishing my book. This must be an easy way to start.

Suppose I wrote a fan fiction without talking to the copyright holder, and it came out well. Is it possible (or realistic) to "legalize" my work afterwards? Or should I have discussed my story with Lucasfilm Story Group first, and if by then it is off-canon, it would become non-publishable?