Copy folder from local machine to other serverRSS

9 replies

Last post Aug 19, 2005 11:20 AM by sirchandler

  • Copy folder from local machine to other server

    Aug 15, 2005 04:51 AM|sirchandler|LINK

    Hi im having trouble with our site,  i have to copy data from one server(web server) to another server. At the moment i get this error:

    Microsoft VBScript runtime error '800a0046'

    Permission denied

    /file/1/main.asp, line 26

    I have created a share with the proper permissions for the iusr_ account and for a domain\user account and the filesystem permissions are good too. Can someone shed some light on my problem?

    CODE:

    Dim root, Code, Projectname, ProjectCode

    GetProjectCode(session("projectid"))
    root = "\\servername\sharename\directoryname\" & projectname & "-^-" & ProjectCode

    CheckFolder root

    Sub CheckFolder(folder)
        Set objFSO2 = Server.CreateObject("Scripting.FileSystemObject")
        if  not objFSO2.FolderExists(folder) then
            folder = mid(folder,1,len(folder))
            objFSO2.CopyFolder "c:\directory" , folder , false
            end if
        set objFSO2 = nothing
    end sub

  • Re: Copy folder from local machine to other server

    Aug 15, 2005 08:47 AM|tomkmvp|LINK

    See the section on "Synchronizing the IUSR_machine accounts":
    http://www.aspfaq.com/show.asp?id=2168
  • Re: Copy folder from local machine to other server

    Aug 15, 2005 10:29 AM|sirchandler|LINK

    Hi thanks for the quick reply.  I was under the impression that since my 2 servers are in the same domain, that I would be able to define a domain account that had  the proper permissions to access the files and copy them to the other location. Is this possible? or do i have to use anonymous access and the iusr_ account?
  • Re: Copy folder from local machine to other server

    Aug 15, 2005 11:07 AM|tomkmvp|LINK

    A domain account would work but it's not clear how you're using it.  On way is to use a domain account as the anonymous user.
  • Re: Copy folder from local machine to other server

    Aug 15, 2005 11:25 AM|sirchandler|LINK

    OK, Lets see if I can explain the situation better. When I try to copy from Web-server A to File-server B, I get a permission denied. I would like to define this to run  as a domain user, if not possible then we have to call a script that does a net use as a different user and performs the copy action. The user is defined in global.asa but I think the webserver is using other credentials (thats why i tried setting the permissions for the iusr account aswell). Both servers are windows 2003 servers.

    PS Thanks again for your quick reply

  • Re: Copy folder from local machine to other server

    Aug 15, 2005 11:56 AM|jeff@zina.com|LINK

    This also depends on how you're authenticating to the system.  The script may be running under the anonymous user account, or it may run under the account of the user that was authenticated.  One way that may get what you need is to make the anonymous user account a domain account.  You can create a domain account for IIS, then in IIS go to the properties for the web server, directory security tab, access and control, and set the account to be used.  Grant that same account the necessary access on the other system, and use a UNC convention to get there, not a mapped drive letter.

    Jeff
    Have you Binged a solution before posting?
  • Re: Copy folder from local machine to other server

    Aug 15, 2005 02:54 PM|tomkmvp|LINK

    Yes, and the link I provided pretty much explains this.
  • Re: Copy folder from local machine to other server

    Aug 19, 2005 06:16 AM|sirchandler|LINK

    Ok, ive gotten it running now under anonymous acess, but i want my users to be authenticated. Right now I have the copy action working properly with the above code, but only anonymous access. How can I get my users authenticated(even plain text would be acceptable!) but have the copy action run under other credentials??
  • Re: Copy folder from local machine to other server

    Aug 19, 2005 09:54 AM|tomkmvp|LINK

    Remove anonymous access and the user's credentials will be used instead.  make sure they have NTFS change permissions to the folder.
  • Re: Copy folder from local machine to other server

    Aug 19, 2005 11:20 AM|sirchandler|LINK

    I've tried removing anonymous access, the problem is that i  would have to give the users Full Control perms because we need to do some setting of security on the files that have been copied. That is why i wanted to define the job to run as a (predefined)user with full control on the target machine, so that my users cannot screw up the rest of the security in this folder. If this cant be done ill have to use tomkmvp's solution above.