views:

536

answers:

2
    public class UploadHandler : IHttpHandler
    {
        public void ProcessRequest(HttpContext context)
        {
        ...

        // Create the directory if needed...
        if (!Directory.Exists(uploadDir))
        {
            System.Security.AccessControl.DirectorySecurity ds = new System.Security.AccessControl.DirectorySecurity(RivWorks.AppSettings.UploadRoot, System.Security.AccessControl.AccessControlSections.All);
            Directory.CreateDirectory(uploadDir, ds);
        }
        ...
    }

I have the above snippet of code for a ASHX file and it works fine in my local environment. As soon as I push it to a server environment I don't get an error, it appears to have built the directory, yet when I check for it - well - it is not there. When I run it via a FLEX app we are getting this error:

Error #2038: File I/O Error. URL: http://%5Bourdomain%5D.com/UploadHandler.ashx?CompanyID=d229cc80-ca96-4a8a-992c-80c94ac2c6b4

Is there anything I am missing?

UPDATE:

  1. I can create files anywhere on disk
  2. I cannot create directories anywhere on disk.

I get this error now when trying to create a directory:

The process does not possess the 'SeSecurityPrivilege' privilege which is required for this operation.

+2  A: 

Have you checked that your program has the correct access rights to the relevant directories on the server?

ChrisF
ASP.NET account - Full rights, IUSR_machineName - Full rights, NETWORK SERVICE - Full rights. Am I missing any accounts?
Keith Barrows
http://mayurthakor.wordpress.com/2009/01/05/set-rightspermission-to-avoid-file-io-error-2038-in-flex-file-upload/ - And I am doing this through Windows Explorer, right-click, properties/security....
Keith Barrows
and we can keep bumping up the Votes *BUT* my problem is not fixed.
Keith Barrows
This is not the correct answer unfortunately. While it is the typical answer it does not fix my problem. My problem has something to do with GPO and elevating the IIS account - which opens us up for a broader surface area of attack.
Keith Barrows
Ended up twiddling with the App Pool identity and got it running.
Keith Barrows
A: 

Is the site runs with identity impersonation=true? If so it runs under your credentials/authorization in your environment

napoleon