Tuesday, October 16, 2007

SharePoint 2007: Running Elevated Code and Still No Permission

i have created a provisioning wizard to control where and what sites are created. I do this through a web part that is added to the STS#1 definition. To prevent users from accessing the site settings menu everyone is setup at the top level as a "Reader". So obviously if i want to create a site, within the users context, i need to elevate their permission. There is plenty of code out there that demostrates the SPSecurity.RunWithElevatedPrivileges, however, if you are to use the SPContext while inside a call to RunWithElevatedPrivileges it does not elevate the current context permission. You will have to open a new site. Examples below:

// Doesn't Work
SPSecurity.RunWithElevatedPrivileges(delegate {
using (SPWeb web = SPContext.Current.Web) {
// provision site & do other jazz
web.Webs.Add(...);
}
});

// Better
SPSecurity.RunWithElevatedPrivileges(delegate {
using (SPSite site = new SPSite(SPContext.Current.Web.Url)) {
using (SPWeb web = site.OpenWeb()) {
// provision site & do other jazz
web.Webs.Add(...);
}

}
});


Odd but works for me.

Monday, October 01, 2007

Extinction of Languages: Bad thing?

I was reading this article on Slashdot and they make it seem like this is a bad thing. I think this is a good thing. While the languages are gone, the cultures are still there. With the benefit of being able to communicate now with a greater number of people. I consider a language to be a standard, a standard in which people communicate. As with any standard, they arise from necessity. With technology bridge geographical communication obstacles, there is a boarder range of communication and essentially new standards--which may render older standards obsolete. If this wasn’t the case, we would never make any progress. How’s the old saying, “Out with the old, In with the new”.