Sharepoint Forum

Ask Question   UnAnswered
Home » Forum » Sharepoint       RSS Feeds

Unable to create/add files/folders in Shared documents programmatic

  Asked By: Demarco    Date: May 11    Category: Sharepoint    Views: 5076

I have an xslt saved in my Shared documents- path being Shared Documents/Common/XSLT/Word2HTML-.NET-script.xsl.

This xsl calls a method in extension object- method definition is as follows:

public String getFolderPath(String strImage, String filename)
String finalImagePath = returnFolderPath(strImage, filename);
return finalImagePath;

returnFolderPath() method is as follows:

public static String returnFolderPath(String strImage, String filename)
byte[] data = Convert.FromBase64String(strImage);
String fullPath = String.Empty;
SPFolder sourceDir;
spsWeb.AllowUnsafeUpdates = true;
if (!spsWeb.GetFolder(imageFolder).Exists)
sourceDir = spsWeb.GetFolder(imageFolder);
spsWeb.Files.Add(imageFolder + "/" + filename, data, true);
//sourceDir.Files.Add(filename, data, true);
fullPath = @"http://localhost:8082/" + sourceDir.Url + "//" + filename;
return fullPath;

I have purposely called another method from getFolderPath()- since the creation of SPWeb object in extension object was causing problems.

However the problem that I face now is- I am neither able to create a new folder, nor add files to the existing folder. Following is the error that I receive:

Exception Details: System.UnauthorizedAccessException: Access denied.

ASP.NET is not authorized to access the requested resource. Consider granting access rights to the resource to the ASP.NET request identity. ASP.NET has a base process identity (typically {MACHINE}\ASPNET on IIS 5 or Network Service on IIS 6) that is used if the application is not impersonating. If the application is impersonating via <identity impersonate="true"/>, the identity will be the anonymous user (typically IUSR_MACHINENAME) or the authenticated request user.

I have granted Administrator level permissions on my Sharepoint site to the following accounts:
1. KAUSTUBHA\aspnet (Local machine aspnet account)
2. Network Service

Also, impersonate is set to "true" in web.config, and my anonymous access is set ON, with my network login (cyb-ms\kaustubha) as the anonymous access login.

Please help me on this, also tell me if I have left out trying anything...



1 Answer Found

Answer #1    Answered By: Laura Walker     Answered On: May 11

Check Application Pool Identity