There are different ways for using impersonation in SharePoint 2007. Probably the most common way is calling the RunWithElevatedPrivileges method defined into the SPSecurity class. If you don't know how to impersonate using this method, you should visit the msdn reference.
But sometimes this approach doesn't work, infact this method is useless if you are trying to impersonate when writing event handlers. An another possible solution, is using the Explicit Impersonation in SharePoint 2007. This method will impersonate through user's SPUserToken class.
Here's the code snippet for impersonating a different user:
SPUser user = SPContext.Current.Web.AllUsers[@"DOMAIN\LOGINNAME"];
SPUserToken token = user.UserToken;
using (SPSite site = new SPSite(SPContext.Current.Site.Url,token))
{
using (SPWeb web = site.OpenWeb())
{
SPList list = web.Lists["YourList"];
list.Items[0]["Title"] = "Your new title";
list.Items[0].Update();
}
}