Elevation: Run Code as an Administrator
Sometimes you may need your web part to perform tasks for which the current user doesn’t have priviliges. For instance, we needed a sign up form for our WCM web site where the user could enter contact information that should be stored in a list.
Naturally, our web site runs with anonymous access and the the anonymous users do not have access to the underlying lists, including the list where the contact information goes.
Thus, submitting to the list is not just a matter of doing an Items.Add() because this causes a login dialogue to pop up and ultimately a 401 Unauthorized error.
Normally you’d create an element in the list with code similar to this:
However, if the logged-in user doesn’t have sufficient credentials to write to the list, a login dialogue will pop up.
Run with Elevation
To get around this problem you can use SPSecurity.RunWithElevatedPriviliges() like this:
For this to work, you need to instantiate the SPSite and SPWeb objects inside delegate():

Now the list will be updated with a new element, created by the system account.
[...] For instance, you may have created a newsletter signup web part which posts data to a list (using elevation). In time, the list fills up with more or less sensitive information about your newsletter [...]
ViewFormPagesLockDown Does not Kick In « SharePoint Sharpener
August 28, 2008 at 12:15 pm