Pages

Tuesday, January 26, 2010

Getting access denied error while updating list items

I was getting access denied error while updating list items, I already tried to put my code into SPSecurity.RunWithElevatedPrivileges delegate, still I was getting error. Below was my actual code.

CODE:

//code line for updating list columns

Listitem.update()

List.Update()

After doing debugging and removing line by line from actual code I have figured out actual problem – the user who has contributor rights(normal user) was getting access denied error, admin users can able to update list without any problem, it’s because of LIST.UPDATE() statement, because contributor rights users don’t have permission to change anything into List settings, they can add/delete list items but they can’t able to change anything into list, after removing LIST.UPDATE() statement from my actual code, all users were able to successfully update the list items.

Enjoy!

5 comments:

  1. Hi Sanket

    You saved my Life with this blog. Please post the good blogs like this.

    Thanks a lot
    Disha Shah

    ReplyDelete
  2. So run that by me again? how were they able to update list items without a call to .Update() ?

    ReplyDelete
  3. Hi Shane,

    I was talking about List.Update(), when we are updating list items at that time we don’t require to call List.Update(), we can update the items by ListItem.Update() only.

    Thanks for your comment!
    Sanket

    ReplyDelete
  4. I am not using any LIST.UPDATE() but the loged in user have contributor permissions only. still i am geeting the Access is denied error

    SPWorkflowTask.AlterTask(this._TaskListItem, taskHash, true);

    ReplyDelete
  5. Hi Sanket,
    Your blog helps me a lot. I was stucked at the same issue since last 2 days.
    But i have figured out one strange issue. I will be thankful to you, if you can explain it for me.

    When I tried to update the sharepoint list item, i got the access denied exception, but when checked the item in the list it was updated. How is it possible, if user in the group have contribute access dont have permission to update the list item?

    Waiting for your valuable response.
    Also Thank you very much for this blog.


    -Kaustubh

    ReplyDelete