R – UpdateListItem method and System Account

sharepoint

I've developed a Help Desk application in Visual Studio that uses a Sharepoint List to store the data.

My problem is that when i use the UpdateListItems method for submitting a new record, Sharepoint automatically assigns to the "Created By" (Author) field as "System Account" and this prevents the trigger of a workfow i created with Sharepoint Designer.
I've tried to force the Created By field during submit by adding to my batch person id;#person username

but it will still show "System Account"!!

Any ideas!?

sorry for my bad english:(

Best Answer

Have you considered using impersonation to update the list item?

You need a user on the site who has the correct access that you can impersonate. Look into the SPSite constructor that gets passed in an SPUserToken.

SPUserToken token = targetWeb.AllUsers["BobTheImpersonationAccount"].UserToken;
using(SPSite impersonatedSite = new SPSite("http://siteurl", token))
{
    //Anything accessed through impersonatedSite and its child objects are now executing under the guise of BobTheImpersonationAccount

}
Related Topic