Python cgi script can't copy to or modify items on file server

Posted on 2014-08-19
Last Modified: 2014-08-22
I'm working on an application to be used on our intranet.  It needs to be able to create directories and move files to our file server (N:), and to eventually modify them.  Currently, I'm testing it using IIS (localhost) on my computer.  I'm a novice at IIS by the way.   Okay, I'm using a python cgi script and it is unable to do this...
driveLetter = r'N:'
    picDir = os.path.join(driveLetter,r'FieldPics') #set output directory as N:\FieldPics   
    picCountyDir = os.path.join(picDir, str(county[0])) #set output directory as N:\FieldPics\CountyName 
    if not os.path.exists(picCountyDir):
        os.makedirs(picCountyDir) #if necesssary create the county directory inside the N:\FieldPics directory

Open in new window

It tells me, "The system cannot find the path specified."   I have given IUSR and NETWORK SERVICE full control of N:\FieldPics.  I'm unable to figure out what I need to do next.
Question by:Nate_LR
    LVL 25

    Accepted Solution

    FIrst off, you'll need to use the UNC path rather than a mapped drive.  Mapped drives are based on the security context of the running process and your IIS process won't have an N:\ drive.  
    sharePath = r'\\MyServer\myShare'
    picDir = os.path.join(sharePath, r'FieldPrice')

    Open in new window

    If you're allowing anonymous access, your next problem will be a problem with IIS impersonation.  See the microsoft kb article ( for details.  But basically, you'll need to get IIS to use a network account to access the resource by setting the application pool identity to a domain account:

    1) Right-click the Application Pool hosting your CGI process (unless you've made changes it will be the DefaultAppPool)
    2) Select Advanced Settings...
    3) Update the Identity setting -- switch it to custom and enter the username (domain\username) and password of an account that IIS will use to access the resource

    Author Comment

    I REALLY appreciate this clockwatcher!

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Better Security Awareness With Threat Intelligence

    See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

    This article will show the steps for installing Python on Ubuntu Operating System. I have created a virtual machine with Ubuntu Operating system 8.10 and this installing process also works with upgraded version of Ubuntu OS. For installing Py…
    Sequence is something that used to store data in it in very simple words. Let us just create a list first. To create a list first of all we need to give a name to our list which I have taken as “COURSE” followed by equals sign and finally enclosed …
    This tutorial will walk an individual through configuring a drive on a Windows Server 2008 to perform shadow copies in order to quickly recover deleted files and folders. Click on Start and then select Computer to view the available drives on the se…
    This tutorial will walk an individual through the process of transferring the five major, necessary Active Directory Roles, commonly referred to as the FSMO roles to another domain controller. Log onto the new domain controller with a user account t…

    759 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    11 Experts available now in Live!

    Get 1:1 Help Now