I have a web part that, after insert an item in a list where the current user has the permission, need to insert an item in a list where the current user hasn't access. How can I do that?

  • Maybe Gaetanu You Are doing something wrong? Try to sit in it more then 25 minutes.
    – Grzegorz Z
    Oct 16, 2012 at 14:09

1 Answer 1


You can use the RunWithElevatedPrivileges method to elevate your code and allow the user permission to the list.

SPUser currentUser = SPContext.Current.Web.CurrentUser;
     // code to run here
   item["Editor"] = currentUser;
   item["Author"] = currentUser;


  • I read that is not a good way to accomplish this issue and I after the update I haven't the item in the list
    – Gaetanu
    Oct 16, 2012 at 13:56
  • I'm curious, where did you read this is not a good method to use? Run a debugger and ensure the code is firing. It should work without issue. On your new items, if you want them tagged from the current user, you need to declare a user object outside of the method, then set it to the Author and Editor fields. Oct 16, 2012 at 14:16
  • 1
    Thanks for sharing that, I haven't come across that before. Asking my colleagues at the table, they also lean towards using SPSecurity.RunwithElevatedPrivilege. I'm going to do some more research to see what the real differences are. Oct 16, 2012 at 18:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.