December 2007 Entries

Lock down application pages on a public web site

If you are creating public web sites and anonymous users have access to the site all anonymous users will have read access. By default this means that all users can also access the application and forms pages like for instance the allitems.aspx of the pages library. Now it's true that you would need to know the url to get there, but it still doesn't look very professional. Microsoft felt the same way and has thought of a solution for this, the ViewFormPagesLockDown. Donald Hessing has written more about it on his brand new blog. Check it out!

Using SPWeb.EnsureUser(loginName) to add a new SPUser to a web

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...