0

i need help wit this I want user to edit list items (insert) without having a permission of edit for that list in c# how can i do that?

  • What version of SharePoint are you targeting? – Rob Windsor Oct 15 '18 at 14:19
1

Try using SystemAccount System Account.

SPUserToken sysToken = properties.Site.SystemAccount.UserToken;
using (SPSite elevatedSite = new SPSite(properties.Site.ID, sysToken))
{
   using (SPWeb elevateWeb = elevatedSite.OpenWeb())
   { 
       //your code here...
   }
}

BOUCHAALA AHMED

1

You can use SPSecurity.RunWithElevatedPrivileges, here is an exemple :

Guid siteId = SPContext.Current.Site.ID;
Guid webId = SPContext.Current.Web.ID;

SPSecurity.RunWithElevatedPrivileges(delegate()
{
    using (SPSite site = new SPSite(siteId))
    {
        using (SPWeb web = site.OpenWeb(webId))
        {
            // Your code here
        }
    }
});

BOUCHAALA AHMED

  • every time i got this Sorry, this site hasn't been shared with you. – Shams Eldeen Oct 15 '18 at 14:46
0

In C#, I believe you can use impersonation to add list items in sharepoint list without having permission on list.

For more information, click here.

Impersonation in SP 2010, here.

Using SPTokens for impersonation. For more info here.

Please upvote if this answer helped you in any way.

  • in SP2013?? how can I – Shams Eldeen Oct 15 '18 at 13:22
  • Use RunWithElevatedPrivileges() in C#, see first link for more information clarification. – Ganesh Sanap Oct 15 '18 at 14:01
  • every time i got this Sorry, this site hasn't been shared with you. – Shams Eldeen Oct 15 '18 at 14:45
  • Great. Please upvote if this answer helped you in any way. – Ganesh Sanap Oct 16 '18 at 11:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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