About Me

My photo
a Dynamic and Energetic guy.....

Monday, July 13, 2009

RunWithElevatedPrivileges in sharepoint


When we try to get data from a document library that is not assigned for current user, we are getting this error.

Solution is:::::

SPSecurity.RunWithElevatedPrivileges(delegate()
{
//any code that we have to use
});


Sometimes even we add this delegate still it's not working.
That's because the object we are using made without elevated privileges.
(Ex:- We are creating SPWeb under the delegate, but the SPSite(parent object) object is outside the delegate, then we won't get chance to access data)

No comments:

My Masters