Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

Re: Is it possible to have a script run under one account and open a file using another?

by Kanji (Parson)
on Jul 30, 2003 at 01:12 UTC ( [id://279047]=note: print w/replies, xml ) Need Help??


in reply to Is it possible to have a script run under one account and open a file using another?

What you want should be doable with Win32::AdminMisc's CreateProcessAsUser or LogonAsUser functions, with example code included in the RUNAS.PL file that accompanies the install.

But ... you'll have to put the password for whatever account you log into in the CGI script, so whether or not this is a "bad idea" depends on your level of paranoia and confidence in the security of your scripts.

    --k.


  • Comment on Re: Is it possible to have a script run under one account and open a file using another?
  • Select or Download Code

Replies are listed 'Best First'.
Re: Re: Is it possible to have a script run under one account and open a file using another?
by rzward (Monk) on Jul 30, 2003 at 01:35 UTC
    Thank you for the tip.

    Win32::AdminMisc has LogonAsUser, which appears to be what I'm looking for. I was hoping for a platform independent function but I guess that's not possible.

    Looking at the requirements for functions such as LogonAsUser, switching the anonymous user account under which the scriopt runs might be less trouble than asking system administrators to set priveleges such as "SeTcbPrivilege", "SeChangeNotify" and "SeAssignPrimaryToken".

    I'll take a closer look. Thank you!

    Richard

      If you want it to be portable, abstract it one level, and then bring in whatever code you need based on the OS in your abstraction layer rather than the application layer. As you need support for new environments, you only adjust your abstraction layer.

      Example:

      # Application.pl use IO::File::AsUser; # Your abstraction layer my $fh = IO::File::AsUser->open($file, $user); # AsUser.pm package IO::File::AsUser; #blah blah sub open { if ($Windows) { do_what_needs_to_be_done_on_windows(); } elsif ($Unix} { do_what_needs_to_be_done_on_unix(); } }

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://279047]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others goofing around in the Monastery: (5)
As of 2024-04-19 16:19 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found