How can I apply role to users within the code without using ASP.net config?
I assume you don't want to embed the username, passwords and membership information inside the web.config. You can use the provider model to arrange authentication & authorization, it takes away much of the donkey work
There is a good series on doing this with SQL server here[
^]. In this case you can run SQL against the database to set everyone up. I think that answers the other parts of your question, but I'm not fully clear I understand it.
There are other providers available with .net, so you are not restricted to SQL, you can extend these and even implement your own.