mushu has asked for the wisdom of the Perl Monks concerning the following question:

Using ActiveState 5.8 build, I am wondering if it is possible to have a script access a resource via UNC that requires a specific username, in order to then FTP that file to a different server? Ok, that was rather awkward... this might be better: what is the logistics of having Perl access a UNC path that is "invisible" to everyone except that user? I could not find anything in cpan or google that appears to do this. I can't just set the "runas" value on my ".pl" sourcecode file because Windows only allows you to runas a different user when it is an executable file. Comments?
  • Comment on unable to locate info on accessing UNC file as diff user

Replies are listed 'Best First'.
Re: unable to locate info on accessing UNC file as diff user
by ikegami (Patriarch) on Mar 18, 2005 at 18:42 UTC
    You may not be able to do run-as on "script.pl", but you could on "perl script.pl".
Re: unable to locate info on accessing UNC file as diff user
by flogic (Acolyte) on Mar 18, 2005 at 20:27 UTC
    I asked a similar question recently here. Z1R pointed out Win32::NetResource. I haven't tried it yet but it might help you out.
Re: unable to locate info on accessing UNC file as diff user
by mushu (Initiate) on Mar 18, 2005 at 19:31 UTC
    Well, the original problem is worse than that. Perl is installed on the web server. This script is also there. It needs to run as a nightly task that grabs a file from a user's home directory and FTP's it to a different server. So, I can't run the Perl.exe program as that user since it will be used by other processes. That user account is locked out of local access and only has that user's folder access perms. BLAH!?!?

      I faced a similar problem with a batch script on a Windows 2000 server. I had the network admins set up a service account on the domain and then I used the Windows "Scheduled Task" functionality. I selected my script directly (using "shebang" syntax to point to the perl runtime) and selected the service account in the "run as" portion. Works like a champ.

      You said it needs to run nightly, and it sounds like you already have a domain ID for it, so it may be easy to set up. I think you can probably just use the standard UNC syntax for the pathnames. But I'm not 100% certain about this last part. I know that the "run-as" bit works though.



      PCS