When you need to do something in a list or item, in SharePoint, with a specific user you can use the SPUserToken.

Here is an example:

try{
    SPWeb webOrigUser = SPContext.Current.Web;

    //get the token for the impersonation user
    SPUserToken token = webOrigUser.AllUsers[USERNAME].UserToken;

    SPSite site = new SPSite(SiteId/SiteUrl, token);
    …..
}catch{}

LEAVE A REPLY

Please enter your comment!
Please enter your name here