Tuesday, September 9, 2008

Attempted to perform an unauthorized operation.

Since last two days we are facing some strange error in SharePoint.
Attempted to perform an unauthorized operation

We are getting this error while updating something in SPWeb.

We are not getting why this error is occurred. We also try with admin login but still error shows that unauthorized operation.

Mean while we found strange solution for the strange problem.

Previously we are using SPWeb object with HTTPContext.Current.Web or properties.ListItem.Web in event handler.

SPWeb objWeb= HTTPContext.Current.Web;
SPWeb objWeb= properties.ListItem.Web;

But updating something regarding this web will cause this error.

So what we found that strange solution.
Do not use SPWeb object this way.
Create new SPWeb object with site.OpenWeb();

Like this
SPSite objSite = new SPSite(SiteUrl));
SPWeb objWeb= objSite. OpenWeb();

It worked for us.

But we don’t know what the reason will cause this problem and what the reason which solve this problem.

No comments:

Share your SharePoint Experiences with us...
As good as the SharePointKings is, we want to make it even better. One of our most valuable sources of input for our Blog Posts comes from ever enthusiastic Visitors/Readers. We welcome every Visitor/Reader to contribute their experiences with SharePoint. It may be in the form of a code stub, snippet, any tips and trick or any crazy thing you have tried with SharePoint.
Send your Articles to sharepointkings@gmail.com with your Profile Summary. We will Post them. The idea is to act as a bridge between you Readers!!!

If anyone would like to have their advertisement posted on this blog, please send us the requirement details to sharepointkings@gmail.com