It happens quite often that I have to write a piece of code to set user permissions on a SharePoint site. One of the challenges you encounter when doing so is that you need to have a valid SPUser object, that is known in the site collection to be able to do this.
If you want to create a new subsite or web you can start out like this:
// Open an existing site collection SPSite portalSite = new SPSite("http://portal"); // Create a new subsite (web) SPWeb newWeb = portalSite.AllWebs.Add("http://portal/newweb", "My New WebSite", "This is my new web site", 1033, "STS#0", true, false); // Get the...