0

I am uploading doucment using object model. However my 'UploadFile()' method throws exception "The request failed with HTTP status 403: Forbidden.". This happens if my current user is not a member of one custom group (ABCGroup). And 'ABCGroup' has all permissions. Even if I give 'Full Control' permissions to this user it doesn't work. So I am really wondering.

1
  • It's happening when they are part of ABCGroup or are not part of ABCGroup? It would be helpful to post a bit more code - there are some API calls that require high permissions.
    – lgaud
    Commented Oct 22, 2012 at 1:24

2 Answers 2

1

As you are trying to upload files through code, did you try to use the RunWithElevatedPrivileges method ? Below is a link which will give you more information on the method.

http://msdn.microsoft.com/en-us/library/bb466220(office.12).aspx

You can do something like this:

SPSite siteColl = SPContext.Current.Site;
SPWeb site = SPContext.Current.Web;
SPSecurity.RunWithElevatedPrivileges(delegate() {
using (SPSite ElevatedsiteColl = new SPSite(siteColl.ID)) {
 using (SPWeb ElevatedSite = ElevatedsiteColl.OpenWeb(site.ID)) {

    ////Add your code to upload the file  here....

 }
}
});
0

I assume you are adding the document through the UploadFile() method to a document library. So make sure the user who is uploading the document has permission to the document library. No need to use RunWithElevatedPrivileges.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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