Skip to main content
added 118 characters in body
Source Link
Ali Jafer
  • 17.8k
  • 1
  • 28
  • 41

can you try this:

using (SPWeb web = site.OpenWeb(SPContext.Current.Web.ID)) 

instead of:

using (SPWeb web = site.OpenWeb()) 

this will explain why your code is failing :)

http://blogs.msdn.com/b/sasohail/archive/2010/10/31/access-denied-within-spsecurity-runwithelevatedprivileges.aspx

another method is to use this:

http://sarangasl.blogspot.co.uk/2009/12/add-user-to-sharepoint-user-group.html

hope it helps :)

can you try this:

using (SPWeb web = site.OpenWeb(SPContext.Current.Web.ID)) 

instead of:

using (SPWeb web = site.OpenWeb()) 

this will explain why your code is failing :)

http://blogs.msdn.com/b/sasohail/archive/2010/10/31/access-denied-within-spsecurity-runwithelevatedprivileges.aspx

hope it helps :)

can you try this:

using (SPWeb web = site.OpenWeb(SPContext.Current.Web.ID)) 

instead of:

using (SPWeb web = site.OpenWeb()) 

this will explain why your code is failing :)

http://blogs.msdn.com/b/sasohail/archive/2010/10/31/access-denied-within-spsecurity-runwithelevatedprivileges.aspx

another method is to use this:

http://sarangasl.blogspot.co.uk/2009/12/add-user-to-sharepoint-user-group.html

hope it helps :)

Source Link
Ali Jafer
  • 17.8k
  • 1
  • 28
  • 41

can you try this:

using (SPWeb web = site.OpenWeb(SPContext.Current.Web.ID)) 

instead of:

using (SPWeb web = site.OpenWeb()) 

this will explain why your code is failing :)

http://blogs.msdn.com/b/sasohail/archive/2010/10/31/access-denied-within-spsecurity-runwithelevatedprivileges.aspx

hope it helps :)